@@ -47,6 +47,11 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
private Window _window;
|
||||
private Control _previouslyFocused;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether use automatic popup direction fix based on the screen dimensions.
|
||||
/// </summary>
|
||||
protected virtual bool UseAutomaticDirectionFix => true;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if context menu is opened
|
||||
/// </summary>
|
||||
@@ -132,21 +137,24 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
Rectangle monitorBounds = Platform.GetMonitorBounds(locationSS);
|
||||
Vector2 rightBottomLocationSS = locationSS + dpiSize;
|
||||
bool isUp = false, isLeft = false;
|
||||
if (monitorBounds.Bottom < rightBottomLocationSS.Y)
|
||||
if (UseAutomaticDirectionFix)
|
||||
{
|
||||
// Direction: up
|
||||
isUp = true;
|
||||
locationSS.Y -= dpiSize.Y;
|
||||
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)
|
||||
locationSS.Y += 30.0f * dpiScale;
|
||||
}
|
||||
if (monitorBounds.Right < rightBottomLocationSS.X)
|
||||
{
|
||||
// Direction: left
|
||||
isLeft = true;
|
||||
locationSS.X -= dpiSize.X;
|
||||
// Offset to fix sub-menu location
|
||||
if (parent is ContextMenu menu && menu._childCM != null)
|
||||
locationSS.Y += 30.0f * dpiScale;
|
||||
}
|
||||
if (monitorBounds.Right < rightBottomLocationSS.X)
|
||||
{
|
||||
// Direction: left
|
||||
isLeft = true;
|
||||
locationSS.X -= dpiSize.X;
|
||||
}
|
||||
}
|
||||
|
||||
// Update direction flag
|
||||
|
||||
Reference in New Issue
Block a user