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 : UIElement, IInputElement
{
    public Widget()
    {
        MarkDirty();
    }

    public Widget(Rect size)
    {
        Size = size;
        MarkDirty();
    }

    public Widget(Vector2 position)
    {
        LocalPosition = position;
        MarkDirty();
    }

    public void Input(UIInputContext context)
    {
        if (context.Handled || IgnoreInput) return;
        OnInput(context);
    }

    /// <summary>
    /// Called when this widget receives input.
    /// </summary>
    /// <param name="action">An input action this widget received.</param>
    protected abstract void OnInput(UIInputContext context);
}