using System.Numerics;
using Voile.Input;
using Voile.Rendering;
namespace Voile.UI.Widgets;
///
/// A base class for all UI widgets.
///
public abstract class Widget : UIElement, IInputElement
{
public Widget()
{
MarkDirty();
}
public Widget(Rect size)
{
Size = size;
MarkDirty();
}
public Widget(Vector2 position)
{
Position = position;
MarkDirty();
}
public void Input(UIInputContext context)
{
if (context.Handled || IgnoreInput) return;
if (ContainsPoint(context.MousePosition))
{
OnInput(context);
}
}
///
/// Called when this widget receives input.
///
/// An input action this widget received.
protected abstract void OnInput(UIInputContext context);
}