Add support for custom background brush to Button

This commit is contained in:
Wojtek Figat
2021-07-14 12:21:38 +02:00
parent a7cb12f597
commit d7cca59315

View File

@@ -71,6 +71,12 @@ namespace FlaxEngine.GUI
/// </summary>
public event Action<Button> ButtonClicked;
/// <summary>
/// Gets or sets the brush used for background drawing.
/// </summary>
[EditorOrder(2000), Tooltip("The brush used for background drawing.")]
public IBrush BackgroundBrush { get; set; }
/// <summary>
/// Gets or sets the color of the border.
/// </summary>
@@ -206,7 +212,10 @@ namespace FlaxEngine.GUI
}
// Draw background
Render2D.FillRectangle(clientRect, backgroundColor);
if (BackgroundBrush != null)
BackgroundBrush.Draw(clientRect, backgroundColor);
else
Render2D.FillRectangle(clientRect, backgroundColor);
Render2D.DrawRectangle(clientRect, borderColor);
// Draw text