42 lines
945 B
C#
42 lines
945 B
C#
using System.Numerics;
|
|
using Voile.Input;
|
|
using Voile.Rendering;
|
|
|
|
namespace Voile.UI.Widgets;
|
|
|
|
public enum ButtonState
|
|
{
|
|
Disabled,
|
|
Hovered,
|
|
Pressed,
|
|
Normal
|
|
}
|
|
|
|
/// <summary>
|
|
/// A clickable button with a label.
|
|
/// </summary>
|
|
public class Button : Widget
|
|
{
|
|
public string Label { get; set; } = "Button";
|
|
public override Rect MinimumRect => new Rect(Position, Width: 128.0f, Height: 64.0f);
|
|
|
|
public Button(string label, Action pressedAction)
|
|
{
|
|
Label = label;
|
|
_pressedAction = pressedAction;
|
|
}
|
|
|
|
public override void Render(RenderSystem renderer, Style style)
|
|
{
|
|
// TODO: use a button color from style.
|
|
renderer.SetTransform(Position, Vector2.Zero);
|
|
renderer.DrawRectangle(new Vector2(MinimumRect.Width, MinimumRect.Height), new Color(0.25f, 0.25f, 0.25f));
|
|
}
|
|
|
|
public override void Input(IInputAction action)
|
|
{
|
|
|
|
}
|
|
|
|
private Action _pressedAction;
|
|
} |