Merge branch 'move-child-menu-arrow-for-scrollbar' of https://github.com/Tryibion/FlaxEngine into Tryibion-move-child-menu-arrow-for-scrollbar
This commit is contained in:
@@ -365,6 +365,7 @@ namespace FlaxEditor.GUI.ContextMenu
|
|||||||
float maxWidth = 0;
|
float maxWidth = 0;
|
||||||
float height = _itemsAreaMargin.Height;
|
float height = _itemsAreaMargin.Height;
|
||||||
int itemsLeft = MaximumItemsInViewCount;
|
int itemsLeft = MaximumItemsInViewCount;
|
||||||
|
int overflowItemCount = 0;
|
||||||
for (int i = 0; i < _panel.Children.Count; i++)
|
for (int i = 0; i < _panel.Children.Count; i++)
|
||||||
{
|
{
|
||||||
if (_panel.Children[i] is ContextMenuItem item && item.Visible)
|
if (_panel.Children[i] is ContextMenuItem item && item.Visible)
|
||||||
@@ -374,11 +375,27 @@ namespace FlaxEditor.GUI.ContextMenu
|
|||||||
height += item.Height + _itemsMargin.Height;
|
height += item.Height + _itemsMargin.Height;
|
||||||
itemsLeft--;
|
itemsLeft--;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
overflowItemCount++;
|
||||||
|
}
|
||||||
maxWidth = Mathf.Max(maxWidth, item.MinimumWidth);
|
maxWidth = Mathf.Max(maxWidth, item.MinimumWidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maxWidth = Mathf.Max(maxWidth + 20, MinimumWidth);
|
maxWidth = Mathf.Max(maxWidth + 20, MinimumWidth);
|
||||||
|
|
||||||
|
// Move child arrows to accommodate scroll bar showing
|
||||||
|
if (overflowItemCount > 0)
|
||||||
|
{
|
||||||
|
foreach (var child in _panel.Children)
|
||||||
|
{
|
||||||
|
if (child is ContextMenuChildMenu item && item.Visible)
|
||||||
|
{
|
||||||
|
item.AdjustArrowAmount = -_panel.VScrollBar.Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Resize container
|
// Resize container
|
||||||
Size = new Float2(Mathf.Ceil(maxWidth), Mathf.Ceil(height));
|
Size = new Float2(Mathf.Ceil(maxWidth), Mathf.Ceil(height));
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ namespace FlaxEditor.GUI.ContextMenu
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly ContextMenu ContextMenu = new ContextMenu();
|
public readonly ContextMenu ContextMenu = new ContextMenu();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount to adjust the arrow image by in x coordinates.
|
||||||
|
/// </summary>
|
||||||
|
public float AdjustArrowAmount = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ContextMenuChildMenu"/> class.
|
/// Initializes a new instance of the <see cref="ContextMenuChildMenu"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -44,7 +49,7 @@ namespace FlaxEditor.GUI.ContextMenu
|
|||||||
|
|
||||||
// Draw arrow
|
// Draw arrow
|
||||||
if (ContextMenu.HasChildren)
|
if (ContextMenu.HasChildren)
|
||||||
Render2D.DrawSprite(style.ArrowRight, new Rectangle(Width - 15, (Height - 12) / 2, 12, 12), Enabled ? isCMopened ? style.BackgroundSelected : style.Foreground : style.ForegroundDisabled);
|
Render2D.DrawSprite(style.ArrowRight, new Rectangle(Width - 15 + AdjustArrowAmount, (Height - 12) / 2, 12, 12), Enabled ? isCMopened ? style.BackgroundSelected : style.Foreground : style.ForegroundDisabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user