protected void SetupOverflowAndScroll(OverflowType overflow, Margin scrollBarMargin, ScrollType scroll, ScrollBarDisplayType scrollBarDisplay, int flags) { if (overflow == OverflowType.Hidden) { container = new Container(); rootContainer.AddChild(container); UpdateMask(); container.SetXY(_margin.left * GRoot.contentScaleFactor, _margin.top * GRoot.contentScaleFactor); } else if (overflow == OverflowType.Scroll) { container = new Container(); rootContainer.AddChild(container); scrollPane = new ScrollPane(this, scroll, _margin, scrollBarMargin, scrollBarDisplay, flags); } else if (_margin.left != 0 || _margin.top != 0) { container = new Container(); rootContainer.AddChild(container); container.SetXY(_margin.left * GRoot.contentScaleFactor, _margin.top * GRoot.contentScaleFactor); } SetBoundsChangedFlag(); }
protected void SetupScroll(Margin scrollBarMargin, ScrollType scroll, ScrollBarDisplayType scrollBarDisplay, int flags, String vtScrollBarRes, String hzScrollBarRes) { container = new Container(); rootContainer.AddChild(container); scrollPane = new ScrollPane(this, scroll, scrollBarMargin, scrollBarDisplay, flags, vtScrollBarRes, hzScrollBarRes); UpdateClipRect(); }
protected void SetupScroll(Margin scrollBarMargin, ScrollType scroll, ScrollBarDisplayType scrollBarDisplay, int flags, string vtScrollBarRes, string hzScrollBarRes, string headerRes, string footerRes) { if (rootContainer == container) { container = new Container(); rootContainer.AddChild(container); } scrollPane = new ScrollPane(this, scroll, scrollBarMargin, scrollBarDisplay, flags, vtScrollBarRes, hzScrollBarRes, headerRes, footerRes); }
public void SetupOverflowAndScroll(OverflowType overflow, Margin margin, ScrollType scroll, int scrollSpeed, ScrollBarDisplayType scrollBarDisplay) { _margin = margin; if (overflow == OverflowType.Hidden) { container.clipRect = new Rect(0, 0, _width * GRoot.contentScaleFactor, _height * GRoot.contentScaleFactor); if (_scrollPane != null) { _scrollPane.Dispose(); _scrollPane = null; } container.x = margin.left * GRoot.contentScaleFactor; container.y = margin.top * GRoot.contentScaleFactor; } else if (overflow == OverflowType.Scroll) { container.clipRect = null; if (_scrollPane == null) { _scrollPane = new ScrollPane(this, scroll, margin, scrollSpeed, scrollBarDisplay); } } else { container.clipRect = null; if (_scrollPane != null) { _scrollPane.Dispose(); _scrollPane = null; } container.x = margin.left * GRoot.contentScaleFactor; container.y = margin.top * GRoot.contentScaleFactor; } SetBoundsChangedFlag(); }
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); }
private void Load() { int cnt = this._items.Count; for (int i = 0; i < cnt; i++) { ConfigValue value = this._items[i]; if (!value.valid) { continue; } switch (( ConfigKey )i) { case ConfigKey.UseCanvasSortingOrder: useCanvasSortingOrder = value.b; break; case ConfigKey.ButtonSound: if (Application.isPlaying) { buttonSound = UIPackage.GetItemAssetByURL(value.s) as AudioClip; } break; case ConfigKey.ButtonSoundVolumeScale: buttonSoundVolumeScale = value.f; break; case ConfigKey.DefaultComboBoxVisibleItemCount: defaultComboBoxVisibleItemCount = value.i; break; case ConfigKey.DefaultFont: defaultFont = value.s; break; case ConfigKey.DefaultMovementType: defaultMovementType = (ScrollView.MovementType)value.i; break; case ConfigKey.DefaultScrollBarDisplay: defaultScrollBarDisplay = ( ScrollBarDisplayType )value.i; break; case ConfigKey.DefaultScrollBounceEffect: defaultScrollBounceEffect = value.b; break; case ConfigKey.DefaultScrollElasticity: defaultScrollElasticity = value.i; break; case ConfigKey.DefaultScrollDecelerationRate: defaultScrollDecelerationRate = value.i; break; case ConfigKey.DefaultScrollInertia: defaultScrollInertia = value.b; break; case ConfigKey.DefaultScrollSensitivity: defaultScrollSensitivity = value.i; break; case ConfigKey.GlobalModalWaiting: globalModalWaiting = value.s; break; case ConfigKey.HorizontalScrollBar: horizontalScrollBar = value.s; break; case ConfigKey.LoaderErrorSign: loaderErrorSign = value.s; break; case ConfigKey.ModalLayerColor: modalLayerColor = value.c; break; case ConfigKey.PopupMenu: popupMenu = value.s; break; case ConfigKey.PopupMenuSeperator: popupMenuSeperator = value.s; break; case ConfigKey.TooltipsWin: tooltipsWin = value.s; break; case ConfigKey.VerticalScrollBar: verticalScrollBar = value.s; break; case ConfigKey.WindowModalWaiting: windowModalWaiting = value.s; break; case ConfigKey.PixelDragThreshold: pixelDragThreshold = value.f; break; } } }
public void Load() { int cnt = Items.Count; for (int i = 0; i < cnt; i++) { ConfigValue value = Items[i]; if (!value.valid) { continue; } switch ((UIConfig.ConfigKey)i) { case ConfigKey.ButtonSound: if (Application.isPlaying) { UIConfig.buttonSound = UIPackage.GetItemAssetByURL(value.s) as NAudioClip; } break; case ConfigKey.ButtonSoundVolumeScale: UIConfig.buttonSoundVolumeScale = value.f; break; case ConfigKey.ClickDragSensitivity: UIConfig.clickDragSensitivity = value.i; break; case ConfigKey.DefaultComboBoxVisibleItemCount: UIConfig.defaultComboBoxVisibleItemCount = value.i; break; case ConfigKey.DefaultFont: UIConfig.defaultFont = value.s; break; case ConfigKey.DefaultScrollBarDisplay: UIConfig.defaultScrollBarDisplay = (ScrollBarDisplayType)value.i; break; case ConfigKey.DefaultScrollBounceEffect: UIConfig.defaultScrollBounceEffect = value.b; break; case ConfigKey.DefaultScrollStep: UIConfig.defaultScrollStep = value.i; break; case ConfigKey.DefaultScrollTouchEffect: UIConfig.defaultScrollTouchEffect = value.b; break; case ConfigKey.GlobalModalWaiting: UIConfig.globalModalWaiting = value.s; break; case ConfigKey.HorizontalScrollBar: UIConfig.horizontalScrollBar = value.s; break; case ConfigKey.LoaderErrorSign: UIConfig.loaderErrorSign = value.s; break; case ConfigKey.ModalLayerColor: UIConfig.modalLayerColor = value.c; break; case ConfigKey.PopupMenu: UIConfig.popupMenu = value.s; break; case ConfigKey.PopupMenu_seperator: UIConfig.popupMenu_seperator = value.s; break; case ConfigKey.TooltipsWin: UIConfig.tooltipsWin = value.s; break; case ConfigKey.TouchDragSensitivity: UIConfig.touchDragSensitivity = value.i; break; case ConfigKey.TouchScrollSensitivity: UIConfig.touchScrollSensitivity = value.i; break; case ConfigKey.VerticalScrollBar: UIConfig.verticalScrollBar = value.s; break; case ConfigKey.WindowModalWaiting: UIConfig.windowModalWaiting = value.s; break; case ConfigKey.AllowSoftnessOnTopOrLeftSide: UIConfig.allowSoftnessOnTopOrLeftSide = value.b; break; case ConfigKey.InputCaretSize: UIConfig.inputCaretSize = value.i; break; case ConfigKey.InputHighlightColor: UIConfig.inputHighlightColor = value.c; break; case ConfigKey.DepthSupportForPaintingMode: UIConfig.depthSupportForPaintingMode = value.b; break; case ConfigKey.EnhancedTextOutlineEffect: UIConfig.enhancedTextOutlineEffect = value.b; break; case ConfigKey.Branch: UIPackage.branch = value.s; break; } } }
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); }
public void Load() { int cnt = Items.Count; for (int i = 0; i < cnt; i++) { ConfigValue value = Items[i]; if (!value.valid) { continue; } switch ((UIConfig.ConfigKey)i) { case ConfigKey.ButtonSound: //if (Application.isPlaying) // UIConfig.buttonSound = UIPackage.GetItemAssetByURL(value.s) as AudioClip; break; case ConfigKey.ButtonSoundVolumeScale: UIConfig.buttonSoundVolumeScale = value.f; break; case ConfigKey.ClickDragSensitivity: UIConfig.clickDragSensitivity = value.i; break; case ConfigKey.DefaultComboBoxVisibleItemCount: UIConfig.defaultComboBoxVisibleItemCount = value.i; break; case ConfigKey.DefaultFont: UIConfig.defaultFont = value.s; break; case ConfigKey.DefaultScrollBarDisplay: UIConfig.defaultScrollBarDisplay = (ScrollBarDisplayType)value.i; break; case ConfigKey.DefaultScrollBounceEffect: UIConfig.defaultScrollBounceEffect = value.b; break; case ConfigKey.DefaultScrollSpeed: UIConfig.defaultScrollSpeed = value.i; break; case ConfigKey.DefaultScrollTouchEffect: UIConfig.defaultScrollTouchEffect = value.b; break; case ConfigKey.GlobalModalWaiting: UIConfig.globalModalWaiting = value.s; break; case ConfigKey.HorizontalScrollBar: UIConfig.horizontalScrollBar = value.s; break; case ConfigKey.LoaderErrorSign: UIConfig.loaderErrorSign = value.s; break; case ConfigKey.ModalLayerColor: //UIConfig.modalLayerColor = value.c; break; case ConfigKey.PopupMenu: UIConfig.popupMenu = value.s; break; case ConfigKey.PopupMenu_seperator: UIConfig.popupMenu_seperator = value.s; break; case ConfigKey.RenderingTextBrighterOnDesktop: UIConfig.renderingTextBrighterOnDesktop = value.b; break; case ConfigKey.TooltipsWin: UIConfig.tooltipsWin = value.s; break; case ConfigKey.TouchDragSensitivity: UIConfig.touchDragSensitivity = value.i; break; case ConfigKey.TouchScrollSensitivity: UIConfig.touchScrollSensitivity = value.i; break; case ConfigKey.VerticalScrollBar: UIConfig.verticalScrollBar = value.s; break; case ConfigKey.WindowModalWaiting: UIConfig.windowModalWaiting = value.s; break; case ConfigKey.AllowSoftnessOnTopOrLeftSide: UIConfig.allowSoftnessOnTopOrLeftSide = value.b; break; } } }
protected void SetupScroll(Margin scrollBarMargin, ScrollType scroll, ScrollBarDisplayType scrollBarDisplay, int flags, String vtScrollBarRes, String hzScrollBarRes) { container = new Container(); rootContainer.AddChild(container); scrollPane = new ScrollPane(this, scroll, scrollBarMargin, scrollBarDisplay, flags, vtScrollBarRes, hzScrollBarRes); UpdateClipRect(); SetBoundsChangedFlag(); }
public void Load() { int cnt = Items.Count; for (int i = 0; i < cnt; i++) { ConfigValue value = Items[i]; if (!value.valid) continue; switch ((UIConfig.ConfigKey)i) { case ConfigKey.ButtonSound: if (Application.isPlaying) UIConfig.buttonSound = UIPackage.GetItemAssetByURL(value.s) as AudioClip; break; case ConfigKey.ButtonSoundVolumeScale: UIConfig.buttonSoundVolumeScale = value.f; break; case ConfigKey.ClickDragSensitivity: UIConfig.clickDragSensitivity = value.i; break; case ConfigKey.DefaultComboBoxVisibleItemCount: UIConfig.defaultComboBoxVisibleItemCount = value.i; break; case ConfigKey.DefaultFont: UIConfig.defaultFont = value.s; break; case ConfigKey.DefaultScrollBarDisplay: UIConfig.defaultScrollBarDisplay = (ScrollBarDisplayType)value.i; break; case ConfigKey.DefaultScrollBounceEffect: UIConfig.defaultScrollBounceEffect = value.b; break; case ConfigKey.DefaultScrollSpeed: UIConfig.defaultScrollSpeed = value.i; break; case ConfigKey.DefaultScrollTouchEffect: UIConfig.defaultScrollTouchEffect = value.b; break; case ConfigKey.GlobalModalWaiting: UIConfig.globalModalWaiting = value.s; break; case ConfigKey.HorizontalScrollBar: UIConfig.horizontalScrollBar = value.s; break; case ConfigKey.LoaderErrorSign: UIConfig.loaderErrorSign = value.s; break; case ConfigKey.ModalLayerColor: UIConfig.modalLayerColor = value.c; break; case ConfigKey.PopupMenu: UIConfig.popupMenu = value.s; break; case ConfigKey.PopupMenu_seperator: UIConfig.popupMenu_seperator = value.s; break; case ConfigKey.RenderingTextBrighterOnDesktop: UIConfig.renderingTextBrighterOnDesktop = value.b; break; case ConfigKey.TooltipsWin: UIConfig.tooltipsWin = value.s; break; case ConfigKey.TouchDragSensitivity: UIConfig.touchDragSensitivity = value.i; break; case ConfigKey.TouchScrollSensitivity: UIConfig.touchScrollSensitivity = value.i; break; case ConfigKey.VerticalScrollBar: UIConfig.verticalScrollBar = value.s; break; case ConfigKey.WindowModalWaiting: UIConfig.windowModalWaiting = value.s; break; case ConfigKey.AllowSoftnessOnTopOrLeftSide: UIConfig.allowSoftnessOnTopOrLeftSide = value.b; break; case ConfigKey.InputCaretSize: UIConfig.inputCaretSize = value.i; break; case ConfigKey.InputHighlightColor: UIConfig.inputHighlightColor = value.c; break; } } }
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); }
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"); }
protected void SetupScroll(Margin scrollBarMargin, ScrollType scroll, ScrollBarDisplayType scrollBarDisplay, int flags, String vtScrollBarRes, String hzScrollBarRes) { if (rootContainer == container) { container = new Container(); rootContainer.AddChild(container); } scrollPane = new ScrollPane(this, scroll, scrollBarMargin, scrollBarDisplay, flags, vtScrollBarRes, hzScrollBarRes); }