summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/UICommon/XUIScrollView.cs
blob: fd301524031314405227cc6f709a0b1124d3fb94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using UILib;
using UnityEngine;
using XUtliPoolLib;

public class XUIScrollView : XUIObject, IXUIScrollView
{

    protected override void OnAwake()
    {
		base.OnAwake();
        m_uiScrollView = GetComponent<UIScrollView>();
        if (null == m_uiScrollView)
        {
            XDebug.singleton.AddErrorLog("null == m_uiScrollView");
        }
    }

    public void ResetPosition()
    {
        m_uiScrollView.ResetPosition();
    }

    public void UpdatePosition()
    {
        m_uiScrollView.UpdatePosition();
    }

    public void SetCustomMovement(Vector2 movment)
    {
        m_uiScrollView.customMovement = movment;
    }

    public void SetPosition(float pos)
    {
        Vector2 pv = NGUIMath.GetPivotOffset(m_uiScrollView.contentPivot);
        m_uiScrollView.SetDragAmount(pv.x, pos, false);

        // Next move the clipping area back and update the scroll bars
        m_uiScrollView.SetDragAmount(pv.x, pos, true);
    }

    public void SetDragPositionX(float pos)
    {
        Vector2 pv = NGUIMath.GetPivotOffset(m_uiScrollView.contentPivot);
        m_uiScrollView.SetDragAmount(pos+pv.x, pv.y, false);

        // Next move the clipping area back and update the scroll bars
        m_uiScrollView.SetDragAmount(pos + pv.x, pv.y, true);
    }

    public void SetDragFinishDelegate(Delegate func)
    {
        m_uiScrollView.onDragFinished = (UIScrollView.OnDragFinished)func;
    }

    public void SetAutoMove(float from, float to, float moveSpeed)
    {
        m_uiScrollView.SetAutoMove(from, to, moveSpeed);
    }

    public bool RestrictWithinBounds(bool instant)
    {
        return m_uiScrollView.RestrictWithinBounds(instant);
    }

    public void MoveAbsolute(Vector3 absolute)
    {
        m_uiScrollView.MoveAbsolute(absolute);
    }

    public void MoveRelative(Vector3 relative)
    {
        m_uiScrollView.MoveRelative(relative);
    }

    public void NeedRecalcBounds()
    {
        m_uiScrollView.NeedRecalcBounds();
    }

    private UIScrollView m_uiScrollView = null;
}