Add method enum.
This commit is contained in:
@@ -10,6 +10,22 @@ namespace FlaxEngine.GUI
|
|||||||
/// <seealso cref="FlaxEngine.GUI.Control" />
|
/// <seealso cref="FlaxEngine.GUI.Control" />
|
||||||
public class ProgressBar : ContainerControl
|
public class ProgressBar : ContainerControl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The method used to effect the bar.
|
||||||
|
/// </summary>
|
||||||
|
public enum BarMethod
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Stretch the bar.
|
||||||
|
/// </summary>
|
||||||
|
Stretch,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clip the bar.
|
||||||
|
/// </summary>
|
||||||
|
Clip,
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The direction to move the progress bar
|
/// The direction to move the progress bar
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -28,12 +44,12 @@ namespace FlaxEngine.GUI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Move the bar vertically up.
|
/// Move the bar vertically up.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
VerticalUp,
|
VerticalTop,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Move the bar vertically down.
|
/// Move the bar vertically down.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
VerticalDown,
|
VerticalBottom,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -66,12 +82,12 @@ namespace FlaxEngine.GUI
|
|||||||
/// Gets a value indicating whether use progress value smoothing.
|
/// Gets a value indicating whether use progress value smoothing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseSmoothing => !Mathf.IsZero(SmoothingScale);
|
public bool UseSmoothing => !Mathf.IsZero(SmoothingScale);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true, the progress bar will clip instead of stretch.
|
/// The method used to effect the bar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorOrder(42), Tooltip("Whether or not to clip vs stretch the progress bar.")]
|
[EditorOrder(41), Tooltip("The method used to effect the bar.")]
|
||||||
public bool ClipBar = false;
|
public BarMethod Method = BarMethod.Stretch;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The direction to clip or stretch the bar.
|
/// The direction to clip or stretch the bar.
|
||||||
@@ -214,17 +230,25 @@ namespace FlaxEngine.GUI
|
|||||||
case BarDirection.HorizontalRight:
|
case BarDirection.HorizontalRight:
|
||||||
barRect = new Rectangle(Width - Width * progressNormalized, 0, Width * progressNormalized, Height);
|
barRect = new Rectangle(Width - Width * progressNormalized, 0, Width * progressNormalized, Height);
|
||||||
break;
|
break;
|
||||||
case BarDirection.VerticalUp:
|
case BarDirection.VerticalTop:
|
||||||
barRect = new Rectangle(0, 0, Width, Height * progressNormalized);
|
barRect = new Rectangle(0, 0, Width, Height * progressNormalized);
|
||||||
break;
|
break;
|
||||||
case BarDirection.VerticalDown:
|
case BarDirection.VerticalBottom:
|
||||||
barRect = new Rectangle(0, Height - Height * progressNormalized, Width, Height * progressNormalized);
|
barRect = new Rectangle(0, Height - Height * progressNormalized, Width, Height * progressNormalized);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ClipBar)
|
switch (Method)
|
||||||
{
|
{
|
||||||
|
case BarMethod.Stretch:
|
||||||
|
BarMargin.ShrinkRectangle(ref barRect);
|
||||||
|
if (BarBrush != null)
|
||||||
|
BarBrush.Draw(barRect, BarColor);
|
||||||
|
else
|
||||||
|
Render2D.FillRectangle(barRect, BarColor);
|
||||||
|
break;
|
||||||
|
case BarMethod.Clip:
|
||||||
var rect = new Rectangle(0, 0, Width, Height);
|
var rect = new Rectangle(0, 0, Width, Height);
|
||||||
BarMargin.ShrinkRectangle(ref rect);
|
BarMargin.ShrinkRectangle(ref rect);
|
||||||
Render2D.PushClip(ref barRect);
|
Render2D.PushClip(ref barRect);
|
||||||
@@ -233,14 +257,8 @@ namespace FlaxEngine.GUI
|
|||||||
else
|
else
|
||||||
Render2D.FillRectangle(rect, BarColor);
|
Render2D.FillRectangle(rect, BarColor);
|
||||||
Render2D.PopClip();
|
Render2D.PopClip();
|
||||||
}
|
break;
|
||||||
else
|
default: break;
|
||||||
{
|
|
||||||
BarMargin.ShrinkRectangle(ref barRect);
|
|
||||||
if (BarBrush != null)
|
|
||||||
BarBrush.Draw(barRect, BarColor);
|
|
||||||
else
|
|
||||||
Render2D.FillRectangle(barRect, BarColor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user