mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 14:08:34 +01:00
Compare commits
No commits in common. "f166c3d25607692d65a4b10a06ca8dfc0b22b0ea" and "cd32372994270337b8a43d8297873c5d475235f7" have entirely different histories.
f166c3d256
...
cd32372994
5 changed files with 30 additions and 33 deletions
|
@ -54,8 +54,6 @@ Fixes
|
|||
- Fixed paragraph links having incorrect hover locations when using special text alignments
|
||||
- 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,7 +51,14 @@ 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 virtual bool IsDisabled { get; set; }
|
||||
public bool IsDisabled {
|
||||
get => this.isDisabled;
|
||||
set {
|
||||
this.isDisabled = value;
|
||||
this.CanBePressed = !value;
|
||||
this.CanBeSelected = !value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether this button's <see cref="Text"/> should be truncated if it exceeds this button's width.
|
||||
/// Defaults to false.
|
||||
|
@ -64,10 +71,7 @@ namespace MLEM.Ui.Elements {
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeSelected => base.CanBeSelected && !this.IsDisabled;
|
||||
/// <inheritdoc />
|
||||
public override bool CanBePressed => base.CanBePressed && !this.IsDisabled;
|
||||
private bool isDisabled;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new button with the given settings
|
||||
|
|
|
@ -62,18 +62,21 @@ 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 virtual bool IsDisabled { get; set; }
|
||||
public bool IsDisabled {
|
||||
get => this.isDisabled;
|
||||
set {
|
||||
this.isDisabled = value;
|
||||
this.CanBePressed = !value;
|
||||
this.CanBeSelected = !value;
|
||||
}
|
||||
}
|
||||
/// <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 virtual bool CanBeSelected { get; set; } = true;
|
||||
public bool CanBeSelected = true;
|
||||
/// <summary>
|
||||
/// Set this field to false to disallow the element from reacting to being moused over.
|
||||
/// </summary>
|
||||
public virtual bool CanBeMoused { get; set; } = true;
|
||||
public bool CanBeMoused = 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 virtual bool CanBePressed { get; set; } = true;
|
||||
public bool CanBePressed = true;
|
||||
/// <summary>
|
||||
/// Set this field to false to cause auto-anchored siblings to ignore this element as a possible anchor point.
|
||||
/// </summary>
|
||||
public virtual bool CanAutoAnchorsAttach { get; set; } = true;
|
||||
public bool CanAutoAnchorsAttach = 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 virtual bool SetWidthBasedOnChildren { get; set; }
|
||||
public bool SetWidthBasedOnChildren;
|
||||
/// <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 virtual bool SetHeightBasedOnChildren { get; set; }
|
||||
public bool SetHeightBasedOnChildren;
|
||||
/// <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 virtual bool TreatSizeAsMinimum { get; set; }
|
||||
public bool TreatSizeAsMinimum;
|
||||
/// <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 virtual bool TreatSizeAsMaximum { get; set; }
|
||||
public bool TreatSizeAsMaximum;
|
||||
/// <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 virtual bool PreventParentSpill { get; set; }
|
||||
public bool PreventParentSpill;
|
||||
/// <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 virtual float DrawAlpha { get; set; } = 1;
|
||||
public float DrawAlpha = 1;
|
||||
/// <summary>
|
||||
/// Stores whether this element is currently being moused over or touched.
|
||||
/// </summary>
|
||||
|
|
|
@ -259,9 +259,7 @@ namespace MLEM.Ui {
|
|||
/// <param name="element">The element to select, or null to deselect the selected element.</param>
|
||||
/// <param name="autoNav">Whether automatic navigation should be forced on</param>
|
||||
public void SelectElement(RootElement root, Element element, bool? autoNav = null) {
|
||||
if (root == null || !root.CanSelectContent)
|
||||
return;
|
||||
if (element != null && !element.CanBeSelected)
|
||||
if (root == null)
|
||||
return;
|
||||
var selected = this.GetSelectedElement(root);
|
||||
if (selected == element)
|
||||
|
@ -286,8 +284,6 @@ namespace MLEM.Ui {
|
|||
/// </summary>
|
||||
/// <param name="element">The element to set as moused</param>
|
||||
public void SetMousedElement(Element element) {
|
||||
if (element != null && !element.CanBeMoused)
|
||||
return;
|
||||
if (element != this.MousedElement) {
|
||||
if (this.MousedElement != null)
|
||||
this.System.InvokeOnElementMouseExit(this.MousedElement);
|
||||
|
@ -303,8 +299,6 @@ namespace MLEM.Ui {
|
|||
/// </summary>
|
||||
/// <param name="element">The element to set as touched</param>
|
||||
public void SetTouchedElement(Element element) {
|
||||
if (element != null && !element.CanBeMoused)
|
||||
return;
|
||||
if (element != this.TouchedElement) {
|
||||
if (this.TouchedElement != null)
|
||||
this.System.InvokeOnElementTouchExit(this.TouchedElement);
|
||||
|
@ -322,11 +316,9 @@ namespace MLEM.Ui {
|
|||
/// <param name="root">The root element whose selected element to return</param>
|
||||
/// <returns>The given root's selected element, or null if the root doesn't exist, or if there is no selected element for that root.</returns>
|
||||
public Element GetSelectedElement(RootElement root) {
|
||||
if (root == null || !root.CanSelectContent)
|
||||
if (root == null)
|
||||
return null;
|
||||
this.selectedElements.TryGetValue(root.Name, out var element);
|
||||
if (element != null && !element.CanBeSelected)
|
||||
return null;
|
||||
return element;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue