mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
Fixed buttons and checkboxes changing their CanBeSelected and CanBePressed values when being disabled
This commit is contained in:
parent
2c90ca9b89
commit
f166c3d256
4 changed files with 22 additions and 28 deletions
|
@ -55,6 +55,7 @@ Fixes
|
|||
- Fixed the graphics device's viewport being ignored for mouse and touch queries
|
||||
- Fixed auto-navigating panels not scrolling to the center of elements properly
|
||||
- Fixed UiControls allowing for non-selectable or non-mouseable elements to be marked as selected or moused
|
||||
- Fixed buttons and checkboxes changing their CanBeSelected and CanBePressed values when being disabled
|
||||
|
||||
Removals
|
||||
- Marked StyleProp equality members as obsolete
|
||||
|
|
|
@ -51,14 +51,7 @@ namespace MLEM.Ui.Elements {
|
|||
/// Set this property to true to mark the button as disabled.
|
||||
/// A disabled button cannot be moused over, selected or pressed.
|
||||
/// </summary>
|
||||
public bool IsDisabled {
|
||||
get => this.isDisabled;
|
||||
set {
|
||||
this.isDisabled = value;
|
||||
this.CanBePressed = !value;
|
||||
this.CanBeSelected = !value;
|
||||
}
|
||||
}
|
||||
public virtual bool IsDisabled { get; set; }
|
||||
/// <summary>
|
||||
/// Whether this button's <see cref="Text"/> should be truncated if it exceeds this button's width.
|
||||
/// Defaults to false.
|
||||
|
@ -71,7 +64,10 @@ namespace MLEM.Ui.Elements {
|
|||
}
|
||||
}
|
||||
|
||||
private bool isDisabled;
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeSelected => base.CanBeSelected && !this.IsDisabled;
|
||||
/// <inheritdoc />
|
||||
public override bool CanBePressed => base.CanBePressed && !this.IsDisabled;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new button with the given settings
|
||||
|
|
|
@ -62,21 +62,18 @@ namespace MLEM.Ui.Elements {
|
|||
/// Set this property to true to mark the checkbox as disabled.
|
||||
/// A disabled checkbox cannot be moused over, selected or toggled.
|
||||
/// </summary>
|
||||
public bool IsDisabled {
|
||||
get => this.isDisabled;
|
||||
set {
|
||||
this.isDisabled = value;
|
||||
this.CanBePressed = !value;
|
||||
this.CanBeSelected = !value;
|
||||
}
|
||||
}
|
||||
public virtual bool IsDisabled { get; set; }
|
||||
/// <summary>
|
||||
/// An event that is invoked when this checkbox's <see cref="Checked"/> property changes
|
||||
/// </summary>
|
||||
public CheckStateChange OnCheckStateChange;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeSelected => base.CanBeSelected && !this.IsDisabled;
|
||||
/// <inheritdoc />
|
||||
public override bool CanBePressed => base.CanBePressed && !this.IsDisabled;
|
||||
|
||||
private bool isChecked;
|
||||
private bool isDisabled;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new checkbox with the given settings
|
||||
|
|
|
@ -191,51 +191,51 @@ namespace MLEM.Ui.Elements {
|
|||
/// Set this field to false to disallow the element from being selected.
|
||||
/// An unselectable element is skipped by automatic navigation and its <see cref="OnSelected"/> callback will never be called.
|
||||
/// </summary>
|
||||
public bool CanBeSelected = true;
|
||||
public virtual bool CanBeSelected { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Set this field to false to disallow the element from reacting to being moused over.
|
||||
/// </summary>
|
||||
public bool CanBeMoused = true;
|
||||
public virtual bool CanBeMoused { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Set this field to false to disallow this element's <see cref="OnPressed"/> and <see cref="OnSecondaryPressed"/> events to be called.
|
||||
/// </summary>
|
||||
public bool CanBePressed = true;
|
||||
public virtual bool CanBePressed { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Set this field to false to cause auto-anchored siblings to ignore this element as a possible anchor point.
|
||||
/// </summary>
|
||||
public bool CanAutoAnchorsAttach = true;
|
||||
public virtual bool CanAutoAnchorsAttach { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Set this field to true to cause this element's width to be automatically calculated based on the area that its <see cref="Children"/> take up.
|
||||
/// To use this element's <see cref="Size"/>'s X coordinate as a minimum or maximum width rather than ignoring it, set <see cref="TreatSizeAsMinimum"/> or <see cref="TreatSizeAsMaximum"/> to true.
|
||||
/// </summary>
|
||||
public bool SetWidthBasedOnChildren;
|
||||
public virtual bool SetWidthBasedOnChildren { get; set; }
|
||||
/// <summary>
|
||||
/// Set this field to true to cause this element's height to be automatically calculated based on the area that its <see cref="Children"/> take up.
|
||||
/// To use this element's <see cref="Size"/>'s Y coordinate as a minimum or maximum height rather than ignoring it, set <see cref="TreatSizeAsMinimum"/> or <see cref="TreatSizeAsMaximum"/> to true.
|
||||
/// </summary>
|
||||
public bool SetHeightBasedOnChildren;
|
||||
public virtual bool SetHeightBasedOnChildren { get; set; }
|
||||
/// <summary>
|
||||
/// If this field is set to true, and <see cref="SetWidthBasedOnChildren"/> or <see cref="SetHeightBasedOnChildren"/> are enabled, the resulting width or height will always be greather than or equal to this element's <see cref="Size"/>.
|
||||
/// For example, if an element's <see cref="Size"/>'s Y coordinate is set to 20, but there is only one child with a height of 10 in it, the element's height would be shrunk to 10 if this value was false, but would remain at 20 if it was true.
|
||||
/// Note that this value only has an effect if <see cref="SetWidthBasedOnChildren"/> or <see cref="SetHeightBasedOnChildren"/> are enabled.
|
||||
/// </summary>
|
||||
public bool TreatSizeAsMinimum;
|
||||
public virtual bool TreatSizeAsMinimum { get; set; }
|
||||
/// <summary>
|
||||
/// If this field is set to true, and <see cref="SetWidthBasedOnChildren"/> or <see cref="SetHeightBasedOnChildren"/>are enabled, the resulting width or height weill always be less than or equal to this element's <see cref="Size"/>.
|
||||
/// Note that this value only has an effect if <see cref="SetWidthBasedOnChildren"/> or <see cref="SetHeightBasedOnChildren"/> are enabled.
|
||||
/// </summary>
|
||||
public bool TreatSizeAsMaximum;
|
||||
public virtual bool TreatSizeAsMaximum { get; set; }
|
||||
/// <summary>
|
||||
/// Set this field to true to cause this element's final display area to never exceed that of its <see cref="Parent"/>.
|
||||
/// If the resulting area is too large, the size of this element is shrunk to fit the target area.
|
||||
/// This can be useful if an element should fill the remaining area of a parent exactly.
|
||||
/// </summary>
|
||||
public bool PreventParentSpill;
|
||||
public virtual bool PreventParentSpill { get; set; }
|
||||
/// <summary>
|
||||
/// The transparency (alpha value) that this element is rendered with.
|
||||
/// Note that, when <see cref="Draw"/> is called, this alpha value is multiplied with the <see cref="Parent"/>'s alpha value and passed down to this element's <see cref="Children"/>.
|
||||
/// </summary>
|
||||
public float DrawAlpha = 1;
|
||||
public virtual float DrawAlpha { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// Stores whether this element is currently being moused over or touched.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in a new issue