diff --git a/TestGame/TestGame.cs b/TestGame/TestGame.cs index b55255b..9e6ced5 100644 --- a/TestGame/TestGame.cs +++ b/TestGame/TestGame.cs @@ -108,7 +108,7 @@ public class TestGame : Game { Size = new Rect(256.0f, 128.0f), ClipContents = false, - WrapText = true + WrapText = false }; // _rootFill.AddChild(_label); diff --git a/Voile/Source/UI/Widgets/Label.cs b/Voile/Source/UI/Widgets/Label.cs index 8171dea..5865064 100644 --- a/Voile/Source/UI/Widgets/Label.cs +++ b/Voile/Source/UI/Widgets/Label.cs @@ -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()