1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-06-18 11:24:31 +02:00

Added style properties for a lot of hardcoded default element styles

This commit is contained in:
Ell 2021-10-29 23:33:15 +02:00
parent 9ddc1f6975
commit 0809cd0218
15 changed files with 125 additions and 70 deletions

View file

@ -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

View file

@ -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

View file

@ -79,14 +79,13 @@ namespace MLEM.Ui.Elements {
/// <param name="size">The button's size</param>
/// <param name="text">The text that should be displayed on the button</param>
/// <param name="tooltipText">The text that should be displayed in a <see cref="Tooltip"/> when hovering over this button</param>
/// <param name="tooltipWidth">The width of this button's <see cref="Tooltip"/>, or 50 by default</param>
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);
}
/// <inheritdoc />

View file

@ -36,7 +36,7 @@ namespace MLEM.Ui.Elements {
/// <summary>
/// The width of the space between this checkbox and its <see cref="Label"/>
/// </summary>
public float TextOffsetX = 2;
public StyleProp<float> TextOffsetX;
private bool checced;
/// <summary>
@ -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);
}
/// <summary>

View file

@ -35,8 +35,7 @@ namespace MLEM.Ui.Elements {
/// <param name="size">The dropdown button's size</param>
/// <param name="text">The text displayed on the dropdown button</param>
/// <param name="tooltipText">The text displayed as a tooltip when hovering over the dropdown button</param>
/// <param name="tooltipWidth">The width of the dropdown button's tooltip</param>
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
});

View file

@ -18,11 +18,10 @@ namespace MLEM.Ui.Elements {
/// <param name="texture">The texture of the image to render on the button</param>
/// <param name="text">The text to display on the button</param>
/// <param name="tooltipText">The text of the button's tooltip</param>
/// <param name="tooltipWidth">The width of the button's tooltip</param>
/// <param name="imagePadding">The <see cref="Element.Padding"/> of the button's image</param>
/// <returns>An image button</returns>
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 {
/// <summary>
/// Adds a new <see cref="Tooltip"/> to the given element using the <see cref="Tooltip(float,Paragraph.TextCallback,Element)"/> constructor
/// Adds a new <see cref="Tooltip"/> to the given element using the <see cref="Tooltip(Paragraph.TextCallback,Element)"/> constructor
/// </summary>
/// <param name="element"></param>
/// <param name="width">The width of the tooltip</param>
/// <param name="element">The element to add the tooltip to</param>
/// <param name="textCallback">The text to display on the tooltip</param>
/// <returns>The created tooltip instance</returns>
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);
}
/// <summary>
/// Adds a new <see cref="Tooltip"/> to the given element using the <see cref="Tooltip(float,string,Element)"/> constructor
/// Adds a new <see cref="Tooltip"/> to the given element using the <see cref="Tooltip(string,Element)"/> constructor
/// </summary>
/// <param name="element"></param>
/// <param name="width">The width of the tooltip</param>
/// <param name="element">The element to add the tooltip to</param>
/// <param name="text">The text to display on the tooltip</param>
/// <returns>The created tooltip instance</returns>
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);
}
}

View file

@ -27,8 +27,18 @@ namespace MLEM.Ui.Elements {
/// </summary>
public StyleProp<Color> DrawColor;
/// <summary>
/// The amount that the scrollable area is moved per single movement of the scroll wheel
/// This value is passed to the <see cref="ScrollBar"/>'s <see cref="Elements.ScrollBar.StepPerScroll"/>
/// </summary>
public StyleProp<float> StepPerScroll;
/// <summary>
/// The size that the <see cref="ScrollBar"/>'s scroller should have, in pixels
/// </summary>
public StyleProp<Vector2> ScrollerSize;
/// <summary>
/// The scroll bar that this panel contains.
/// This is only nonnull if <see cref="scrollOverflow"/> is true.
/// Note that some scroll bar styling is controlled by this panel, namely <see cref="StepPerScroll"/> and <see cref="ScrollerSize"/>.
/// </summary>
public readonly ScrollBar ScrollBar;
private readonly bool scrollOverflow;
@ -44,29 +54,22 @@ namespace MLEM.Ui.Elements {
/// <param name="positionOffset">The panel's offset from its anchor point</param>
/// <param name="setHeightBasedOnChildren">Whether the panel should automatically calculate its height based on its children's size</param>
/// <param name="scrollOverflow">Whether this panel should automatically add a scroll bar to scroll towards elements that are beyond the area this panel covers</param>
/// <param name="scrollerSize">The size of the <see cref="ScrollBar"/>'s scroller</param>
/// <param name="autoHideScrollbar">Whether the scroll bar should be hidden automatically if the panel does not contain enough children to allow for scrolling</param>
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();
}
/// <summary>
@ -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);
}
}
}

