Add MarginContainer, mark parent elements dirty when child gets marked dirty too.

This commit is contained in:
2025-06-25 00:35:35 +02:00
parent 5bf052db96
commit 64d3dba42d
5 changed files with 111 additions and 13 deletions

View File

@@ -56,7 +56,8 @@ public class TestGame : Game
Input.AddInputMapping("reload", new IInputAction[] { new KeyInputAction(KeyboardKey.R) });
_emitterId = _particleSystem.CreateEmitter(Renderer.WindowSize / 2, _fireEffect);
_fillContainer.AddChild(_container);
_fillContainer.AddChild(_marginContainer);
_marginContainer.AddChild(_container);
_uiSystem.AddElement(_fillContainer);
}
@@ -129,21 +130,20 @@ public class TestGame : Game
private FlexContainer _container = new(minimumSize: new Rect(64.0f, 64.0f), new())
{
ConfineToContents = true,
Anchor = Anchor.Center,
Size = new Rect(500, 300),
Direction = FlexDirection.Column,
Justify = JustifyContent.Start,
Align = AlignItems.Center,
Wrap = true,
Gap = 10f
Gap = 8.0f
};
private FillContainer _fillContainer = new();
private MarginContainer _marginContainer = new(new Margin(32.0f))
{
};
// private HorizontalContainer _container = new(new Rect(128.0f, 64.0f), new(), 16)
// {
// ConfineToContents = true,
// Anchor = Anchor.CenterRight,
// AnchorOffset = new Vector2(0.5f, 0.0f)
// };
}