Merge FlexContainer, WIP dynamic container resizing.

This commit is contained in:
2025-06-20 19:46:42 +02:00
parent 76dafe9996
commit bc95fff4a3
3 changed files with 164 additions and 4 deletions

View File

@@ -15,7 +15,15 @@ public abstract class Container : IElement, IParentableElement, IUpdatableElemen
/// <inheritdoc />
public Rect MinimumRect { get; set; } = Rect.Zero;
/// <inheritdoc />
public Rect Size { get; set; } = Rect.Zero;
public Rect Size
{
get => _size;
set
{
_size = value;
MarkDirty();
}
}
/// <inheritdoc />
public bool Visible { get; set; } = true;
/// <inheritdoc />
@@ -71,7 +79,7 @@ public abstract class Container : IElement, IParentableElement, IUpdatableElemen
{
if (Children.Count == 0)
{
Size = MinimumRect;
_size = MinimumRect;
return;
}
@@ -99,7 +107,7 @@ public abstract class Container : IElement, IParentableElement, IUpdatableElemen
float finalWidth = MathF.Max(occupiedWidth, MinimumRect.Width);
float finalHeight = MathF.Max(occupiedHeight, MinimumRect.Height);
Size = new Rect(finalWidth, finalHeight);
MinimumRect = new Rect(finalWidth, finalHeight);
}
public void AddChild(IElement child)
@@ -135,4 +143,5 @@ public abstract class Container : IElement, IParentableElement, IUpdatableElemen
private List<IElement> _children = new();
private bool _isDirty;
private Rect _size = Rect.Zero;
}