Add text alignment options to Button

This commit is contained in:
Wojtek Figat
2024-08-07 17:44:47 +02:00
parent 28ce224caa
commit 1c02f3d8fe

View File

@@ -62,6 +62,18 @@ namespace FlaxEngine.GUI
[EditorDisplay("Text Style"), EditorOrder(2020)]
public Color TextColor;
/// <summary>
/// Gets or sets the horizontal text alignment within the control bounds.
/// </summary>
[EditorDisplay("Text Style"), EditorOrder(2027)]
public TextAlignment HorizontalAlignment { get; set; } = TextAlignment.Center;
/// <summary>
/// Gets or sets the vertical text alignment within the control bounds.
/// </summary>
[EditorDisplay("Text Style"), EditorOrder(2028)]
public TextAlignment VerticalAlignment { get; set; } = TextAlignment.Center;
/// <summary>
/// Gets or sets the brush used for background drawing.
/// </summary>
@@ -262,7 +274,7 @@ namespace FlaxEngine.GUI
Render2D.DrawRectangle(clientRect, borderColor, BorderThickness);
// Draw text
Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, HorizontalAlignment, VerticalAlignment);
}
/// <inheritdoc />