diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuButton.cs b/Source/Editor/GUI/ContextMenu/ContextMenuButton.cs
index dc48cae73..d4d224272 100644
--- a/Source/Editor/GUI/ContextMenu/ContextMenuButton.cs
+++ b/Source/Editor/GUI/ContextMenu/ContextMenuButton.cs
@@ -108,7 +108,6 @@ namespace FlaxEditor.GUI.ContextMenu
///
public override void Draw()
{
- // Cache data
var style = Style.Current;
var backgroundRect = new Rectangle(-X + 3, 0, Parent.Width - 6, Height);
var textRect = new Rectangle(0, 0, Width - 8, Height);
@@ -228,15 +227,11 @@ namespace FlaxEditor.GUI.ContextMenu
{
var style = Style.Current;
float width = 20;
-
if (style.FontMedium)
{
width += style.FontMedium.MeasureText(Text).X;
-
- if (ShortKeys.Length > 0)
- {
+ if (!string.IsNullOrEmpty(ShortKeys))
width += 40 + style.FontMedium.MeasureText(ShortKeys).X;
- }
}
return Mathf.Max(width, base.MinimumWidth);
diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs b/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs
index 690d904c1..bb12dc955 100644
--- a/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs
+++ b/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs
@@ -10,13 +10,8 @@ namespace FlaxEditor.GUI.ContextMenu
///
///
[HideInEditor]
- public class ContextMenuChildMenu : ContextMenuItem
+ public class ContextMenuChildMenu : ContextMenuButton
{
- ///
- /// The item text.
- ///
- public string Text;
-
///
/// The child context menu.
///
@@ -28,7 +23,7 @@ namespace FlaxEditor.GUI.ContextMenu
/// The parent context menu.
/// The text.
public ContextMenuChildMenu(ContextMenu parent, string text)
- : base(parent, 8, 22)
+ : base(parent, text)
{
Text = text;
}
@@ -36,21 +31,16 @@ namespace FlaxEditor.GUI.ContextMenu
///
public override void Draw()
{
- // Cache data
var style = Style.Current;
var backgroundRect = new Rectangle(-X + 3, 0, Parent.Width - 6, Height);
- var clientRect = new Rectangle(Vector2.Zero, Size);
bool isCMopened = ContextMenu.IsOpened;
// Draw background
- if (isCMopened || (IsMouseOver && Enabled))
+ if (isCMopened)
Render2D.FillRectangle(backgroundRect, style.LightBackground);
base.Draw();
- // Draw text
- Render2D.DrawText(style.FontMedium, Text, clientRect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
-
// Draw arrow
if (ContextMenu.HasChildren)
Render2D.DrawSprite(style.ArrowRight, new Rectangle(Width - 15, (Height - 12) / 2, 12, 12), Enabled ? isCMopened ? style.BackgroundSelected : style.Foreground : style.ForegroundDisabled);
@@ -73,22 +63,5 @@ namespace FlaxEditor.GUI.ContextMenu
// Hide parent CM popups and set itself as child
parentContextMenu.ShowChild(ContextMenu, PointToParent(ParentContextMenu, new Vector2(Width, 0)));
}
-
- ///
- public override float MinimumWidth
- {
- get
- {
- var style = Style.Current;
- float width = 16;
-
- if (style.FontMedium)
- {
- width += style.FontMedium.MeasureText(Text).X;
- }
-
- return Mathf.Max(width, base.MinimumWidth);
- }
- }
}
}