mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 05:58:35 +01:00
Made custom values of Element.Style persist when a new ui style is set
This commit is contained in:
parent
94b6aa0d1b
commit
f3e6df6862
3 changed files with 18 additions and 20 deletions
|
@ -31,6 +31,7 @@ Improvements
|
||||||
- Ensure that a panel gets notified of all relevant changes by calling OnChildAreaDirty for all grandchildren
|
- Ensure that a panel gets notified of all relevant changes by calling OnChildAreaDirty for all grandchildren
|
||||||
- Avoid unnecessary panel updates by using an Epsilon comparison when scrolling children
|
- Avoid unnecessary panel updates by using an Epsilon comparison when scrolling children
|
||||||
- Allow setting a default text alignment for paragraphs in UiStyle
|
- Allow setting a default text alignment for paragraphs in UiStyle
|
||||||
|
- Made custom values of Element.Style persist when a new ui style is set
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed paragraph links having incorrect hover locations when using special text alignments
|
- Fixed paragraph links having incorrect hover locations when using special text alignments
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace Demos {
|
||||||
this.root.AddChild(new Button(Anchor.AutoCenter, new Vector2(1, 10), "Change Style") {
|
this.root.AddChild(new Button(Anchor.AutoCenter, new Vector2(1, 10), "Change Style") {
|
||||||
OnPressed = element => this.UiSystem.Style = this.UiSystem.Style == untexturedStyle ? style : untexturedStyle,
|
OnPressed = element => this.UiSystem.Style = this.UiSystem.Style == untexturedStyle ? style : untexturedStyle,
|
||||||
PositionOffset = new Vector2(0, 1),
|
PositionOffset = new Vector2(0, 1),
|
||||||
Texture = this.testPatch
|
Style = untexturedStyle
|
||||||
});
|
});
|
||||||
|
|
||||||
this.root.AddChild(new VerticalSpace(3));
|
this.root.AddChild(new VerticalSpace(3));
|
||||||
|
|
|
@ -32,22 +32,7 @@ namespace MLEM.Ui.Elements {
|
||||||
internal set {
|
internal set {
|
||||||
this.system = value;
|
this.system = value;
|
||||||
this.Controls = value?.Controls;
|
this.Controls = value?.Controls;
|
||||||
this.Style = value?.Style;
|
this.Style = this.Style.OrStyle(value?.Style);
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// This Element's current <see cref="UiStyle"/>.
|
|
||||||
/// When this value is changed, <see cref="InitStyle"/> is called.
|
|
||||||
/// Note that this value is automatically set to the <see cref="UiSystem"/>'s ui style when it is changed.
|
|
||||||
/// </summary>
|
|
||||||
public UiStyle Style {
|
|
||||||
get => this.style;
|
|
||||||
set {
|
|
||||||
if (this.style != value) {
|
|
||||||
this.style = value;
|
|
||||||
if (value != null)
|
|
||||||
this.InitStyle(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -261,6 +246,18 @@ namespace MLEM.Ui.Elements {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AreaDirty { get; private set; }
|
public bool AreaDirty { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This Element's current <see cref="UiStyle"/>.
|
||||||
|
/// When this property is set, <see cref="InitStyle"/> is called.
|
||||||
|
/// </summary>
|
||||||
|
public StyleProp<UiStyle> Style {
|
||||||
|
get => this.style;
|
||||||
|
set {
|
||||||
|
this.style = value;
|
||||||
|
if (this.style.HasValue())
|
||||||
|
this.InitStyle(this.style);
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A style property that contains the selection indicator that is displayed on this element if it is the <see cref="RootElement.SelectedElement"/>
|
/// A style property that contains the selection indicator that is displayed on this element if it is the <see cref="RootElement.SelectedElement"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -418,7 +415,7 @@ namespace MLEM.Ui.Elements {
|
||||||
private RectangleF area;
|
private RectangleF area;
|
||||||
private bool isHidden;
|
private bool isHidden;
|
||||||
private int priority;
|
private int priority;
|
||||||
private UiStyle style;
|
private StyleProp<UiStyle> style;
|
||||||
private StyleProp<Padding> childPadding;
|
private StyleProp<Padding> childPadding;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1063,7 +1060,7 @@ namespace MLEM.Ui.Elements {
|
||||||
this.ActionSound = this.ActionSound.OrStyle(style.ActionSound);
|
this.ActionSound = this.ActionSound.OrStyle(style.ActionSound);
|
||||||
this.SecondActionSound = this.SecondActionSound.OrStyle(style.ActionSound);
|
this.SecondActionSound = this.SecondActionSound.OrStyle(style.ActionSound);
|
||||||
|
|
||||||
this.System.InvokeOnElementStyleInit(this);
|
this.System?.InvokeOnElementStyleInit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue