mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-24 21:48: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
|
||||
- Avoid unnecessary panel updates by using an Epsilon comparison when scrolling children
|
||||
- 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
|
||||
- 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") {
|
||||
OnPressed = element => this.UiSystem.Style = this.UiSystem.Style == untexturedStyle ? style : untexturedStyle,
|
||||
PositionOffset = new Vector2(0, 1),
|
||||
Texture = this.testPatch
|
||||
Style = untexturedStyle
|
||||
});
|
||||
|
||||
this.root.AddChild(new VerticalSpace(3));
|
||||
|
|
|
@ -32,22 +32,7 @@ namespace MLEM.Ui.Elements {
|
|||
internal set {
|
||||
this.system = value;
|
||||
this.Controls = value?.Controls;
|
||||
this.Style = 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);
|
||||
}
|
||||
this.Style = this.Style.OrStyle(value?.Style);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -261,6 +246,18 @@ namespace MLEM.Ui.Elements {
|
|||
/// </summary>
|
||||
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>
|
||||
/// A style property that contains the selection indicator that is displayed on this element if it is the <see cref="RootElement.SelectedElement"/>
|
||||
/// </summary>
|
||||
|
@ -418,7 +415,7 @@ namespace MLEM.Ui.Elements {
|
|||
private RectangleF area;
|
||||
private bool isHidden;
|
||||
private int priority;
|
||||
private UiStyle style;
|
||||
private StyleProp<UiStyle> style;
|
||||
private StyleProp<Padding> childPadding;
|
||||
|
||||
/// <summary>
|
||||
|
@ -1062,8 +1059,8 @@ namespace MLEM.Ui.Elements {
|
|||
this.SelectionIndicator = this.SelectionIndicator.OrStyle(style.SelectionIndicator);
|
||||
this.ActionSound = this.ActionSound.OrStyle(style.ActionSound);
|
||||
this.SecondActionSound = this.SecondActionSound.OrStyle(style.ActionSound);
|
||||
|
||||
this.System.InvokeOnElementStyleInit(this);
|
||||
|
||||
this.System?.InvokeOnElementStyleInit(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in a new issue