Fix margins issues in context menus

This commit is contained in:
Wojtek Figat
2024-04-18 15:26:52 +02:00
parent 695c212cf0
commit 285710360c
2 changed files with 17 additions and 10 deletions

View File

@@ -29,6 +29,15 @@ namespace FlaxEditor.GUI.ContextMenu
CloseMenuOnClick = false;
}
private void ShowChild(ContextMenu parentContextMenu)
{
// Hide parent CM popups and set itself as child
var vAlign = parentContextMenu.ItemsAreaMargin.Top;
var location = new Float2(Width, -vAlign);
location = PointToParent(parentContextMenu, location);
parentContextMenu.ShowChild(ContextMenu, location);
}
/// <inheritdoc />
public override void Draw()
{
@@ -58,14 +67,12 @@ namespace FlaxEditor.GUI.ContextMenu
var parentContextMenu = ParentContextMenu;
if (parentContextMenu == ContextMenu)
return;
if (ContextMenu.IsOpened)
return;
base.OnMouseEnter(location);
// Hide parent CM popups and set itself as child
parentContextMenu.ShowChild(ContextMenu, PointToParent(ParentContextMenu, new Float2(Width, 0)));
ShowChild(parentContextMenu);
}
/// <inheritdoc />
@@ -78,8 +85,7 @@ namespace FlaxEditor.GUI.ContextMenu
if (ContextMenu.IsOpened)
return true;
// Hide parent CM popups and set itself as child
parentContextMenu.ShowChild(ContextMenu, PointToParent(ParentContextMenu, new Float2(Width, 0)));
ShowChild(parentContextMenu);
return base.OnMouseUp(location, button);
}
}