View file

@ -101,11 +101,11 @@ namespace MLEM.Ui.Elements {
/// Whether smooth scrolling should be enabled for this scroll bar.
/// Smooth scrolling causes the <see cref="CurrentValue"/> to change gradually rather than instantly when scrolling.
/// </summary>
public bool SmoothScrolling;
public StyleProp<bool> SmoothScrolling;
/// <summary>
/// The factor with which <see cref="SmoothScrolling"/> happens.
/// </summary>
public float SmoothScrollFactor = 0.75F;
public StyleProp<float> 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);
}
/// <summary>

View file

@ -113,11 +113,11 @@ namespace MLEM.Ui.Elements {
/// <summary>
/// The x position that text should start rendering at, based on the x position of this text field.
/// </summary>
public float TextOffsetX = 4;
public StyleProp<float> TextOffsetX;
/// <summary>
/// The width that the caret should render with.
/// The width that the caret should render with, in pixels
/// </summary>
public float CaretWidth = 0.5F;
public StyleProp<float> CaretWidth;
/// <summary>
/// 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) {

View file

@ -29,25 +29,23 @@ namespace MLEM.Ui.Elements {
/// <summary>
/// Creates a new tooltip with the given settings
/// </summary>
/// <param name="width">The width of the tooltip</param>
/// <param name="text">The text to display on the tooltip</param>
/// <param name="elementToHover">The element that should automatically cause the tooltip to appear and disappear when hovered and not hovered, respectively</param>
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);
}
/// <summary>
/// Creates a new tooltip with the given settings
/// </summary>
/// <param name="width">The width of the tooltip</param>
/// <param name="textCallback">The text to display on the tooltip</param>
/// <param name="elementToHover">The element that should automatically cause the tooltip to appear and disappear when hovered and not hovered, respectively</param>
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);
}
}
/// <summary>
@ -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)

View file

