diff --git a/Source/Engine/UI/GUI/Common/Border.cs b/Source/Engine/UI/GUI/Common/Border.cs
index 543735e99..fb699b132 100644
--- a/Source/Engine/UI/GUI/Common/Border.cs
+++ b/Source/Engine/UI/GUI/Common/Border.cs
@@ -5,7 +5,7 @@ namespace FlaxEngine.GUI
///
/// Border control that draws the border around the control edges (inner and outer sides).
///
- public class Border : Control
+ public class Border : ContainerControl
{
///
/// Gets or sets the color used to draw border lines.
@@ -30,9 +30,9 @@ namespace FlaxEngine.GUI
}
///
- public override void Draw()
+ public override void DrawSelf()
{
- base.Draw();
+ base.DrawSelf();
Render2D.DrawRectangle(new Rectangle(Vector2.Zero, Size), BorderColor, BorderWidth);
}
diff --git a/Source/Engine/UI/GUI/Common/Button.cs b/Source/Engine/UI/GUI/Common/Button.cs
index 9d56a4a36..639552ec3 100644
--- a/Source/Engine/UI/GUI/Common/Button.cs
+++ b/Source/Engine/UI/GUI/Common/Button.cs
@@ -7,7 +7,7 @@ namespace FlaxEngine.GUI
///
/// Button control
///
- public class Button : Control
+ public class Button : ContainerControl
{
///
/// The default height fro the buttons.
@@ -171,7 +171,7 @@ namespace FlaxEngine.GUI
}
///
- public override void Draw()
+ public override void DrawSelf()
{
// Cache data
Rectangle clientRect = new Rectangle(Vector2.Zero, Size);
diff --git a/Source/Engine/UI/GUI/Common/Image.cs b/Source/Engine/UI/GUI/Common/Image.cs
index b94b285b6..adeddce6b 100644
--- a/Source/Engine/UI/GUI/Common/Image.cs
+++ b/Source/Engine/UI/GUI/Common/Image.cs
@@ -80,10 +80,10 @@ namespace FlaxEngine.GUI
}
///
- public override void Draw()
+ public override void DrawSelf()
{
- base.Draw();
-
+ base.DrawSelf();
+
if (Brush == null)
return;
diff --git a/Source/Engine/UI/GUI/Common/ProgressBar.cs b/Source/Engine/UI/GUI/Common/ProgressBar.cs
index f68336d24..21cce7faa 100644
--- a/Source/Engine/UI/GUI/Common/ProgressBar.cs
+++ b/Source/Engine/UI/GUI/Common/ProgressBar.cs
@@ -8,7 +8,7 @@ namespace FlaxEngine.GUI
/// Progress bar control shows visual progress of the action or set of actions.
///
///
- public class ProgressBar : Control
+ public class ProgressBar : ContainerControl
{
///
/// The value.
@@ -160,9 +160,9 @@ namespace FlaxEngine.GUI
}
///
- public override void Draw()
+ public override void DrawSelf()
{
- base.Draw();
+ base.DrawSelf();
float progressNormalized = (_current - _minimum) / _maximum;
if (progressNormalized > 0.001f)
diff --git a/Source/Engine/UI/GUI/Common/RenderToTextureControl.cs b/Source/Engine/UI/GUI/Common/RenderToTextureControl.cs
index 526390dac..3894c3027 100644
--- a/Source/Engine/UI/GUI/Common/RenderToTextureControl.cs
+++ b/Source/Engine/UI/GUI/Common/RenderToTextureControl.cs
@@ -105,7 +105,7 @@ namespace FlaxEngine.GUI
}
///
- public override void Draw()
+ public override void DrawSelf()
{
// Draw cached texture
if (_texture && !_invalid && !_isDuringTextureDraw)
@@ -119,7 +119,7 @@ namespace FlaxEngine.GUI
}
// Draw default UI directly
- base.Draw();
+ base.DrawSelf();
}
///
diff --git a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs
index 0ef44594b..1a57061e1 100644
--- a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs
+++ b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs
@@ -220,7 +220,7 @@ namespace FlaxEngine.GUI
}
///
- public override void Draw()
+ public override void DrawSelf()
{
// Cache data
var rect = new Rectangle(Vector2.Zero, Size);
diff --git a/Source/Engine/UI/GUI/Common/TextBox.cs b/Source/Engine/UI/GUI/Common/TextBox.cs
index 0a6f11660..0ed5c731c 100644
--- a/Source/Engine/UI/GUI/Common/TextBox.cs
+++ b/Source/Engine/UI/GUI/Common/TextBox.cs
@@ -132,7 +132,7 @@ namespace FlaxEngine.GUI
}
///
- public override void Draw()
+ public override void DrawSelf()
{
// Cache data
var rect = new Rectangle(Vector2.Zero, Size);
diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs
index 21187f594..5541ee3e5 100644
--- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs
+++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs
@@ -9,7 +9,7 @@ namespace FlaxEngine.GUI
///
/// Base class for all text box controls which can gather text input from the user.
///
- public abstract class TextBoxBase : Control
+ public abstract class TextBoxBase : ContainerControl
{
///
/// The text separators (used for words skipping).
diff --git a/Source/Engine/UI/GUI/ContainerControl.cs b/Source/Engine/UI/GUI/ContainerControl.cs
index 817bc28a5..8e046ecde 100644
--- a/Source/Engine/UI/GUI/ContainerControl.cs
+++ b/Source/Engine/UI/GUI/ContainerControl.cs
@@ -616,32 +616,35 @@ namespace FlaxEngine.GUI
}
}
- ///
+ ///
+ /// Draw the control and the children.
+ ///
public override void Draw()
{
- base.Draw();
+ DrawSelf();
+ DrawChildren();
+ }
+ ///
+ /// Draws the control.
+ ///
+ public virtual void DrawSelf()
+ {
+ base.Draw();
+ }
+
+ ///
+ /// Draws the children. Can be overridden to provide some customizations. Draw is performed with applied clipping mask for the client area.
+ ///
+ protected virtual void DrawChildren()
+ {
// Push clipping mask
if (ClipChildren)
{
GetDesireClientArea(out var clientArea);
Render2D.PushClip(ref clientArea);
}
-
- DrawChildren();
-
- // Pop clipping mask
- if (ClipChildren)
- {
- Render2D.PopClip();
- }
- }
-
- ///
- /// Draws the children. Can be overridden to provide some customizations. Draw is performed with applied clipping mask for the client area.
- ///
- protected virtual void DrawChildren()
- {
+
// Draw all visible child controls
if (CullChildren)
{
@@ -676,6 +679,12 @@ namespace FlaxEngine.GUI
}
}
}
+
+ // Pop clipping mask
+ if (ClipChildren)
+ {
+ Render2D.PopClip();
+ }
}
///