TextLayout, match rendered text with measured text, implement word wrapping
This commit is contained in:
@@ -98,39 +98,33 @@ public class TestGame : Game
|
||||
PlaceholderText = "Hello, World!"
|
||||
};
|
||||
|
||||
c.AddChild(addButton);
|
||||
c.AddChild(removeButton);
|
||||
c.AddChild(outlineButton);
|
||||
c.AddChild(linkButton);
|
||||
c.AddChild(inputField);
|
||||
// c.AddChild(addButton);
|
||||
// c.AddChild(removeButton);
|
||||
// c.AddChild(outlineButton);
|
||||
// c.AddChild(linkButton);
|
||||
// c.AddChild(inputField);
|
||||
|
||||
var vc = new VerticalContainer(0.0f);
|
||||
vc.AddChild(c);
|
||||
_label = new Label("What the heck??? Word wrapping!!! That's crazy... Noooo wayyy Before GTA 6 too!!!\nnewline :)", _defaultFontSet)
|
||||
{
|
||||
Size = new Rect(256.0f, 128.0f),
|
||||
};
|
||||
|
||||
var f = new MarginContainer(new Size(0.0f));
|
||||
f.AddChild(_container);
|
||||
|
||||
vc.AddChild(f);
|
||||
|
||||
_rootFill.AddChild(vc);
|
||||
_uiSystem.AddElement(_rootFill);
|
||||
// _rootFill.AddChild(_label);
|
||||
_uiSystem.AddElement(_label);
|
||||
}
|
||||
|
||||
|
||||
protected override void Update(double deltaTime)
|
||||
{
|
||||
if (Input.IsActionPressed("reload"))
|
||||
{
|
||||
// ResourceManager.Reload();
|
||||
// _particleSystem!.RestartEmitter(_emitterId);
|
||||
}
|
||||
|
||||
_uiSystem.SetWindowSize(Renderer.WindowSize);
|
||||
|
||||
var mousePos = Input.GetMousePosition();
|
||||
_label.Size = new Rect(mousePos.X, mousePos.Y);
|
||||
}
|
||||
|
||||
protected override void Render(double deltaTime)
|
||||
{
|
||||
Renderer.ClearBackground(Color.Black);
|
||||
Renderer.ClearBackground(Color.White);
|
||||
|
||||
// foreach (var emitter in _particleSystem!.Emitters)
|
||||
// {
|
||||
@@ -139,6 +133,8 @@ public class TestGame : Game
|
||||
|
||||
Renderer.ResetTransform();
|
||||
_uiSystem.Render(Renderer);
|
||||
Renderer.SetTransform(_label.GlobalPosition, Vector2.Zero);
|
||||
Renderer.DrawRectangleOutline(_label.Size, Color.Red, 2);
|
||||
}
|
||||
|
||||
private void DrawEmitter(ParticleEmitter emitter)
|
||||
|
||||
Reference in New Issue
Block a user