Add RemoveChild to IParentableElement, only resize Container if children overflow it.

This commit is contained in:
2025-06-20 19:14:29 +02:00
parent 3154b3fa10
commit a9a8113dd9
4 changed files with 28 additions and 9 deletions

View File

@@ -73,9 +73,16 @@ public class TestGame : Game
_container.AddChild(new RectangleWidget(new Rect(32.0f, 32.0f), MathUtils.RandomColor()));
}
if (Input.IsActionPressed("cancel") && _container.Children.Count != 0)
{
var lastChild = _container.Children.Last();
_container.RemoveChild(lastChild);
}
if (Input.IsMouseButtonDown(MouseButton.Left))
{
_particleSystem.SetEmitterPosition(_emitterId, Input.GetMousePosition());
var mousePos = Input.GetMousePosition();
_container.Size = new Rect(mousePos.X, mousePos.Y);
}
}
@@ -118,5 +125,5 @@ public class TestGame : Game
private ResourceRef<Sound> _sound;
private ResourceRef<Texture2d> _icon;
private GridContainer _container = new();
private GridContainer _container = new(minimumSize: new Rect(64.0f, 64.0f), new());
}