1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 04:53:29 +01:00

Allow manually hiding a paragraph without its text overriding the hidden state

This commit is contained in:
Ell 2022-05-04 13:22:24 +02:00
parent 58b716aabb
commit 98118e540a
2 changed files with 7 additions and 4 deletions

View file

@ -28,6 +28,7 @@ Improvements
- Turned Tooltip paragraph styling into style properties
- Improved ElementHelper.AddTooltip overloads
- Don't query a paragraph's text callback in the constructor
- Allow manually hiding a paragraph without its text overriding the hidden state
Fixes
- Fixed auto-nav tooltip displaying on the selected element even when not in auto-nav mode

View file

@ -59,7 +59,7 @@ namespace MLEM.Ui.Elements {
set {
if (this.text != value) {
this.text = value;
this.IsHidden = string.IsNullOrWhiteSpace(this.text);
this.forceHide = string.IsNullOrWhiteSpace(this.text);
this.SetTextDirty();
}
}
@ -99,9 +99,13 @@ namespace MLEM.Ui.Elements {
}
}
/// <inheritdoc />
public override bool IsHidden => base.IsHidden || this.forceHide;
private string text;
private StyleProp<TextAlignment> alignment;
private StyleProp<GenericFont> regularFont;
private bool forceHide;
/// <summary>
/// Creates a new paragraph with the given settings.
@ -110,14 +114,12 @@ namespace MLEM.Ui.Elements {
/// <param name="width">The paragraph's width. Note that its height is automatically calculated.</param>
/// <param name="textCallback">The paragraph's text</param>
/// <param name="autoAdjustWidth">Whether the paragraph's width should automatically be calculated based on the text within it.</param>
public Paragraph(Anchor anchor, float width, TextCallback textCallback, bool autoAdjustWidth = false) : this(anchor, width, "", autoAdjustWidth) {
this.IsHidden = true;
public Paragraph(Anchor anchor, float width, TextCallback textCallback, bool autoAdjustWidth = false) : this(anchor, width, string.Empty, autoAdjustWidth) {
this.GetTextCallback = textCallback;
}
/// <inheritdoc cref="Paragraph(Anchor,float,TextCallback,bool)"/>
public Paragraph(Anchor anchor, float width, string text, bool autoAdjustWidth = false) : base(anchor, new Vector2(width, 0)) {
this.IsHidden = true;
this.Text = text;
this.AutoAdjustWidth = autoAdjustWidth;
this.CanBeSelected = false;