From c5405183c9aaa1d84a6b62733100058c578394f4 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 1 Jun 2021 12:14:04 +0200 Subject: [PATCH] Fix tooltips to be constrained by monitor bounds instead of virtual desktop or parent window bounds #470 #540 --- Source/Engine/UI/GUI/Tooltip.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/Engine/UI/GUI/Tooltip.cs b/Source/Engine/UI/GUI/Tooltip.cs index 4541124e7..e6690c82d 100644 --- a/Source/Engine/UI/GUI/Tooltip.cs +++ b/Source/Engine/UI/GUI/Tooltip.cs @@ -72,19 +72,17 @@ namespace FlaxEngine.GUI Vector2 dpiSize = Size * dpiScale; Vector2 locationWS = target.PointToWindow(location); Vector2 locationSS = parentWin.PointToScreen(locationWS); - Vector2 screenSize = Platform.VirtualDesktopSize; - Vector2 parentWinLocationSS = parentWin.PointToScreen(Vector2.Zero); - float parentWinRightSS = parentWinLocationSS.Y + parentWin.Size.Y; - float parentWinBottomSS = parentWinLocationSS.X + parentWin.Size.X; + Rectangle monitorBounds = Platform.GetMonitorBounds(locationSS); + Vector2 rightBottomMonitorBounds = monitorBounds.BottomRight; Vector2 rightBottomLocationSS = locationSS + dpiSize; // Prioritize tooltip placement within parent window, fall back to virtual desktop - if (parentWinRightSS < rightBottomLocationSS.Y || screenSize.Y < rightBottomLocationSS.Y) + if (rightBottomMonitorBounds.Y < rightBottomLocationSS.Y) { // Direction: up locationSS.Y -= dpiSize.Y; } - if (parentWinBottomSS < rightBottomLocationSS.X || screenSize.X < rightBottomLocationSS.X) + if (rightBottomMonitorBounds.X < rightBottomLocationSS.X) { // Direction: left locationSS.X -= dpiSize.X;