public void Dispose() { _container.RemoveEventListenerObsolete(MouseEvent.MOUSE_WHEEL, __mouseWheel); _container.RemoveEventListenerObsolete(MouseEvent.MOUSE_DOWN, __mouseDown); _container.RemoveChildren(); _maskContent.x = 0; _maskContent.y = 0; _container.AddChild(_maskContent); }
public ScrollPane(GComponent owner, ScrollType scrollType, Margin margin, int scrollSpeed, ScrollBarDisplayType scrollBarDisplay) { if (_easeTypeFunc == null) { _easeTypeFunc = Ease.CubeOut; } _owner = owner; _container = _owner.rootContainer; _maskContent = _owner.container; _maskContent.x = 0; _maskContent.y = 0; _maskHolder = new Sprite(); _container.AddChild(_maskHolder); _maskContentHolder = new Sprite(); _maskContentHolder.AddChild(_maskContent); _maskHolder.AddChild(_maskContentHolder); if (GRoot.touchScreen) { _holdArea = 20; } else { _holdArea = 10; } _holdAreaPoint = Vector2.zero; _margin = new Margin(); _bouncebackEffect = UIConfig.defaultScrollBounceEffect; _touchEffect = UIConfig.defaultScrollTouchEffect; _xPerc = 0; _yPerc = 0; _aniFlag = true; _scrollType = scrollType; _scrollSpeed = scrollSpeed; if (_scrollSpeed == 0) { _scrollSpeed = UIConfig.defaultScrollSpeed; } _mouseWheelSpeed = _scrollSpeed * 2; 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) { throw new Exception("cannot create scrollbar from " + UIConfig.verticalScrollBar); } _vtScrollBar.SetScrollPane(this, true); owner.rootContainer.AddChild(_vtScrollBar.displayObject); } } if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Horizontal) { if (UIConfig.horizontalScrollBar != null) { _hzScrollBar = UIPackage.CreateObjectFromURL(UIConfig.horizontalScrollBar) as GScrollBar; if (_hzScrollBar == null) { throw new Exception("cannot create scrollbar from " + UIConfig.horizontalScrollBar); } _hzScrollBar.SetScrollPane(this, false); owner.rootContainer.AddChild(_hzScrollBar.displayObject); } } _scrollBarDisplayAuto = scrollBarDisplay == ScrollBarDisplayType.Auto; if (_scrollBarDisplayAuto) { if (_vtScrollBar != null) { _vtScrollBar.displayObject.visible = false; } if (_hzScrollBar != null) { _hzScrollBar.displayObject.visible = false; } owner.rootContainer.AddEventListenerObsolete(MouseEvent.ROLL_OVER, __rollOver); owner.rootContainer.AddEventListenerObsolete(MouseEvent.ROLL_OUT, __rollOut); } } _margin.left = margin.left; _margin.top = margin.top; _margin.right = margin.right; _margin.bottom = margin.bottom; _maskHolder.x = _margin.left; _maskHolder.y = _margin.top; SetSize(owner.width, owner.height); SetContentSize((int)owner.bounds.width, (int)owner.bounds.height); _container.AddEventListenerObsolete(MouseEvent.MOUSE_WHEEL, __mouseWheel); _container.AddEventListenerObsolete(MouseEvent.MOUSE_DOWN, __mouseDown); // onScroll = new EventListener(this, "onScroll"); }