コード例 #1
0
 static public int SetScrollPane(IntPtr l)
 {
     try {
         FairyGUI.GScrollBar self = (FairyGUI.GScrollBar)checkSelf(l);
         FairyGUI.ScrollPane a1;
         checkType(l, 2, out a1);
         System.Boolean a2;
         checkType(l, 3, out a2);
         self.SetScrollPane(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #2
0
        public ScrollPane(GComponent owner,
                                    ScrollType scrollType,
                                    Margin margin,
                                    Margin scrollBarMargin,
                                    ScrollBarDisplayType scrollBarDisplay,
                                    int flags)
        {
            _throwTween = new ThrowTween();

            _owner = owner;
            _container = _owner.rootContainer;

            _maskHolder = new Container();
            _container.AddChild(_maskHolder);

            _maskContentHolder = _owner.container;
            _maskContentHolder.x = 0;
            _maskContentHolder.y = 0;
            _maskHolder.AddChild(_maskContentHolder);

            if (Stage.touchScreen)
                _holdArea = 20;
            else
                _holdArea = 5;
            _holdAreaPoint = new Vector2();
            _margin = margin;
            _scrollBarMargin = scrollBarMargin;
            _bouncebackEffect = UIConfig.defaultScrollBounceEffect;
            _touchEffect = UIConfig.defaultScrollTouchEffect;
            _xPerc = 0;
            _yPerc = 0;
            _aniFlag = true;
            _scrollBarVisible = true;
            _scrollSpeed = UIConfig.defaultScrollSpeed;
            _mouseWheelSpeed = _scrollSpeed * 2;
            _displayOnLeft = (flags & 1) != 0;
            _snapToItem = (flags & 2) != 0;
            _displayInDemand = (flags & 4) != 0;
            _scrollType = scrollType;
            _mouseWheelEnabled = true;

            if (scrollBarDisplay == ScrollBarDisplayType.Default)
                scrollBarDisplay = UIConfig.defaultScrollBarDisplay;

            if (scrollBarDisplay != ScrollBarDisplayType.Hidden)
            {
                if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Vertical)
                {
                    if (UIConfig.verticalScrollBar != null)
                    {
                        _vtScrollBar = UIPackage.CreateObjectFromURL(UIConfig.verticalScrollBar) as GScrollBar;
                        if (_vtScrollBar == null)
                            Debug.LogError("FairyGUI: cannot create scrollbar from " + UIConfig.verticalScrollBar);
                        else
                        {
                            _vtScrollBar.SetScrollPane(this, true);
                            _container.AddChild(_vtScrollBar.displayObject);
                        }
                    }
                }
                if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Horizontal)
                {
                    if (UIConfig.horizontalScrollBar != null)
                    {
                        _hzScrollBar = UIPackage.CreateObjectFromURL(UIConfig.horizontalScrollBar) as GScrollBar;
                        if (_hzScrollBar == null)
                            Debug.LogError("FairyGUI: cannot create scrollbar from " + UIConfig.horizontalScrollBar);
                        else
                        {
                            _hzScrollBar.SetScrollPane(this, false);
                            _container.AddChild(_hzScrollBar.displayObject);
                        }
                    }
                }

                _scrollBarDisplayAuto = scrollBarDisplay == ScrollBarDisplayType.Auto;
                if (_scrollBarDisplayAuto)
                {
                    if (_vtScrollBar != null)
                        _vtScrollBar.displayObject.visible = false;
                    if (_hzScrollBar != null)
                        _hzScrollBar.displayObject.visible = false;
                    _scrollBarVisible = false;

                    _container.onRollOver.Add(__rollOver);
                    _container.onRollOut.Add(__rollOut);
                }
            }
            else
                _mouseWheelEnabled = false;

            if (_displayOnLeft && _vtScrollBar != null)
                _maskHolder.x = Mathf.FloorToInt((_margin.left + _vtScrollBar.width) * GRoot.contentScaleFactor);
            else
                _maskHolder.x = Mathf.FloorToInt(_margin.left * GRoot.contentScaleFactor);
            _maskHolder.y = Mathf.FloorToInt(_margin.top * GRoot.contentScaleFactor);

            SetSize(owner.width, owner.height);
            SetContentSize(owner.Bounds.width, owner.Bounds.height);

            _container.onMouseWheel.Add(__mouseWheel);
            _container.onMouseDown.Add(__mouseDown);
        }
コード例 #3
0
ファイル: ScrollPane.cs プロジェクト: yinlei/Fishing
        public ScrollPane(GComponent owner,
            ScrollType scrollType,
            Margin scrollBarMargin,
            ScrollBarDisplayType scrollBarDisplay,
            int flags,
            string vtScrollBarRes,
            string hzScrollBarRes)
        {
            onScroll = new EventListener(this, "onScroll");
            _refreshDelegate = Refresh;

            _throwTween = new ThrowTween();
            _owner = owner;
            _container = _owner.rootContainer;

            _maskHolder = new Container();
            _container.AddChild(_maskHolder);

            _maskContentHolder = _owner.container;
            _maskContentHolder.x = 0;
            _maskContentHolder.y = 0;
            _maskHolder.AddChild(_maskContentHolder);

            _scrollBarMargin = scrollBarMargin;
            _scrollType = scrollType;
            _scrollSpeed = UIConfig.defaultScrollSpeed;
            _mouseWheelSpeed = _scrollSpeed * 2;
            _softnessOnTopOrLeftSide = UIConfig.allowSoftnessOnTopOrLeftSide;

            _displayOnLeft = (flags & 1) != 0;
            _snapToItem = (flags & 2) != 0;
            _displayInDemand = (flags & 4) != 0;
            _pageMode = (flags & 8) != 0;
            if ((flags & 16) != 0)
                _touchEffect = true;
            else if ((flags & 32) != 0)
                _touchEffect = false;
            else
                _touchEffect = UIConfig.defaultScrollTouchEffect;
            if ((flags & 64) != 0)
                _bouncebackEffect = true;
            else if ((flags & 128) != 0)
                _bouncebackEffect = false;
            else
                _bouncebackEffect = UIConfig.defaultScrollBounceEffect;

            _xPerc = 0;
            _yPerc = 0;
            _aniFlag = true;
            _scrollBarVisible = true;
            _mouseWheelEnabled = true;
            _holdAreaPoint = new Vector2();
            _pageSize = Vector2.one;

            if (scrollBarDisplay == ScrollBarDisplayType.Default)
            {
                if (Application.isMobilePlatform)
                    scrollBarDisplay = ScrollBarDisplayType.Auto;
                else
                    scrollBarDisplay = UIConfig.defaultScrollBarDisplay;
            }

            if (scrollBarDisplay != ScrollBarDisplayType.Hidden)
            {
                if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Vertical)
                {
                    string res = string.IsNullOrEmpty(vtScrollBarRes) ? UIConfig.verticalScrollBar : vtScrollBarRes;
                    if (!string.IsNullOrEmpty(res))
                    {
                        _vtScrollBar = UIPackage.CreateObjectFromURL(res) as GScrollBar;
                        if (_vtScrollBar == null)
                            Debug.LogWarning("FairyGUI: cannot create scrollbar from " + res);
                        else
                        {
                            _vtScrollBar.SetScrollPane(this, true);
                            _container.AddChild(_vtScrollBar.displayObject);
                        }
                    }
                }
                if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Horizontal)
                {
                    string res = string.IsNullOrEmpty(hzScrollBarRes) ? UIConfig.horizontalScrollBar : hzScrollBarRes;
                    if (!string.IsNullOrEmpty(res))
                    {
                        _hzScrollBar = UIPackage.CreateObjectFromURL(res) as GScrollBar;
                        if (_hzScrollBar == null)
                            Debug.LogWarning("FairyGUI: cannot create scrollbar from " + res);
                        else
                        {
                            _hzScrollBar.SetScrollPane(this, false);
                            _container.AddChild(_hzScrollBar.displayObject);
                        }
                    }
                }

                _scrollBarDisplayAuto = scrollBarDisplay == ScrollBarDisplayType.Auto;
                if (_scrollBarDisplayAuto)
                {
                    if (_vtScrollBar != null)
                        _vtScrollBar.displayObject.visible = false;
                    if (_hzScrollBar != null)
                        _hzScrollBar.displayObject.visible = false;
                    _scrollBarVisible = false;

                    _container.onRollOver.Add(__rollOver);
                    _container.onRollOut.Add(__rollOut);
                }
            }
            else
                _mouseWheelEnabled = false;

            SetSize(owner.width, owner.height);

            _container.onMouseWheel.Add(__mouseWheel);
            _container.onTouchBegin.Add(__touchBegin);
        }
