From 0809cd0218a9aaaa37d39a805bedb63f3e93e05e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 29 Oct 2021 23:33:15 +0200 Subject: [PATCH] Added style properties for a lot of hardcoded default element styles --- CHANGELOG.md | 1 + Demos/UiDemo.cs | 8 ++--- MLEM.Ui/Elements/Button.cs | 5 ++- MLEM.Ui/Elements/Checkbox.cs | 3 +- MLEM.Ui/Elements/Dropdown.cs | 3 +- MLEM.Ui/Elements/ElementHelper.cs | 23 ++++++------ MLEM.Ui/Elements/Panel.cs | 38 ++++++++++++++------ MLEM.Ui/Elements/ScrollBar.cs | 8 +++-- MLEM.Ui/Elements/TextField.cs | 8 +++-- MLEM.Ui/Elements/Tooltip.cs | 19 +++++----- MLEM.Ui/Style/StyleProp.cs | 8 +++-- MLEM.Ui/Style/UiStyle.cs | 58 ++++++++++++++++++++++++++----- MLEM.Ui/Style/UntexturedStyle.cs | 9 ----- Sandbox/GameImpl.cs | 2 +- Tests/UiTests.cs | 2 +- 15 files changed, 125 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b899d4d..588e53c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Improvements - Cache TokenizedString inner offsets for non-Left text alignments to improve performance - Exposed the epsilon value used by Element calculations - Made Image ScaleToImage take ui scale into account +- Added style properties for a lot of hardcoded default element styles Fixes - Fixed VerticalSpace height parameter being an integer diff --git a/Demos/UiDemo.cs b/Demos/UiDemo.cs index ff0373f..bc85457 100644 --- a/Demos/UiDemo.cs +++ b/Demos/UiDemo.cs @@ -63,7 +63,7 @@ namespace Demos { this.UiSystem.AutoScaleWithScreen = true; // create the root panel that all the other components sit on and add it to the ui system - this.root = new Panel(Anchor.Center, new Vector2(80, 100), Vector2.Zero, false, true, new Point(5, 10)); + this.root = new Panel(Anchor.Center, new Vector2(80, 100), Vector2.Zero, false, true); this.root.ScrollBar.SmoothScrolling = true; // add the root to the demos' ui this.UiRoot.AddChild(this.root); @@ -136,16 +136,16 @@ namespace Demos { this.root.AddChild(new RadioButton(Anchor.AutoLeft, new Vector2(1, 10), "Radio button 1!")); this.root.AddChild(new RadioButton(Anchor.AutoLeft, new Vector2(1, 10), "Radio button 2!") {PositionOffset = new Vector2(0, 1)}); - var tooltip = new Tooltip(50, "I am tooltip!") {IsHidden = true}; + var tooltip = new Tooltip("I am tooltip!") {IsHidden = true}; this.UiSystem.Add("TestTooltip", tooltip); this.root.AddChild(new VerticalSpace(3)); this.root.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 10), "Toggle Mouse Tooltip") { OnPressed = element => tooltip.IsHidden = !tooltip.IsHidden }); var delayed = this.root.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 10), "Delayed Tooltip") {PositionOffset = new Vector2(0, 1)}); - delayed.AddTooltip(50, "This tooltip appears with a half second delay!").Delay = TimeSpan.FromSeconds(0.5); + delayed.AddTooltip("This tooltip appears with a half second delay!").Delay = TimeSpan.FromSeconds(0.5); var condition = this.root.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 10), "Hold Ctrl for Tooltip") {PositionOffset = new Vector2(0, 1)}); - condition.AddTooltip(50, p => this.InputHandler.IsModifierKeyDown(ModifierKey.Control) ? "This tooltip only appears when holding control!" : string.Empty); + condition.AddTooltip(p => this.InputHandler.IsModifierKeyDown(ModifierKey.Control) ? "This tooltip only appears when holding control!" : string.Empty); var slider = new Slider(Anchor.AutoLeft, new Vector2(1, 10), 5, 1) { StepPerScroll = 0.01F diff --git a/MLEM.Ui/Elements/Button.cs b/MLEM.Ui/Elements/Button.cs index 18c5871..1b2cf0e 100644 --- a/MLEM.Ui/Elements/Button.cs +++ b/MLEM.Ui/Elements/Button.cs @@ -79,14 +79,13 @@ namespace MLEM.Ui.Elements { /// The button's size /// The text that should be displayed on the button /// The text that should be displayed in a when hovering over this button - /// The width of this button's , or 50 by default - public Button(Anchor anchor, Vector2 size, string text = null, string tooltipText = null, float tooltipWidth = 50) : base(anchor, size) { + public Button(Anchor anchor, Vector2 size, string text = null, string tooltipText = null) : base(anchor, size) { if (text != null) { this.Text = new Paragraph(Anchor.Center, 1, text, true) {Padding = new Vector2(1)}; this.AddChild(this.Text); } if (tooltipText != null) - this.Tooltip = this.AddTooltip(tooltipWidth, tooltipText); + this.Tooltip = this.AddTooltip(tooltipText); } /// diff --git a/MLEM.Ui/Elements/Checkbox.cs b/MLEM.Ui/Elements/Checkbox.cs index 35f6687..e214120 100644 --- a/MLEM.Ui/Elements/Checkbox.cs +++ b/MLEM.Ui/Elements/Checkbox.cs @@ -36,7 +36,7 @@ namespace MLEM.Ui.Elements { /// /// The width of the space between this checkbox and its /// - public float TextOffsetX = 2; + public StyleProp TextOffsetX; private bool checced; /// @@ -106,6 +106,7 @@ namespace MLEM.Ui.Elements { this.HoveredTexture.SetFromStyle(style.CheckboxHoveredTexture); this.HoveredColor.SetFromStyle(style.CheckboxHoveredColor); this.Checkmark.SetFromStyle(style.CheckboxCheckmark); + this.TextOffsetX.SetFromStyle(style.CheckboxTextOffsetX); } /// diff --git a/MLEM.Ui/Elements/Dropdown.cs b/MLEM.Ui/Elements/Dropdown.cs index 9625577..7b85120 100644 --- a/MLEM.Ui/Elements/Dropdown.cs +++ b/MLEM.Ui/Elements/Dropdown.cs @@ -35,8 +35,7 @@ namespace MLEM.Ui.Elements { /// The dropdown button's size /// The text displayed on the dropdown button /// The text displayed as a tooltip when hovering over the dropdown button - /// The width of the dropdown button's tooltip - public Dropdown(Anchor anchor, Vector2 size, string text = null, string tooltipText = null, float tooltipWidth = 50) : base(anchor, size, text, tooltipText, tooltipWidth) { + public Dropdown(Anchor anchor, Vector2 size, string text = null, string tooltipText = null) : base(anchor, size, text, tooltipText) { this.Panel = this.AddChild(new Panel(Anchor.TopCenter, size, Vector2.Zero, true) { IsHidden = true }); diff --git a/MLEM.Ui/Elements/ElementHelper.cs b/MLEM.Ui/Elements/ElementHelper.cs index b0d76cb..8a50c6c 100644 --- a/MLEM.Ui/Elements/ElementHelper.cs +++ b/MLEM.Ui/Elements/ElementHelper.cs @@ -18,11 +18,10 @@ namespace MLEM.Ui.Elements { /// The texture of the image to render on the button /// The text to display on the button /// The text of the button's tooltip - /// The width of the button's tooltip /// The of the button's image /// An image button - public static Button ImageButton(Anchor anchor, Vector2 size, TextureRegion texture, string text = null, string tooltipText = null, float tooltipWidth = 50, float imagePadding = 2) { - var button = new Button(anchor, size, text, tooltipText, tooltipWidth); + public static Button ImageButton(Anchor anchor, Vector2 size, TextureRegion texture, string text = null, string tooltipText = null, float imagePadding = 2) { + var button = new Button(anchor, size, text, tooltipText); var image = new Image(Anchor.CenterLeft, Vector2.One, texture) {Padding = new Vector2(imagePadding)}; button.OnAreaUpdated += e => image.Size = new Vector2(e.Area.Height, e.Area.Height) / e.Scale; button.AddChild(image, 0); @@ -172,25 +171,23 @@ namespace MLEM.Ui.Elements { public static class ElementExtensions { /// - /// Adds a new to the given element using the constructor + /// Adds a new to the given element using the constructor /// - /// - /// The width of the tooltip + /// The element to add the tooltip to /// The text to display on the tooltip /// The created tooltip instance - public static Tooltip AddTooltip(this Element element, float width, Paragraph.TextCallback textCallback) { - return new Tooltip(width, textCallback, element); + public static Tooltip AddTooltip(this Element element, Paragraph.TextCallback textCallback) { + return new Tooltip(textCallback, element); } /// - /// Adds a new to the given element using the constructor + /// Adds a new to the given element using the constructor /// - /// - /// The width of the tooltip + /// The element to add the tooltip to /// The text to display on the tooltip /// The created tooltip instance - public static Tooltip AddTooltip(this Element element, float width, string text) { - return new Tooltip(width, text, element); + public static Tooltip AddTooltip(this Element element, string text) { + return new Tooltip(text, element); } } diff --git a/MLEM.Ui/Elements/Panel.cs b/MLEM.Ui/Elements/Panel.cs index 666268a..01d416f 100644 --- a/MLEM.Ui/Elements/Panel.cs +++ b/MLEM.Ui/Elements/Panel.cs @@ -27,8 +27,18 @@ namespace MLEM.Ui.Elements { /// public StyleProp DrawColor; /// + /// The amount that the scrollable area is moved per single movement of the scroll wheel + /// This value is passed to the 's + /// + public StyleProp StepPerScroll; + /// + /// The size that the 's scroller should have, in pixels + /// + public StyleProp ScrollerSize; + /// /// The scroll bar that this panel contains. /// This is only nonnull if is true. + /// Note that some scroll bar styling is controlled by this panel, namely and . /// public readonly ScrollBar ScrollBar; private readonly bool scrollOverflow; @@ -44,29 +54,22 @@ namespace MLEM.Ui.Elements { /// The panel's offset from its anchor point /// Whether the panel should automatically calculate its height based on its children's size /// Whether this panel should automatically add a scroll bar to scroll towards elements that are beyond the area this panel covers - /// The size of the 's scroller /// Whether the scroll bar should be hidden automatically if the panel does not contain enough children to allow for scrolling - public Panel(Anchor anchor, Vector2 size, Vector2 positionOffset, bool setHeightBasedOnChildren = false, bool scrollOverflow = false, Point? scrollerSize = null, bool autoHideScrollbar = true) : base(anchor, size) { + public Panel(Anchor anchor, Vector2 size, Vector2 positionOffset, bool setHeightBasedOnChildren = false, bool scrollOverflow = false, bool autoHideScrollbar = true) : base(anchor, size) { this.PositionOffset = positionOffset; this.SetHeightBasedOnChildren = setHeightBasedOnChildren; this.scrollOverflow = scrollOverflow; - this.ChildPadding = new Vector2(5); this.CanBeSelected = false; if (scrollOverflow) { - var (w, h) = scrollerSize ?? Point.Zero; - this.ScrollBar = new ScrollBar(Anchor.TopRight, new Vector2(w, 1), h, 0) { - StepPerScroll = 10, + this.ScrollBar = new ScrollBar(Anchor.TopRight, Vector2.Zero, 0, 0) { OnValueChanged = (element, value) => this.ScrollChildren(), CanAutoAnchorsAttach = false, AutoHideWhenEmpty = autoHideScrollbar, IsHidden = autoHideScrollbar }; - - // modify the padding so that the scroll bar isn't over top of something else - this.ScrollBar.PositionOffset -= new Vector2(w + 1, 0); if (autoHideScrollbar) - this.ScrollBar.OnAutoHide += e => this.ChildPadding += new Padding(0, w, 0, 0) * (e.IsHidden ? -1 : 1); + this.ScrollBar.OnAutoHide += e => this.ChildPadding += new Padding(0, this.ScrollerSize.Value.X, 0, 0) * (e.IsHidden ? -1 : 1); // handle automatic element selection, the scroller needs to scroll to the right location this.OnSelectedElementChanged += (element, otherElement) => { @@ -99,6 +102,7 @@ namespace MLEM.Ui.Elements { this.ScrollChildren(); this.ScrollSetup(); + this.SetScrollBarStyle(); } private void ScrollChildren() { @@ -207,6 +211,11 @@ namespace MLEM.Ui.Elements { protected override void InitStyle(UiStyle style) { base.InitStyle(style); this.Texture.SetFromStyle(style.PanelTexture); + this.StepPerScroll.SetFromStyle(style.PanelStepPerScroll); + this.ScrollerSize.SetFromStyle(style.PanelScrollerSize); + if (this.ChildPadding == default) + this.ChildPadding = style.PanelChildPadding; + this.SetScrollBarStyle(); } /// @@ -245,5 +254,14 @@ namespace MLEM.Ui.Elements { base.Dispose(); } + private void SetScrollBarStyle() { + if (this.ScrollBar == null) + return; + this.ScrollBar.StepPerScroll = this.StepPerScroll; + this.ScrollBar.Size = new Vector2(this.ScrollerSize.Value.X, 1); + this.ScrollBar.ScrollerSize = this.ScrollerSize; + this.ScrollBar.PositionOffset = new Vector2(-this.ScrollerSize.Value.X - 1, 0); + } + } } \ No newline at end of file diff --git a/MLEM.Ui/Elements/ScrollBar.cs b/MLEM.Ui/Elements/ScrollBar.cs index fd7a048..72778c7 100644 --- a/MLEM.Ui/Elements/ScrollBar.cs +++ b/MLEM.Ui/Elements/ScrollBar.cs @@ -101,11 +101,11 @@ namespace MLEM.Ui.Elements { /// Whether smooth scrolling should be enabled for this scroll bar. /// Smooth scrolling causes the to change gradually rather than instantly when scrolling. /// - public bool SmoothScrolling; + public StyleProp SmoothScrolling; /// /// The factor with which happens. /// - public float SmoothScrollFactor = 0.75F; + public StyleProp SmoothScrollFactor; static ScrollBar() { InputHandler.EnableGestures(GestureType.HorizontalDrag, GestureType.VerticalDrag); @@ -180,7 +180,7 @@ namespace MLEM.Ui.Elements { if (this.SmoothScrolling && this.scrollAdded != 0) { this.scrollAdded *= this.SmoothScrollFactor; - if (Math.Abs(this.scrollAdded) <= 0.1F) + if (Math.Abs(this.scrollAdded) <= Epsilon) this.scrollAdded = 0; this.OnValueChanged?.Invoke(this, this.CurrentValue); } @@ -216,6 +216,8 @@ namespace MLEM.Ui.Elements { base.InitStyle(style); this.Background.SetFromStyle(style.ScrollBarBackground); this.ScrollerTexture.SetFromStyle(style.ScrollBarScrollerTexture); + this.SmoothScrolling.SetFromStyle(style.ScrollBarSmoothScrolling); + this.SmoothScrollFactor.SetFromStyle(style.ScrollBarSmoothScrollFactor); } /// diff --git a/MLEM.Ui/Elements/TextField.cs b/MLEM.Ui/Elements/TextField.cs index b9a4128..98672e8 100644 --- a/MLEM.Ui/Elements/TextField.cs +++ b/MLEM.Ui/Elements/TextField.cs @@ -113,11 +113,11 @@ namespace MLEM.Ui.Elements { /// /// The x position that text should start rendering at, based on the x position of this text field. /// - public float TextOffsetX = 4; + public StyleProp TextOffsetX; /// - /// The width that the caret should render with. + /// The width that the caret should render with, in pixels /// - public float CaretWidth = 0.5F; + public StyleProp CaretWidth; /// /// The rule used for text input. /// Rules allow only certain characters to be allowed inside of a text field. @@ -399,6 +399,8 @@ namespace MLEM.Ui.Elements { this.Texture.SetFromStyle(style.TextFieldTexture); this.HoveredTexture.SetFromStyle(style.TextFieldHoveredTexture); this.HoveredColor.SetFromStyle(style.TextFieldHoveredColor); + this.TextOffsetX.SetFromStyle(style.TextFieldTextOffsetX); + this.CaretWidth.SetFromStyle(style.TextFieldCaretWidth); } private bool FilterText(ref string text, bool removeMismatching) { diff --git a/MLEM.Ui/Elements/Tooltip.cs b/MLEM.Ui/Elements/Tooltip.cs index 3f26adc..83c3c20 100644 --- a/MLEM.Ui/Elements/Tooltip.cs +++ b/MLEM.Ui/Elements/Tooltip.cs @@ -29,25 +29,23 @@ namespace MLEM.Ui.Elements { /// /// Creates a new tooltip with the given settings /// - /// The width of the tooltip /// The text to display on the tooltip /// The element that should automatically cause the tooltip to appear and disappear when hovered and not hovered, respectively - public Tooltip(float width, string text = null, Element elementToHover = null) : + public Tooltip(string text = null, Element elementToHover = null) : base(Anchor.TopLeft, Vector2.One, Vector2.Zero) { if (text != null) - this.Paragraph = this.AddChild(new Paragraph(Anchor.TopLeft, width, text)); + this.Paragraph = this.AddChild(new Paragraph(Anchor.TopLeft, 0, text)); this.Init(elementToHover); } /// /// Creates a new tooltip with the given settings /// - /// The width of the tooltip /// The text to display on the tooltip /// The element that should automatically cause the tooltip to appear and disappear when hovered and not hovered, respectively - public Tooltip(float width, Paragraph.TextCallback textCallback, Element elementToHover = null) : + public Tooltip(Paragraph.TextCallback textCallback, Element elementToHover = null) : base(Anchor.TopLeft, Vector2.One, Vector2.Zero) { - this.Paragraph = this.AddChild(new Paragraph(Anchor.TopLeft, width, textCallback)); + this.Paragraph = this.AddChild(new Paragraph(Anchor.TopLeft, 0, textCallback)); this.Init(elementToHover); } @@ -81,8 +79,12 @@ namespace MLEM.Ui.Elements { this.Texture.SetFromStyle(style.TooltipBackground); this.MouseOffset.SetFromStyle(style.TooltipOffset); this.Delay.SetFromStyle(style.TooltipDelay); - // we can't set from style here since it's a different element - this.Paragraph?.TextColor.Set(style.TooltipTextColor); + this.ChildPadding = style.TooltipChildPadding; + if (this.Paragraph != null) { + // we can't set from style here since it's a different element + this.Paragraph.TextColor.Set(style.TooltipTextColor); + this.Paragraph.Size = new Vector2(style.TooltipTextWidth, 0); + } } /// @@ -143,7 +145,6 @@ namespace MLEM.Ui.Elements { this.SetWidthBasedOnChildren = true; this.SetHeightBasedOnChildren = true; - this.ChildPadding = new Vector2(2); this.CanBeMoused = false; if (elementToHover != null) diff --git a/MLEM.Ui/Style/StyleProp.cs b/MLEM.Ui/Style/StyleProp.cs index 8ccbff2..01fddee 100644 --- a/MLEM.Ui/Style/StyleProp.cs +++ b/MLEM.Ui/Style/StyleProp.cs @@ -31,9 +31,8 @@ namespace MLEM.Ui.Style { /// /// The style to apply public void SetFromStyle(T value) { - if (!this.isCustom) { + if (!this.isCustom) this.Value = value; - } } /// @@ -63,6 +62,11 @@ namespace MLEM.Ui.Style { return !EqualityComparer.Default.Equals(this.Value, default); } + /// + public override string ToString() { + return $"{this.Value} (Custom: {this.isCustom})"; + } + /// /// Implicitly converts a style property to its value. /// diff --git a/MLEM.Ui/Style/UiStyle.cs b/MLEM.Ui/Style/UiStyle.cs index fc4ffc0..6901f05 100644 --- a/MLEM.Ui/Style/UiStyle.cs +++ b/MLEM.Ui/Style/UiStyle.cs @@ -31,7 +31,7 @@ namespace MLEM.Ui.Style { /// /// The color that the element renders with when it is moused over () /// - public Color ButtonHoveredColor; + public Color ButtonHoveredColor = Color.LightGray; /// /// The texture that the element uses when it /// @@ -39,12 +39,24 @@ namespace MLEM.Ui.Style { /// /// The color that the element uses when it /// - public Color ButtonDisabledColor; + public Color ButtonDisabledColor = Color.Gray; /// /// The texture that the element uses /// public NinePatch PanelTexture; /// + /// The to apply to a by default + /// + public Padding PanelChildPadding = new Vector2(5); + /// + /// The amount that a 's scrollable area is moved per single movement of the scroll wheel + /// + public float PanelStepPerScroll = 10; + /// + /// The size of the scroller of a 's scroll bar + /// + public Vector2 PanelScrollerSize = new Vector2(5, 10); + /// /// The texture that the element uses /// public NinePatch TextFieldTexture; @@ -55,7 +67,15 @@ namespace MLEM.Ui.Style { /// /// The color that the renders with when it is moused over () /// - public Color TextFieldHoveredColor; + public Color TextFieldHoveredColor = Color.LightGray; + /// + /// The x position that a 's text should start rendering at, based on the x position of the text field + /// + public float TextFieldTextOffsetX = 4; + /// + /// The width that a 's caret should render with + /// + public float TextFieldCaretWidth = 0.5F; /// /// The background texture that the element uses /// @@ -65,6 +85,14 @@ namespace MLEM.Ui.Style { /// public NinePatch ScrollBarScrollerTexture; /// + /// Whether or not a should use smooth scrolling + /// + public bool ScrollBarSmoothScrolling; + /// + /// The factor with which a 's smooth scrolling happens + /// + public float ScrollBarSmoothScrollFactor = 0.75F; + /// /// The texture that the element uses /// public NinePatch CheckboxTexture; @@ -75,12 +103,16 @@ namespace MLEM.Ui.Style { /// /// The color that the element renders with when it is moused over () /// - public Color CheckboxHoveredColor; + public Color CheckboxHoveredColor = Color.LightGray; /// /// The texture that the element renders on top of its regular texture when it is /// public TextureRegion CheckboxCheckmark; /// + /// The width of the space between a and its + /// + public float CheckboxTextOffsetX = 2; + /// /// The texture that the element uses /// public NinePatch RadioTexture; @@ -91,7 +123,7 @@ namespace MLEM.Ui.Style { /// /// The color that the element renders with when it is moused over () /// - public Color RadioHoveredColor; + public Color RadioHoveredColor = Color.LightGray; /// /// The texture that the renders on top of its regular texture when it is /// @@ -103,7 +135,7 @@ namespace MLEM.Ui.Style { /// /// The offset of the element's top left corner from the mouse position /// - public Vector2 TooltipOffset; + public Vector2 TooltipOffset = new Vector2(8, 16); /// /// The color that the text of a should have /// @@ -113,17 +145,25 @@ namespace MLEM.Ui.Style { /// public TimeSpan TooltipDelay = TimeSpan.Zero; /// + /// The width of a 's default text + /// + public float TooltipTextWidth = 50; + /// + /// The to apply to a by default + /// + public Padding TooltipChildPadding = new Vector2(2); + /// /// The texture that the element uses for its background /// public NinePatch ProgressBarTexture; /// /// The color that the element renders with /// - public Color ProgressBarColor; + public Color ProgressBarColor = Color.White; /// /// The padding that the uses for its progress texture () /// - public Vector2 ProgressBarProgressPadding; + public Vector2 ProgressBarProgressPadding = new Vector2(1); /// /// The texture that the uses for displaying its progress /// @@ -131,7 +171,7 @@ namespace MLEM.Ui.Style { /// /// The color that the renders its progress texture with /// - public Color ProgressBarProgressColor; + public Color ProgressBarProgressColor = Color.Red; /// /// The font that and other elements should use for rendering. /// Note that, to specify a bold and italic font for , you should use and . diff --git a/MLEM.Ui/Style/UntexturedStyle.cs b/MLEM.Ui/Style/UntexturedStyle.cs index 8243057..e9008ab 100644 --- a/MLEM.Ui/Style/UntexturedStyle.cs +++ b/MLEM.Ui/Style/UntexturedStyle.cs @@ -16,25 +16,16 @@ namespace MLEM.Ui.Style { public UntexturedStyle(SpriteBatch batch) { this.SelectionIndicator = batch.GenerateTexture(Color.Transparent, Color.Red); this.ButtonTexture = batch.GenerateTexture(Color.CadetBlue); - this.ButtonHoveredColor = Color.LightGray; - this.ButtonDisabledColor = Color.Gray; this.PanelTexture = batch.GenerateTexture(Color.Gray); this.TextFieldTexture = batch.GenerateTexture(Color.MediumBlue); - this.TextFieldHoveredColor = Color.LightGray; this.ScrollBarBackground = batch.GenerateTexture(Color.LightBlue); this.ScrollBarScrollerTexture = batch.GenerateTexture(Color.Blue); this.CheckboxTexture = batch.GenerateTexture(Color.LightBlue); - this.CheckboxHoveredColor = Color.LightGray; this.CheckboxCheckmark = batch.GenerateTexture(Color.Blue).Region; this.RadioTexture = batch.GenerateTexture(Color.AliceBlue); - this.RadioHoveredColor = Color.LightGray; this.RadioCheckmark = batch.GenerateTexture(Color.CornflowerBlue).Region; this.TooltipBackground = batch.GenerateTexture(Color.Black * 0.65F, Color.Black * 0.65F); - this.TooltipOffset = new Vector2(8, 16); this.ProgressBarTexture = batch.GenerateTexture(Color.RoyalBlue); - this.ProgressBarColor = Color.White; - this.ProgressBarProgressPadding = new Vector2(1); - this.ProgressBarProgressColor = Color.Red; } } diff --git a/Sandbox/GameImpl.cs b/Sandbox/GameImpl.cs index 604ef8b..6167e28 100644 --- a/Sandbox/GameImpl.cs +++ b/Sandbox/GameImpl.cs @@ -217,7 +217,7 @@ namespace Sandbox { this.UiSystem.Add("Invalid", invalidPanel);*/ var loadGroup = new Group(Anchor.TopLeft, Vector2.One, false); - var loadPanel = loadGroup.AddChild(new Panel(Anchor.Center, new Vector2(150, 150), Vector2.Zero, false, true, new Point(5, 10), false) { + var loadPanel = loadGroup.AddChild(new Panel(Anchor.Center, new Vector2(150, 150), Vector2.Zero, false, true, false) { ChildPadding = new Padding(5, 10, 5, 5) }); for (var i = 0; i < 1; i++) { diff --git a/Tests/UiTests.cs b/Tests/UiTests.cs index 159c9a7..90822be 100644 --- a/Tests/UiTests.cs +++ b/Tests/UiTests.cs @@ -42,7 +42,7 @@ namespace Tests { [Test] public void TestComplexPanel() { var group = new Group(Anchor.TopLeft, Vector2.One, false); - var panel = group.AddChild(new Panel(Anchor.Center, new Vector2(150, 150), Vector2.Zero, false, true, new Point(5, 10), false) { + var panel = group.AddChild(new Panel(Anchor.Center, new Vector2(150, 150), Vector2.Zero, false, true, false) { ChildPadding = new Padding(5, 10, 5, 5) }); for (var i = 0; i < 5; i++) {