WIP: measure text in Font.

This commit is contained in:
2025-06-29 15:10:37 +02:00
parent 6b108ba56c
commit 0ec4e45c38
4 changed files with 70 additions and 26 deletions

View File

@@ -56,10 +56,10 @@ public class TestGame : Game
Input.AddInputMapping("reload", new IInputAction[] { new KeyInputAction(KeyboardKey.R) });
_emitterId = _particleSystem.CreateEmitter(Renderer.WindowSize / 2, _fireEffect);
_fillContainer.AddChild(_marginContainer);
_marginContainer.AddChild(_container);
// _fillContainer.AddChild(_container);
// _marginContainer.AddChild(_container);
_uiSystem.AddElement(_fillContainer);
_uiSystem.AddElement(_container);
}
@@ -73,7 +73,7 @@ public class TestGame : Game
if (Input.IsActionPressed("accept"))
{
_container.AddChild(new RectangleWidget(new Rect(32.0f, 32.0f), MathUtils.RandomColor()));
_container.AddChild(new Label("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", _font));
}
if (Input.IsActionPressed("cancel") && _container.Children.Count != 0)
@@ -123,7 +123,7 @@ public class TestGame : Game
private ResourceRef<Sound> _sound;
private ResourceRef<Texture2d> _icon;
private FlexContainer _container = new(minimumSize: new Rect(64.0f, 64.0f), new())
private FlexContainer _container = new(minimumSize: new Rect(256.0f, 256.0f), new())
{
Anchor = Anchor.Center,
Direction = FlexDirection.Column,
@@ -133,6 +133,8 @@ public class TestGame : Game
Gap = 8.0f
};
[NotNull] private Label _label;
private FillContainer _fillContainer = new();
private MarginContainer _marginContainer = new(new Margin(32.0f))
{