Add styling brush for progress bar

This commit is contained in:
Wojtek Figat
2021-07-14 12:27:14 +02:00
parent d7cca59315
commit 5b595eb056
2 changed files with 11 additions and 2 deletions

View File

@@ -74,7 +74,7 @@ namespace FlaxEngine.GUI
/// <summary>
/// Gets or sets the brush used for background drawing.
/// </summary>
[EditorOrder(2000), Tooltip("The brush used for background drawing.")]
[EditorDisplay("Style"), EditorOrder(2000), Tooltip("The brush used for background drawing.")]
public IBrush BackgroundBrush { get; set; }
/// <summary>

View File

@@ -108,6 +108,12 @@ namespace FlaxEngine.GUI
[EditorDisplay("Style"), EditorOrder(2000), Tooltip("The color of the progress bar rectangle.")]
public Color BarColor { get; set; }
/// <summary>
/// Gets or sets the brush used for progress bar drawing.
/// </summary>
[EditorDisplay("Style"), EditorOrder(2000), Tooltip("The brush used for progress bar drawing.")]
public IBrush BarBrush { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ProgressBar"/> class.
/// </summary>
@@ -164,7 +170,10 @@ namespace FlaxEngine.GUI
{
var barRect = new Rectangle(0, 0, Width * progressNormalized, Height);
BarMargin.ShrinkRectangle(ref barRect);
Render2D.FillRectangle(barRect, BarColor);
if (BarBrush != null)
BarBrush.Draw(barRect, BarColor);
else
Render2D.FillRectangle(barRect, BarColor);
}
}
}