Fix custom context menu popup showing as child (eg. prefab diff)

This commit is contained in:
Wojtek Figat
2024-02-26 22:13:50 +01:00
parent 470c108ed9
commit 6905382310

View File

@@ -168,30 +168,30 @@ namespace FlaxEditor.GUI.ContextMenu
bool isUp = false, isLeft = false;
if (UseAutomaticDirectionFix)
{
var parentMenu = parent as ContextMenu;
if (monitorBounds.Bottom < rightBottomLocationSS.Y)
{
// Direction: up
isUp = true;
locationSS.Y -= dpiSize.Y;
// Offset to fix sub-menu location
if (parent is ContextMenu menu && menu._childCM != null)
if (parentMenu != null && parentMenu._childCM != null)
locationSS.Y += 30.0f * dpiScale;
}
if (monitorBounds.Right < rightBottomLocationSS.X || _parentCM?.Direction == ContextMenuDirection.LeftDown || _parentCM?.Direction == ContextMenuDirection.LeftUp)
if (parentMenu == null)
{
// Direction: left
isLeft = true;
if (IsSubMenu && _parentCM != null)
{
locationSS.X -= _parentCM.Width + dpiSize.X;
}
else
if (monitorBounds.Right < rightBottomLocationSS.X)
{
isLeft = true;
locationSS.X -= dpiSize.X;
}
}
else if (monitorBounds.Right < rightBottomLocationSS.X || _parentCM?.Direction == ContextMenuDirection.LeftDown || _parentCM?.Direction == ContextMenuDirection.LeftUp)
{
isLeft = true;
if (IsSubMenu && _parentCM != null)
locationSS.X -= _parentCM.Width + dpiSize.X;
else
locationSS.X -= dpiSize.X;
}
}
// Update direction flag