From 8eed667d5a161c5a60aed7eeb245c367d6f43a7e Mon Sep 17 00:00:00 2001
From: Edu Garcia <28616+Arcnor@users.noreply.github.com>
Date: Thu, 28 Sep 2023 22:41:24 +0100
Subject: [PATCH] Makes BaseLinesGapScale configurable for Label
---
Source/Engine/UI/GUI/Common/Label.cs | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/Source/Engine/UI/GUI/Common/Label.cs b/Source/Engine/UI/GUI/Common/Label.cs
index 2779dfdea..0e2d3c9cf 100644
--- a/Source/Engine/UI/GUI/Common/Label.cs
+++ b/Source/Engine/UI/GUI/Common/Label.cs
@@ -74,10 +74,16 @@ namespace FlaxEngine.GUI
[EditorDisplay("Text Style"), EditorOrder(2022), Tooltip("The text wrapping within the control bounds.")]
public TextWrapping Wrapping { get; set; } = TextWrapping.NoWrap;
+ ///
+ /// Gets or sets the text wrapping within the control bounds.
+ ///
+ [EditorDisplay("Text Style"), EditorOrder(2023), Tooltip("The gap between lines when wrapping and more than a single line is displayed."), Limit(0f)]
+ public float BaseLinesGapScale { get; set; } = 1.0f;
+
///
/// Gets or sets the font.
///
- [EditorDisplay("Text Style"), EditorOrder(2023)]
+ [EditorDisplay("Text Style"), EditorOrder(2024)]
public FontReference Font
{
get => _font;
@@ -99,7 +105,7 @@ namespace FlaxEngine.GUI
///
/// Gets or sets the custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data.
///
- [EditorDisplay("Text Style"), EditorOrder(2024)]
+ [EditorDisplay("Text Style"), EditorOrder(2025)]
public MaterialBase Material { get; set; }
///
@@ -227,7 +233,7 @@ namespace FlaxEngine.GUI
}
}
- Render2D.DrawText(_font.GetFont(), Material, _text, rect, color, hAlignment, wAlignment, Wrapping, 1.0f, scale);
+ Render2D.DrawText(_font.GetFont(), Material, _text, rect, color, hAlignment, wAlignment, Wrapping, BaseLinesGapScale, scale);
if (ClipText)
Render2D.PopClip();
@@ -249,6 +255,7 @@ namespace FlaxEngine.GUI
else if (_autoWidth && !_autoHeight)
layout.Bounds.Size.Y = Height - Margin.Height;
_textSize = font.MeasureText(_text, ref layout);
+ _textSize.Y *= BaseLinesGapScale;
// Check if size is controlled via text
if (_autoWidth || _autoHeight)