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 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 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 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
|
Removals
|
||||||
- Marked StyleProp equality members as obsolete
|
- 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.
|
/// Set this property to true to mark the button as disabled.
|
||||||
/// A disabled button cannot be moused over, selected or pressed.
|
/// A disabled button cannot be moused over, selected or pressed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool IsDisabled { get; set; }
|
public bool IsDisabled {
|
||||||
|
get => this.isDisabled;
|
||||||
|
set {
|
||||||
|
this.isDisabled = value;
|
||||||
|
this.CanBePressed = !value;
|
||||||
|
this.CanBeSelected = !value;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this button's <see cref="Text"/> should be truncated if it exceeds this button's width.
|
/// Whether this button's <see cref="Text"/> should be truncated if it exceeds this button's width.
|
||||||
/// Defaults to false.
|
/// Defaults to false.
|
||||||
|
@ -64,10 +71,7 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
private bool isDisabled;
|
||||||
public override bool CanBeSelected => base.CanBeSelected && !this.IsDisabled;
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override bool CanBePressed => base.CanBePressed && !this.IsDisabled;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new button with the given settings
|
/// 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.
|
/// Set this property to true to mark the checkbox as disabled.
|
||||||
/// A disabled checkbox cannot be moused over, selected or toggled.
|
/// A disabled checkbox cannot be moused over, selected or toggled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool IsDisabled { get; set; }
|
public bool IsDisabled {
|
||||||
|
get => this.isDisabled;
|
||||||
|
set {
|
||||||
|
this.isDisabled = value;
|
||||||
|
this.CanBePressed = !value;
|
||||||
|
this.CanBeSelected = !value;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An event that is invoked when this checkbox's <see cref="Checked"/> property changes
|
/// An event that is invoked when this checkbox's <see cref="Checked"/> property changes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CheckStateChange OnCheckStateChange;
|
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 isChecked;
|
||||||
|
private bool isDisabled;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new checkbox with the given settings
|
/// 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.
|
/// 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.
|
/// An unselectable element is skipped by automatic navigation and its <see cref="OnSelected"/> callback will never be called.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool CanBeSelected { get; set; } = true;
|
public bool CanBeSelected = true;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this field to false to disallow the element from reacting to being moused over.
|
/// Set this field to false to disallow the element from reacting to being moused over.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool CanBeMoused { get; set; } = true;
|
public bool CanBeMoused = true;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this field to false to disallow this element's <see cref="OnPressed"/> and <see cref="OnSecondaryPressed"/> events to be called.
|
/// Set this field to false to disallow this element's <see cref="OnPressed"/> and <see cref="OnSecondaryPressed"/> events to be called.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool CanBePressed { get; set; } = true;
|
public bool CanBePressed = true;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this field to false to cause auto-anchored siblings to ignore this element as a possible anchor point.
|
/// Set this field to false to cause auto-anchored siblings to ignore this element as a possible anchor point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool CanAutoAnchorsAttach { get; set; } = true;
|
public bool CanAutoAnchorsAttach = true;
|
||||||
/// <summary>
|
/// <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.
|
/// 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.
|
/// 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>
|
/// </summary>
|
||||||
public virtual bool SetWidthBasedOnChildren { get; set; }
|
public bool SetWidthBasedOnChildren;
|
||||||
/// <summary>
|
/// <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.
|
/// 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.
|
/// 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>
|
/// </summary>
|
||||||
public virtual bool SetHeightBasedOnChildren { get; set; }
|
public bool SetHeightBasedOnChildren;
|
||||||
/// <summary>
|
/// <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"/>.
|
/// 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.
|
/// 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.
|
/// Note that this value only has an effect if <see cref="SetWidthBasedOnChildren"/> or <see cref="SetHeightBasedOnChildren"/> are enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool TreatSizeAsMinimum { get; set; }
|
public bool TreatSizeAsMinimum;
|
||||||
/// <summary>
|
/// <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"/>.
|
/// 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.
|
/// Note that this value only has an effect if <see cref="SetWidthBasedOnChildren"/> or <see cref="SetHeightBasedOnChildren"/> are enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool TreatSizeAsMaximum { get; set; }
|
public bool TreatSizeAsMaximum;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this field to true to cause this element's final display area to never exceed that of its <see cref="Parent"/>.
|
/// 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.
|
/// 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.
|
/// This can be useful if an element should fill the remaining area of a parent exactly.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool PreventParentSpill { get; set; }
|
public bool PreventParentSpill;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The transparency (alpha value) that this element is rendered with.
|
/// 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"/>.
|
/// 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>
|
/// </summary>
|
||||||
public virtual float DrawAlpha { get; set; } = 1;
|
public float DrawAlpha = 1;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores whether this element is currently being moused over or touched.
|
/// Stores whether this element is currently being moused over or touched.
|
||||||
/// </summary>
|
/// </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="element">The element to select, or null to deselect the selected element.</param>
|
||||||
/// <param name="autoNav">Whether automatic navigation should be forced on</param>
|
/// <param name="autoNav">Whether automatic navigation should be forced on</param>
|
||||||
public void SelectElement(RootElement root, Element element, bool? autoNav = null) {
|
public void SelectElement(RootElement root, Element element, bool? autoNav = null) {
|
||||||
if (root == null || !root.CanSelectContent)
|
if (root == null)
|
||||||
return;
|
|
||||||
if (element != null && !element.CanBeSelected)
|
|
||||||
return;
|
return;
|
||||||
var selected = this.GetSelectedElement(root);
|
var selected = this.GetSelectedElement(root);
|
||||||
if (selected == element)
|
if (selected == element)
|
||||||
|
@ -286,8 +284,6 @@ namespace MLEM.Ui {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="element">The element to set as moused</param>
|
/// <param name="element">The element to set as moused</param>
|
||||||
public void SetMousedElement(Element element) {
|
public void SetMousedElement(Element element) {
|
||||||
if (element != null && !element.CanBeMoused)
|
|
||||||
return;
|
|
||||||
if (element != this.MousedElement) {
|
if (element != this.MousedElement) {
|
||||||
if (this.MousedElement != null)
|
if (this.MousedElement != null)
|
||||||
this.System.InvokeOnElementMouseExit(this.MousedElement);
|
this.System.InvokeOnElementMouseExit(this.MousedElement);
|
||||||
|
@ -303,8 +299,6 @@ namespace MLEM.Ui {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="element">The element to set as touched</param>
|
/// <param name="element">The element to set as touched</param>
|
||||||
public void SetTouchedElement(Element element) {
|
public void SetTouchedElement(Element element) {
|
||||||
if (element != null && !element.CanBeMoused)
|
|
||||||
return;
|
|
||||||
if (element != this.TouchedElement) {
|
if (element != this.TouchedElement) {
|
||||||
if (this.TouchedElement != null)
|
if (this.TouchedElement != null)
|
||||||
this.System.InvokeOnElementTouchExit(this.TouchedElement);
|
this.System.InvokeOnElementTouchExit(this.TouchedElement);
|
||||||
|
@ -322,11 +316,9 @@ namespace MLEM.Ui {
|
||||||
/// <param name="root">The root element whose selected element to return</param>
|
/// <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>
|
/// <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) {
|
public Element GetSelectedElement(RootElement root) {
|
||||||
if (root == null || !root.CanSelectContent)
|
if (root == null)
|
||||||
return null;
|
return null;
|
||||||
this.selectedElements.TryGetValue(root.Name, out var element);
|
this.selectedElements.TryGetValue(root.Name, out var element);
|
||||||
if (element != null && !element.CanBeSelected)
|
|
||||||
return null;
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue