WIP: dirty flag for UI.
This commit is contained in:
@@ -22,11 +22,14 @@ public abstract class Widget : IElement, IRenderableElement, IInputElement, IRes
|
||||
public Widget(Vector2 position)
|
||||
{
|
||||
Position = position;
|
||||
Size = MinimumRect;
|
||||
}
|
||||
|
||||
/// </inheritdoc>
|
||||
public abstract Rect MinimumRect { get; }
|
||||
|
||||
public bool Dirty => _isDirty;
|
||||
|
||||
/// <summary>
|
||||
/// Called when its time to draw this widget.
|
||||
/// </summary>
|
||||
@@ -41,15 +44,22 @@ public abstract class Widget : IElement, IRenderableElement, IInputElement, IRes
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!_isDirty) return;
|
||||
_isDirty = false;
|
||||
|
||||
if (Size == Rect.Zero)
|
||||
{
|
||||
Size = MinimumRect;
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkDirty() => _isDirty = true;
|
||||
|
||||
public void DrawSize(RenderSystem renderer)
|
||||
{
|
||||
renderer.SetTransform(Position, Vector2.Zero);
|
||||
renderer.DrawRectangleOutline(new Vector2(Size.Width, Size.Height), Color.Red, 2.0f);
|
||||
}
|
||||
|
||||
private bool _isDirty = true;
|
||||
}
|
||||
Reference in New Issue
Block a user