using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MLEM.Graphics;
using MLEM.Maths;
using MLEM.Textures;
using MLEM.Ui.Style;
namespace MLEM.Ui.Elements {
///
/// A button element for use inside of a .
/// A button element can be pressed, hovered over and that can be disabled.
///
public class Button : Element {
///
/// The button's texture
///
public StyleProp Texture;
///
/// The color that the button draws its texture with
///
public StyleProp NormalColor = Color.White;
///
/// The texture that the button uses while being moused over.
/// If this is null, it uses its default .
///
public StyleProp HoveredTexture;
///
/// The color that the button uses for drawing while being moused over
///
public StyleProp HoveredColor;
///
/// The texture that the button uses when it .
/// If this is null, it uses its default .
///
public StyleProp DisabledTexture;
///
/// The color that the button uses for drawing when it
///
public StyleProp DisabledColor;
///
/// The of text that is displayed on the button.
/// Note that this is only nonnull by default if the constructor was passed a nonnull text.
///
public Paragraph Text;
///
/// The that is displayed when hovering over the button.
/// Note that this is only nonnull by default if the constructor was passed a nonnull tooltip text.
///
public Tooltip Tooltip;
///
/// Set this property to true to mark the button as disabled.
/// A disabled button cannot be moused over, selected or pressed.
/// If this value changes often, consider using .
///
public virtual bool IsDisabled {
get => this.isDisabled || this.AutoDisableCondition?.Invoke(this) == true;
set => this.isDisabled = value;
}
///
/// Whether this button's should be truncated if it exceeds this button's width.
/// Defaults to false.
///
public bool TruncateTextIfLong {
get => this.Text?.TruncateIfLong ?? false;
set {
if (this.Text != null)
this.Text.TruncateIfLong = value;
}
}
///
/// Whether this button should be able to be selected even if it .
/// If this is true, will be able to return true even if is true.
///
public bool CanSelectDisabled;
///
/// An optional function that can be used to modify the result of automatically based on a user-defined condition. This removes the need to disable a button based on a condition in or manually.
/// Note that, if 's underlying value is set to using , this function's result will be ignored.
///
public Func