Compare commits

...

1 Commits

Author SHA1 Message Date
ff3917cd2b Do not recalculate layout if text wrapping is disabled 2026-06-02 02:10:19 +02:00
2 changed files with 14 additions and 4 deletions

View File

@@ -108,7 +108,7 @@ public class TestGame : Game
{
Size = new Rect(256.0f, 128.0f),
ClipContents = false,
WrapText = true
WrapText = false
};
// _rootFill.AddChild(_label);

View File

@@ -57,7 +57,17 @@ public class Label : Widget
if (renderer is not RaylibRenderSystem rayRenderer) return; // TODO: Do NOT rely on RaylibRenderSystem check here. Very bad.
renderer.SetTransform(GlobalPosition, Vector2.Zero);
rayRenderer.DrawText(_font, _layout, style.TextColor ?? Color.Black);
var color = style.TextColor ?? Color.Black;
if (WrapText)
{
rayRenderer.DrawText(_font, _layout, color);
}
else
{
rayRenderer.DrawText(_font, _text, color);
}
}
protected override void OnUpdate(LayoutContext layoutContext)
@@ -67,8 +77,8 @@ public class Label : Widget
if (!_font.HasValue)
return;
var width = WrapText ? Size.Width : float.MaxValue;
_layout = _font.Value.Layout(_text, Vector2.Zero, width);
if (!WrapText) return;
_layout = _font.Value.Layout(_text, Vector2.Zero, Size.Width);
}
private void ResolveFont()