コード例 #4
0
        public ScrollPane(GComponent owner,
                          ScrollType scrollType,
                          Margin margin,
                          Margin scrollBarMargin,
                          ScrollBarDisplayType scrollBarDisplay,
                          int flags)
        {
            _throwTween = new ThrowTween();

            _owner     = owner;
            _container = _owner.rootContainer;

            _maskHolder = new Container();
            _container.AddChild(_maskHolder);

            _maskContentHolder   = _owner.container;
            _maskContentHolder.x = 0;
            _maskContentHolder.y = 0;
            _maskHolder.AddChild(_maskContentHolder);

            if (Stage.touchScreen)
            {
                _holdArea = 20;
            }
            else
            {
                _holdArea = 5;
            }
            _holdAreaPoint     = new Vector2();
            _margin            = margin;
            _scrollBarMargin   = scrollBarMargin;
            _bouncebackEffect  = UIConfig.defaultScrollBounceEffect;
            _touchEffect       = UIConfig.defaultScrollTouchEffect;
            _xPerc             = 0;
            _yPerc             = 0;
            _aniFlag           = true;
            _scrollBarVisible  = true;
            _scrollSpeed       = UIConfig.defaultScrollSpeed;
            _mouseWheelSpeed   = _scrollSpeed * 2;
            _displayOnLeft     = (flags & 1) != 0;
            _snapToItem        = (flags & 2) != 0;
            _displayInDemand   = (flags & 4) != 0;
            _scrollType        = scrollType;
            _mouseWheelEnabled = true;

            if (scrollBarDisplay == ScrollBarDisplayType.Default)
            {
                scrollBarDisplay = UIConfig.defaultScrollBarDisplay;
            }

            if (scrollBarDisplay != ScrollBarDisplayType.Hidden)
            {
                if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Vertical)
                {
                    if (UIConfig.verticalScrollBar != null)
                    {
                        _vtScrollBar = UIPackage.CreateObjectFromURL(UIConfig.verticalScrollBar) as GScrollBar;
                        if (_vtScrollBar == null)
                        {
                            Debug.LogError("FairyGUI: cannot create scrollbar from " + UIConfig.verticalScrollBar);
                        }
                        else
                        {
                            _vtScrollBar.SetScrollPane(this, true);
                            _container.AddChild(_vtScrollBar.displayObject);
                        }
                    }
                }
                if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Horizontal)
                {
                    if (UIConfig.horizontalScrollBar != null)
                    {
                        _hzScrollBar = UIPackage.CreateObjectFromURL(UIConfig.horizontalScrollBar) as GScrollBar;
                        if (_hzScrollBar == null)
                        {
                            Debug.LogError("FairyGUI: cannot create scrollbar from " + UIConfig.horizontalScrollBar);
                        }
                        else
                        {
                            _hzScrollBar.SetScrollPane(this, false);
                            _container.AddChild(_hzScrollBar.displayObject);
                        }
                    }
                }

                _scrollBarDisplayAuto = scrollBarDisplay == ScrollBarDisplayType.Auto;
                if (_scrollBarDisplayAuto)
                {
                    if (_vtScrollBar != null)
                    {
                        _vtScrollBar.displayObject.visible = false;
                    }
                    if (_hzScrollBar != null)
                    {
                        _hzScrollBar.displayObject.visible = false;
                    }
                    _scrollBarVisible = false;

                    _container.onRollOver.Add(__rollOver);
                    _container.onRollOut.Add(__rollOut);
                }
            }
            else
            {
                _mouseWheelEnabled = false;
            }

            if (_displayOnLeft && _vtScrollBar != null)
            {
                _maskHolder.x = Mathf.FloorToInt((_margin.left + _vtScrollBar.width) * GRoot.contentScaleFactor);
            }
            else
            {
                _maskHolder.x = Mathf.FloorToInt(_margin.left * GRoot.contentScaleFactor);
            }
            _maskHolder.y = Mathf.FloorToInt(_margin.top * GRoot.contentScaleFactor);

            SetSize(owner.width, owner.height);
            SetContentSize(owner.Bounds.width, owner.Bounds.height);

            _container.onMouseWheel.Add(__mouseWheel);
            _container.onMouseDown.Add(__mouseDown);
        }