Merge branch 'ui' of git://github.com/jb-perrier/FlaxEngine into jb-perrier-ui

This commit is contained in:
Wojtek Figat
2021-03-18 11:09:28 +01:00
9 changed files with 42 additions and 33 deletions

View File

@@ -5,7 +5,7 @@ namespace FlaxEngine.GUI
/// <summary> /// <summary>
/// Border control that draws the border around the control edges (inner and outer sides). /// Border control that draws the border around the control edges (inner and outer sides).
/// </summary> /// </summary>
public class Border : Control public class Border : ContainerControl
{ {
/// <summary> /// <summary>
/// Gets or sets the color used to draw border lines. /// Gets or sets the color used to draw border lines.
@@ -30,9 +30,9 @@ namespace FlaxEngine.GUI
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Draw() public override void DrawSelf()
{ {
base.Draw(); base.DrawSelf();
Render2D.DrawRectangle(new Rectangle(Vector2.Zero, Size), BorderColor, BorderWidth); Render2D.DrawRectangle(new Rectangle(Vector2.Zero, Size), BorderColor, BorderWidth);
} }

View File

@@ -7,7 +7,7 @@ namespace FlaxEngine.GUI
/// <summary> /// <summary>
/// Button control /// Button control
/// </summary> /// </summary>
public class Button : Control public class Button : ContainerControl
{ {
/// <summary> /// <summary>
/// The default height fro the buttons. /// The default height fro the buttons.
@@ -171,7 +171,7 @@ namespace FlaxEngine.GUI
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Draw() public override void DrawSelf()
{ {
// Cache data // Cache data
Rectangle clientRect = new Rectangle(Vector2.Zero, Size); Rectangle clientRect = new Rectangle(Vector2.Zero, Size);

View File

@@ -80,10 +80,10 @@ namespace FlaxEngine.GUI
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Draw() public override void DrawSelf()
{ {
base.Draw(); base.DrawSelf();
if (Brush == null) if (Brush == null)
return; return;

View File

@@ -8,7 +8,7 @@ namespace FlaxEngine.GUI
/// Progress bar control shows visual progress of the action or set of actions. /// Progress bar control shows visual progress of the action or set of actions.
/// </summary> /// </summary>
/// <seealso cref="FlaxEngine.GUI.Control" /> /// <seealso cref="FlaxEngine.GUI.Control" />
public class ProgressBar : Control public class ProgressBar : ContainerControl
{ {
/// <summary> /// <summary>
/// The value. /// The value.
@@ -160,9 +160,9 @@ namespace FlaxEngine.GUI
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Draw() public override void DrawSelf()
{ {
base.Draw(); base.DrawSelf();
float progressNormalized = (_current - _minimum) / _maximum; float progressNormalized = (_current - _minimum) / _maximum;
if (progressNormalized > 0.001f) if (progressNormalized > 0.001f)

View File

@@ -105,7 +105,7 @@ namespace FlaxEngine.GUI
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Draw() public override void DrawSelf()
{ {
// Draw cached texture // Draw cached texture
if (_texture && !_invalid && !_isDuringTextureDraw) if (_texture && !_invalid && !_isDuringTextureDraw)
@@ -119,7 +119,7 @@ namespace FlaxEngine.GUI
} }
// Draw default UI directly // Draw default UI directly
base.Draw(); base.DrawSelf();
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -220,7 +220,7 @@ namespace FlaxEngine.GUI
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Draw() public override void DrawSelf()
{ {
// Cache data // Cache data
var rect = new Rectangle(Vector2.Zero, Size); var rect = new Rectangle(Vector2.Zero, Size);

View File

@@ -132,7 +132,7 @@ namespace FlaxEngine.GUI
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Draw() public override void DrawSelf()
{ {
// Cache data // Cache data
var rect = new Rectangle(Vector2.Zero, Size); var rect = new Rectangle(Vector2.Zero, Size);

View File

@@ -9,7 +9,7 @@ namespace FlaxEngine.GUI
/// <summary> /// <summary>
/// Base class for all text box controls which can gather text input from the user. /// Base class for all text box controls which can gather text input from the user.
/// </summary> /// </summary>
public abstract class TextBoxBase : Control public abstract class TextBoxBase : ContainerControl
{ {
/// <summary> /// <summary>
/// The text separators (used for words skipping). /// The text separators (used for words skipping).

View File

@@ -616,32 +616,35 @@ namespace FlaxEngine.GUI
} }
} }
/// <inheritdoc /> /// <summary>
/// Draw the control and the children.
/// </summary>
public override void Draw() public override void Draw()
{ {
base.Draw(); DrawSelf();
DrawChildren();
}
/// <summary>
/// Draws the control.
/// </summary>
public virtual void DrawSelf()
{
base.Draw();
}
/// <summary>
/// Draws the children. Can be overridden to provide some customizations. Draw is performed with applied clipping mask for the client area.
/// </summary>
protected virtual void DrawChildren()
{
// Push clipping mask // Push clipping mask
if (ClipChildren) if (ClipChildren)
{ {
GetDesireClientArea(out var clientArea); GetDesireClientArea(out var clientArea);
Render2D.PushClip(ref clientArea); Render2D.PushClip(ref clientArea);
} }
DrawChildren();
// Pop clipping mask
if (ClipChildren)
{
Render2D.PopClip();
}
}
/// <summary>
/// Draws the children. Can be overridden to provide some customizations. Draw is performed with applied clipping mask for the client area.
/// </summary>
protected virtual void DrawChildren()
{
// Draw all visible child controls // Draw all visible child controls
if (CullChildren) if (CullChildren)
{ {
@@ -676,6 +679,12 @@ namespace FlaxEngine.GUI
} }
} }
} }
// Pop clipping mask
if (ClipChildren)
{
Render2D.PopClip();
}
} }
/// <inheritdoc /> /// <inheritdoc />