41 lines
1.0 KiB
C#
41 lines
1.0 KiB
C#
using System.Numerics;
|
|
using Voile.Input;
|
|
using Voile.Rendering;
|
|
|
|
namespace Voile.UI.Widgets;
|
|
|
|
/// <summary>
|
|
/// A base class for all UI widgets.
|
|
/// </summary>
|
|
public abstract class Widget : IElement, IRenderableElement, IInputElement
|
|
{
|
|
public bool Visible { get; set; } = true;
|
|
public bool IgnoreInput { get; set; }
|
|
public Vector2 Position { get; set; } = Vector2.Zero;
|
|
|
|
public Widget()
|
|
{
|
|
|
|
}
|
|
|
|
public Widget(Vector2 position)
|
|
{
|
|
Position = position;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get a minimum rectangle size for this widget.
|
|
/// </summary>
|
|
public abstract Rect MinimumRect { get; }
|
|
|
|
/// <summary>
|
|
/// Called when its time to draw this widget.
|
|
/// </summary>
|
|
/// <param name="renderer"></param>
|
|
public abstract void Render(RenderSystem renderer, Style style);
|
|
/// <summary>
|
|
/// Called when this widget receives input.
|
|
/// </summary>
|
|
/// <param name="action">An input action this widget received.</param>
|
|
public abstract void Input(IInputAction action);
|
|
} |