@ -31,9 +31,8 @@ namespace MLEM.Ui.Style {
/// </summary>
/// <param name="value">The style to apply</param>
public void SetFromStyle(T value) {
if (!this.isCustom) {
if (!this.isCustom)
this.Value = value;
}
}
/// <summary>
@ -63,6 +62,11 @@ namespace MLEM.Ui.Style {
return !EqualityComparer<T>.Default.Equals(this.Value, default);
}
/// <inheritdoc />
public override string ToString() {
return $"{this.Value} (Custom: {this.isCustom})";
}
/// <summary>
/// Implicitly converts a style property to its value.
/// </summary>

View file

@ -31,7 +31,7 @@ namespace MLEM.Ui.Style {
/// <summary>
/// The color that the <see cref="Button"/> element renders with when it is moused over (<see cref="Element.IsMouseOver"/>)
/// </summary>
public Color ButtonHoveredColor;
public Color ButtonHoveredColor = Color.LightGray;
/// <summary>
/// The texture that the <see cref="Button"/> element uses when it <see cref="Button.IsDisabled"/>
/// </summary>
@ -39,12 +39,24 @@ namespace MLEM.Ui.Style {
/// <summary>
/// The color that the <see cref="Button"/> element uses when it <see cref="Button.IsDisabled"/>
/// </summary>
public Color ButtonDisabledColor;
public Color ButtonDisabledColor = Color.Gray;
/// <summary>
/// The texture that the <see cref="Panel"/> element uses
/// </summary>
public NinePatch PanelTexture;
/// <summary>
/// The <see cref="Element.ChildPadding"/> to apply to a <see cref="Panel"/> by default
/// </summary>
public Padding PanelChildPadding = new Vector2(5);
/// <summary>
/// The amount that a <see cref="Panel"/>'s scrollable area is moved per single movement of the scroll wheel
/// </summary>
public float PanelStepPerScroll = 10;
/// <summary>
/// The size of the scroller of a <see cref="Panel"/>'s scroll bar
/// </summary>
public Vector2 PanelScrollerSize = new Vector2(5, 10);
/// <summary>
/// The texture that the <see cref="TextField"/> element uses
/// </summary>
public NinePatch TextFieldTexture;
@ -55,7 +67,15 @@ namespace MLEM.Ui.Style {
/// <summary>
/// The color that the <see cref="TextField"/> renders with when it is moused over (<see cref="Element.IsMouseOver"/>)
/// </summary>
public Color TextFieldHoveredColor;
public Color TextFieldHoveredColor = Color.LightGray;
/// <summary>
/// The x position that a <see cref="TextField"/>'s text should start rendering at, based on the x position of the text field
/// </summary>
public float TextFieldTextOffsetX = 4;
/// <summary>
/// The width that a <see cref="TextField"/>'s caret should render with
/// </summary>
public float TextFieldCaretWidth = 0.5F;
/// <summary>
/// The background texture that the <see cref="ScrollBar"/> element uses
/// </summary>
@ -65,6 +85,14 @@ namespace MLEM.Ui.Style {
/// </summary>
public NinePatch ScrollBarScrollerTexture;
/// <summary>
/// Whether or not a <see cref="ScrollBar"/> should use smooth scrolling
/// </summary>
public bool ScrollBarSmoothScrolling;
/// <summary>
/// The factor with which a <see cref="ScrollBar"/>'s smooth scrolling happens
/// </summary>
public float ScrollBarSmoothScrollFactor = 0.75F;
/// <summary>
/// The texture that the <see cref="Checkbox"/> element uses
/// </summary>
public NinePatch CheckboxTexture;
@ -75,12 +103,16 @@ namespace MLEM.Ui.Style {
/// <summary>
/// The color that the <see cref="Checkbox"/> element renders with when it is moused over (<see cref="Element.IsMouseOver"/>)
/// </summary>
public Color CheckboxHoveredColor;
public Color CheckboxHoveredColor = Color.LightGray;
/// <summary>
/// The texture that the <see cref="Checkbox"/> element renders on top of its regular texture when it is <see cref="Checkbox.Checked"/>
/// </summary>
public TextureRegion CheckboxCheckmark;
/// <summary>
/// The width of the space between a <see cref="Checkbox"/> and its <see cref="Checkbox.Label"/>
/// </summary>
public float CheckboxTextOffsetX = 2;
/// <summary>
/// The texture that the <see cref="RadioButton"/> element uses
/// </summary>
public NinePatch RadioTexture;
@ -91,7 +123,7 @@ namespace MLEM.Ui.Style {
/// <summary>
/// The color that the <see cref="RadioButton"/> element renders with when it is moused over (<see cref="Element.IsMouseOver"/>)
/// </summary>
public Color RadioHoveredColor;
public Color RadioHoveredColor = Color.LightGray;
/// <summary>
/// The texture that the <see cref="RadioButton"/> renders on top of its regular texture when it is <see cref="Checkbox.Checked"/>
/// </summary>
@ -103,7 +135,7 @@ namespace MLEM.Ui.Style {
/// <summary>
/// The offset of the <see cref="Tooltip"/> element's top left corner from the mouse position
/// </summary>
public Vector2 TooltipOffset;
public Vector2 TooltipOffset = new Vector2(8, 16);
/// <summary>
/// The color that the text of a <see cref="Tooltip"/> should have
/// </summary>
@ -113,17 +145,25 @@ namespace MLEM.Ui.Style {
/// </summary>
public TimeSpan TooltipDelay = TimeSpan.Zero;
/// <summary>
/// The width of a <see cref="Tooltip"/>'s default text <see cref="Paragraph"/>
/// </summary>
public float TooltipTextWidth = 50;
/// <summary>
/// The <see cref="Element.ChildPadding"/> to apply to a <see cref="Tooltip"/> by default
/// </summary>
public Padding TooltipChildPadding = new Vector2(2);
/// <summary>
/// The texture that the <see cref="ProgressBar"/> element uses for its background
/// </summary>
public NinePatch ProgressBarTexture;
/// <summary>
/// The color that the <see cref="ProgressBar"/> element renders with
/// </summary>
public Color ProgressBarColor;
public Color ProgressBarColor = Color.White;
/// <summary>
/// The padding that the <see cref="ProgressBar"/> uses for its progress texture (<see cref="ProgressBarProgressTexture"/>)
/// </summary>
public Vector2 ProgressBarProgressPadding;
public Vector2 ProgressBarProgressPadding = new Vector2(1);
/// <summary>
/// The texture that the <see cref="ProgressBar"/> uses for displaying its progress
/// </summary>
@ -131,7 +171,7 @@ namespace MLEM.Ui.Style {
/// <summary>
/// The color that the <see cref="ProgressBar"/> renders its progress texture with
/// </summary>
public Color ProgressBarProgressColor;
public Color ProgressBarProgressColor = Color.Red;
/// <summary>
/// The font that <see cref="Paragraph"/> and other elements should use for rendering.
/// Note that, to specify a bold and italic font for <see cref="TextFormatter"/>, you should use <see cref="GenericFont.Bold"/> and <see cref="GenericFont.Italic"/>.

View file

@ -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;
}
}

View file

@ -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++) {

View file

@ -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++) {