private void AddScrollBar() { _scrollbar = new GameObject("scrollbar", this.GameObj); float scrollbarWidth = Math.Max(ScrollbarButtonsSize.X, ScrollbarCursorSize.X); Transform t = _scrollbar.AddComponent <Transform>(); t.RelativePos = new Vector3(0, Rect.H, 0); t.RelativeAngle = -MathF.PiOver2; _scrollComponent = new SkinnedScrollBar(); _scrollComponent.VisibilityGroup = this.VisibilityGroup; _scrollComponent.Skin = ScrollbarSkin; _scrollComponent.CursorSkin = ScrollbarCursorSkin; _scrollComponent.DecreaseButtonSkin = ScrollbarDecreaseButtonSkin; _scrollComponent.IncreaseButtonSkin = ScrollbarIncreaseButtonSkin; _scrollComponent.ButtonsSize = ScrollbarButtonsSize; _scrollComponent.CursorSize = ScrollbarCursorSize; //_scrollComponent.OnValueChanged = InternalScripts.GetScript<InternalScripts.CommandGridScrollbarValueChanged>(); _scrollComponent.Rect = Rect.AlignTopLeft(0, 0, scrollbarWidth, Rect.W); _scrollComponent.ScrollSpeed = 1; _scrollbar.AddComponent <SkinnedScrollBar>(_scrollComponent); Scene.Current.AddObject(_scrollbar); }
private void AddScrollBar() { _scrollbar = new GameObject("scrollbar", this.GameObj); float scrollbarWidth = Math.Max(ScrollbarButtonsSize.X, ScrollbarCursorSize.X); Transform t = _scrollbar.AddComponent <Transform>(); t.RelativePos = new Vector3(Rect.W - scrollbarWidth, 0, 0); t.RelativeAngle = 0; _scrollComponent = new SkinnedScrollBar(); _scrollComponent.VisibilityGroup = this.VisibilityGroup; _scrollComponent.Skin = ScrollbarSkin; _scrollComponent.CursorSkin = ScrollbarCursorSkin; _scrollComponent.DecreaseButtonSkin = ScrollbarDecreaseButtonSkin; _scrollComponent.IncreaseButtonSkin = ScrollbarIncreaseButtonSkin; _scrollComponent.ButtonsSize = ScrollbarButtonsSize; _scrollComponent.CursorSize = ScrollbarCursorSize; _scrollComponent.Rect = Rect.AlignTopLeft(0, 0, scrollbarWidth, Rect.H); _scrollComponent.ScrollSpeed = _scrollSpeed; _scrollbar.AddComponent <SkinnedScrollBar>(_scrollComponent); Scene.Current.AddObject(_scrollbar); }
public override void Execute(Duality.GameObject inSource, object inParameter) { SkinnedScrollBar scrollBar = inSource.Parent.GetComponent <Widget>() as SkinnedScrollBar; if (scrollBar != null) { scrollBar.Value = Math.Min(scrollBar.Maximum, scrollBar.Value + (int)inParameter); } }
public override void MouseMove(OpenTK.Input.MouseMoveEventArgs e) { base.MouseMove(e); if (_leftButtonDown) { float angle = -this.GameObj.Transform.Angle; _currentDelta += (e.YDelta * MathF.Cos(angle)) + (e.XDelta * MathF.Sin(angle)); if (_parent == null) { _parent = this.GameObj.Parent.GetComponent <SkinnedScrollBar>(); } int valueChange = (int)(_currentDelta / _parent.ValueDelta); if (valueChange != 0) { _parent.Value += valueChange; _currentDelta -= (valueChange * _parent.ValueDelta); } } }