Update arrangement logic for containers, remove position property from Rect, add Size property to IElement.
This commit is contained in:
@@ -7,11 +7,12 @@ namespace Voile.UI.Widgets;
|
||||
/// <summary>
|
||||
/// A base class for all UI widgets.
|
||||
/// </summary>
|
||||
public abstract class Widget : IElement, IRenderableElement, IInputElement
|
||||
public abstract class Widget : IElement, IRenderableElement, IInputElement, IResizeableElement, IUpdatableElement
|
||||
{
|
||||
public bool Visible { get; set; } = true;
|
||||
public bool IgnoreInput { get; set; }
|
||||
public Vector2 Position { get; set; } = Vector2.Zero;
|
||||
public Rect Size { get; set; } = new();
|
||||
|
||||
public Widget()
|
||||
{
|
||||
@@ -23,9 +24,7 @@ public abstract class Widget : IElement, IRenderableElement, IInputElement
|
||||
Position = position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a minimum rectangle size for this widget.
|
||||
/// </summary>
|
||||
/// </inheritdoc>
|
||||
public abstract Rect MinimumRect { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -38,4 +37,12 @@ public abstract class Widget : IElement, IRenderableElement, IInputElement
|
||||
/// </summary>
|
||||
/// <param name="action">An input action this widget received.</param>
|
||||
public abstract void Input(IInputAction action);
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Size == Rect.Zero)
|
||||
{
|
||||
Size = MinimumRect;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user