// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine.GUI
{
///
/// Button control
///
[ActorToolbox("GUI")]
public class Button : ContainerControl
{
///
/// The default height for the buttons.
///
public const float DefaultHeight = 24.0f;
///
/// True if button is being pressed (by mouse or touch).
///
protected bool _isPressed;
///
/// The font.
///
protected FontReference _font;
///
/// The text.
///
protected LocalizedString _text = new LocalizedString();
///
/// Button text property.
///
[EditorOrder(10), Tooltip("The button label text.")]
public LocalizedString Text
{
get => _text;
set => _text = value;
}
///
/// Gets or sets the font used to draw button text.
///
[EditorDisplay("Text Style"), EditorOrder(2022), ExpandGroups]
public FontReference Font
{
get => _font;
set => _font = value;
}
///
/// Gets or sets the custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data.
///
[EditorDisplay("Text Style"), EditorOrder(2021), Tooltip("Custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data.")]
public MaterialBase TextMaterial { get; set; }
///
/// Gets or sets the color used to draw button text.
///
[EditorDisplay("Text Style"), EditorOrder(2020)]
public Color TextColor;
///
/// Gets or sets the brush used for background drawing.
///
[EditorDisplay("Background Style"), EditorOrder(1999), Tooltip("The brush used for background drawing."), ExpandGroups]
public IBrush BackgroundBrush { get; set; }
///
/// Gets or sets the background color when button is highlighted.
///
[EditorDisplay("Background Style"), EditorOrder(2001)]
public Color BackgroundColorHighlighted { get; set; }
///
/// Gets or sets the background color when button is selected.
///
[EditorDisplay("Background Style"), EditorOrder(2002)]
public Color BackgroundColorSelected { get; set; }
///
/// Gets or sets whether the button has a border.
///
[EditorDisplay("Border Style"), EditorOrder(2010), ExpandGroups]
public bool HasBorder { get; set; } = true;
///
/// Gets or sets the border thickness.
///
[EditorDisplay("Border Style"), EditorOrder(2011), Limit(0)]
public float BorderThickness { get; set; } = 1.0f;
///
/// Gets or sets the color of the border.
///
[EditorDisplay("Border Style"), EditorOrder(2012)]
public Color BorderColor { get; set; }
///
/// Gets or sets the border color when button is highlighted.
///
[EditorDisplay("Border Style"), EditorOrder(2013)]
public Color BorderColorHighlighted { get; set; }
///
/// Gets or sets the border color when button is selected.
///
[EditorDisplay("Border Style"), EditorOrder(2013)]
public Color BorderColorSelected { get; set; }
///
/// Event fired when user clicks on the button.
///
public event Action Clicked;
///
/// Event fired when user clicks on the button.
///
public event Action