private void AddListBox() { _listBox = new GameObject("listBox", this.GameObj); Transform t = _listBox.AddComponent <Transform>(); t.RelativePos = new Vector3(0, Rect.H, 0); t.RelativeAngle = 0; _listBoxComponent = new SkinnedListBox(); _listBoxComponent.VisibilityGroup = this.VisibilityGroup; _listBoxComponent.Skin = DropdownSkin; _listBoxComponent.HighlightSkin = HighlightSkin; _listBoxComponent.ScrollbarSkin = ScrollbarSkin; _listBoxComponent.ScrollbarCursorSkin = ScrollbarCursorSkin; _listBoxComponent.ScrollbarDecreaseButtonSkin = ScrollbarDecreaseButtonSkin; _listBoxComponent.ScrollbarIncreaseButtonSkin = ScrollbarIncreaseButtonSkin; _listBoxComponent.ScrollbarButtonsSize = ScrollbarButtonsSize; _listBoxComponent.ScrollbarCursorSize = ScrollbarCursorSize; _listBoxComponent.Rect = Rect.AlignTopLeft(0, 0, Rect.W, _dropDownHeight); _listBoxComponent.TextFont = TextFont; _listBox.AddComponent <SkinnedListBox>(_listBoxComponent); _listBox.Active = false; _listBoxComponent.SelectedItem = null; Scene.Current.AddObject(_listBox); }
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); }
protected override void OnUpdate(float inSecondsPast) { if (CanClose && _closeButton == null && _closeButtonSkin != null) { AddCloseButton(); } if (CanMaximize && _maximizeButton == null && _maximizedSize.X >= Rect.W && _maximizedSize.Y >= Rect.H && _maximizeButtonSkin != null) { AddMaximizeButton(); } if (CanMinimize && _minimizeButton == null && _minimizeButtonSkin != null) { AddMinimizeButton(); } if ((CanMaximize || CanMinimize) && _restoreButton == null && _restoreButtonSkin != null) { AddRestoreButton(); } if ((_dirtyFlags & DirtyFlags.Custom1) != DirtyFlags.None && _closeButton != null) { _closeButton.GetComponent <SkinnedWidget>().Skin = _closeButtonSkin; } if ((_dirtyFlags & DirtyFlags.Custom2) != DirtyFlags.None && _maximizeButton != null) { _maximizeButton.GetComponent <SkinnedWidget>().Skin = _maximizeButtonSkin; } if ((_dirtyFlags & DirtyFlags.Custom3) != DirtyFlags.None && _minimizeButton != null) { _minimizeButton.GetComponent <SkinnedWidget>().Skin = _minimizeButtonSkin; } if ((_dirtyFlags & DirtyFlags.Custom4) != DirtyFlags.None && _restoreButton != null) { _restoreButton.GetComponent <SkinnedWidget>().Skin = _restoreButtonSkin; } if ((_dirtyFlags & DirtyFlags.Custom5) != DirtyFlags.None && _closeButton != null) { _closeButton.GetComponent <SkinnedWidget>().Rect = Rect.AlignTopLeft(0, 0, _closeButtonSize.X, _closeButtonSize.Y); } if ((_dirtyFlags & DirtyFlags.Custom6) != DirtyFlags.None) { Rect newRect = Rect.AlignTopLeft(0, 0, _buttonsSize.X, _buttonsSize.Y); if (_maximizeButton != null) { _maximizeButton.GetComponent <SkinnedWidget>().Rect = newRect; } if (_minimizeButton != null) { _minimizeButton.GetComponent <SkinnedWidget>().Rect = newRect; } if (_restoreButton != null) { _restoreButton.GetComponent <SkinnedWidget>().Rect = newRect; } } base.OnUpdate(inSecondsPast); }
[Test] public void Alignment() { Assert.AreEqual(new Rect(-5, -5, 10, 10), Rect.AlignCenter(0, 0, 10, 10)); Assert.AreEqual(new Rect(0, -5, 10, 10), Rect.AlignLeft(0, 0, 10, 10)); Assert.AreEqual(new Rect(-10, -5, 10, 10), Rect.AlignRight(0, 0, 10, 10)); Assert.AreEqual(new Rect(-5, 0, 10, 10), Rect.AlignTop(0, 0, 10, 10)); Assert.AreEqual(new Rect(-5, -10, 10, 10), Rect.AlignBottom(0, 0, 10, 10)); Assert.AreEqual(new Rect(0, 0, 10, 10), Rect.AlignTopLeft(0, 0, 10, 10)); Assert.AreEqual(new Rect(-10, 0, 10, 10), Rect.AlignTopRight(0, 0, 10, 10)); Assert.AreEqual(new Rect(0, -10, 10, 10), Rect.AlignBottomLeft(0, 0, 10, 10)); Assert.AreEqual(new Rect(-10, -10, 10, 10), Rect.AlignBottomRight(0, 0, 10, 10)); }
private void AddGlyph() { _glyph = new GameObject("glyph", this.GameObj); Transform t = _glyph.AddComponent <Transform>(); t.RelativePos = new Vector3(0, 0, 0); t.RelativeAngle = 0; SkinnedPanel sp = new SkinnedPanel(); sp.VisibilityGroup = this.VisibilityGroup; sp.Skin = GlyphSkin; sp.Rect = Rect.AlignTopLeft(0, 0, GlyphSkin.Res.Size.X, GlyphSkin.Res.Size.Y); _glyph.AddComponent <SkinnedPanel>(sp); Scene.Current.AddObject(_glyph); }
private void AddHighlight() { _highlight = new GameObject("highlight", this.GameObj); Transform t = _highlight.AddComponent <Transform>(); t.RelativePos = new Vector3(Rect.W / 2, Rect.H / 2, DELTA_Z / 2); t.RelativeAngle = 0; _highlightPanel = new SkinnedPanel(); _highlightPanel.VisibilityGroup = this.VisibilityGroup; _highlightPanel.Skin = HighlightSkin; _highlightPanel.Rect = Rect.AlignTopLeft(0, 0, 0, 0); _highlightPanel.OverrideAutomaticZ = true; _highlight.AddComponent <SkinnedPanel>(_highlightPanel); Scene.Current.AddObject(_highlight); }
private void AddMinimizeButton() { _minimizeButton = new GameObject("minimizeButton", this.GameObj); Transform t = _minimizeButton.AddComponent <Transform>(); t.RelativePos = new Vector3(Rect.W - (ButtonsSize.X * 3), 0, DELTA_Z); t.RelativeAngle = 0; MinimizeButton mb = new MinimizeButton(); mb.VisibilityGroup = this.VisibilityGroup; mb.Skin = MinimizeButtonSkin; mb.Rect = Rect.AlignTopLeft(0, 0, ButtonsSize.X, ButtonsSize.Y); _minimizeButton.AddComponent <MinimizeButton>(mb); Scene.Current.AddObject(_minimizeButton); }
private void AddCloseButton() { _closeButton = new GameObject("closeButton", this.GameObj); Transform t = _closeButton.AddComponent <Transform>(); t.RelativePos = new Vector3(Rect.W - CloseButtonSize.X, 0, DELTA_Z); t.RelativeAngle = 0; CloseButton cb = new CloseButton(); cb.VisibilityGroup = this.VisibilityGroup; cb.Skin = CloseButtonSkin; cb.Rect = Rect.AlignTopLeft(0, 0, CloseButtonSize.X, CloseButtonSize.Y); _closeButton.AddComponent <CloseButton>(cb); Scene.Current.AddObject(_closeButton); }
private void AddRestoreButton() { _restoreButton = new GameObject("restoreButton", this.GameObj); Transform t = _restoreButton.AddComponent <Transform>(); t.RelativePos = new Vector3(Rect.W - (ButtonsSize.X * 4), 0, DELTA_Z); t.RelativeAngle = 0; RestoreButton rb = new RestoreButton(); rb.VisibilityGroup = this.VisibilityGroup; rb.Skin = RestoreButtonSkin; rb.Rect = Rect.AlignTopLeft(0, 0, ButtonsSize.X, ButtonsSize.Y); _restoreButton.Active = false; _restoreButton.AddComponent <RestoreButton>(rb); Scene.Current.AddObject(_restoreButton); }