Add container nesting.

This commit is contained in:
2025-06-19 14:50:05 +02:00
parent 806c9cc1d4
commit e499691714
8 changed files with 113 additions and 17 deletions

View File

@@ -55,12 +55,7 @@ public class TestGame : Game
Input.AddInputMapping("reload", new IInputAction[] { new KeyInputAction(KeyboardKey.R) });
_emitterId = _particleSystem.CreateEmitter(Renderer.WindowSize / 2, _fireEffect);
_uiSystem.AddElement(new VerticalContainer(new()
{
new Label("Hello, I'm a label!", _font),
new Label("I'm also a label, except I'm located slightly lower!", _font),
new Label("I hope a VerticalContainer works.", _font)
}, 64.0f));
_uiSystem.AddElement(_container);
}
@@ -74,7 +69,7 @@ public class TestGame : Game
if (Input.KeyboardKeyJustPressed(KeyboardKey.One))
{
_particleSystem.CreateEmitter(Input.GetMousePosition(), _fireEffect);
_container.AddChild(new RectangleWidget(new Rect(Vector2.Zero, 32.0f, 32.0f), MathUtils.RandomColor()));
}
if (Input.IsMouseButtonDown(MouseButton.Left))
@@ -121,4 +116,6 @@ public class TestGame : Game
private ResourceRef<Font> _font;
private ResourceRef<Sound> _sound;
private ResourceRef<Texture2d> _icon;
private HorizontalContainer _container = new(spacing: 64.0f);
}