diff --git a/Source/Editor/Content/Items/AssetItem.cs b/Source/Editor/Content/Items/AssetItem.cs index 437c556fc..ab9984016 100644 --- a/Source/Editor/Content/Items/AssetItem.cs +++ b/Source/Editor/Content/Items/AssetItem.cs @@ -58,7 +58,7 @@ namespace FlaxEditor.Content public override bool OnMouseDoubleClick(Vector2 location, MouseButton button) { - return Item.OnMouseDoubleClick(Item.ScreenToClient(ClientToScreen(location)), button); + return Item.OnMouseDoubleClick(Item.PointFromScreen(PointToScreen(location)), button); } } diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index 816035858..2f1c871e3 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -1203,7 +1203,7 @@ namespace FlaxEditor var win = Windows.GameWin.Root; if (win != null && win.RootWindow is WindowRootControl root && root.Window.IsFocused) { - pos = Vector2.Round(Windows.GameWin.Viewport.PointFromWindow(root.ScreenToClient(pos))); + pos = Vector2.Round(Windows.GameWin.Viewport.PointFromWindow(root.Window.ScreenToClient(pos))); } else { diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs index 615be2d5b..2c3846f82 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs @@ -114,7 +114,7 @@ namespace FlaxEditor.GUI.ContextMenu // Check if show menu inside the other menu - then link as a child to prevent closing the calling menu window on lost focus if (_parentCM == null && parentWin.ChildrenCount == 1 && parentWin.Children[0] is ContextMenuBase parentCM) { - parentCM.ShowChild(this, parentCM.ScreenToClient(parent.ClientToScreen(location)), false); + parentCM.ShowChild(this, parentCM.PointFromScreen(parent.PointToScreen(location)), false); return; } @@ -126,7 +126,7 @@ namespace FlaxEditor.GUI.ContextMenu var dpiScale = Platform.DpiScale; Vector2 dpiSize = Size * dpiScale; Vector2 locationWS = parent.PointToWindow(location); - Vector2 locationSS = parentWin.ClientToScreen(locationWS * dpiScale); + Vector2 locationSS = parentWin.PointToScreen(locationWS); Location = Vector2.Zero; Rectangle monitorBounds = Platform.GetMonitorBounds(locationSS); Vector2 rightBottomLocationSS = locationSS + dpiSize; @@ -303,7 +303,7 @@ namespace FlaxEditor.GUI.ContextMenu if (_parentCM != null) { // Focus parent if user clicked over the parent popup - var mouse = _parentCM.ScreenToClient(FlaxEngine.Input.MouseScreenPosition); + var mouse = _parentCM.PointFromScreen(FlaxEngine.Input.MouseScreenPosition); if (_parentCM.ContainsPoint(ref mouse)) { _parentCM._window.Focus(); diff --git a/Source/Editor/GUI/Docking/DockPanel.cs b/Source/Editor/GUI/Docking/DockPanel.cs index 5641639ec..c784a0327 100644 --- a/Source/Editor/GUI/Docking/DockPanel.cs +++ b/Source/Editor/GUI/Docking/DockPanel.cs @@ -125,7 +125,7 @@ namespace FlaxEditor.GUI.Docking var control = _tabsProxy != null ? (Control)_tabsProxy : this; var dpiScale = Platform.DpiScale; var clientPos = control.PointToWindow(Vector2.Zero); - return new Rectangle(parentWin.ClientToScreen(clientPos * dpiScale), control.Size * dpiScale); + return new Rectangle(parentWin.PointToScreen(clientPos), control.Size * dpiScale); } } @@ -310,7 +310,7 @@ namespace FlaxEditor.GUI.Docking var parentWin = Root; if (parentWin == null) return null; - Vector2 clientPos = parentWin.ScreenToClient(position); + Vector2 clientPos = parentWin.PointFromScreen(position); Vector2 localPos = PointFromWindow(clientPos); // Early out diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index e72d3bf04..e3417e921 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -359,13 +359,13 @@ namespace FlaxEditor.Modules // Place dialog nearby the target control if (targetControl != null) { - var targetControlDesktopCenter = targetControl.ClientToScreen(targetControl.Size * 0.5f); + var targetControlDesktopCenter = targetControl.PointToScreen(targetControl.Size * 0.5f); var desktopSize = Platform.GetMonitorBounds(targetControlDesktopCenter); var pos = targetControlDesktopCenter + new Vector2(10.0f, -dialog.Height * 0.5f); var dialogEnd = pos + dialog.Size; var desktopEnd = desktopSize.BottomRight - new Vector2(10.0f); if (dialogEnd.X >= desktopEnd.X || dialogEnd.Y >= desktopEnd.Y) - pos = targetControl.ClientToScreen(Vector2.Zero) - new Vector2(10.0f + dialog.Width, dialog.Height); + pos = targetControl.PointToScreen(Vector2.Zero) - new Vector2(10.0f + dialog.Width, dialog.Height); var desktopBounds = Platform.VirtualDesktopBounds; pos = Vector2.Clamp(pos, desktopBounds.UpperLeft, desktopBounds.BottomRight - dialog.Size); dialog.RootWindow.Window.Position = pos; diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs index edf4eeaa4..dc87a7737 100644 --- a/Source/Engine/UI/GUI/Control.cs +++ b/Source/Engine/UI/GUI/Control.cs @@ -323,7 +323,7 @@ namespace FlaxEngine.GUI if (parentWin == null) throw new InvalidOperationException("Missing parent window."); var clientPos = PointToWindow(Vector2.Zero); - return parentWin.ClientToScreen(clientPos); + return parentWin.PointToScreen(clientPos); } } @@ -1113,12 +1113,12 @@ namespace FlaxEngine.GUI /// /// Input location of the point to convert /// Converted point location in screen coordinates - public virtual Vector2 ClientToScreen(Vector2 location) + public virtual Vector2 PointToScreen(Vector2 location) { location = PointToParent(ref location); if (_parent != null) { - location = _parent.ClientToScreen(location); + location = _parent.PointToScreen(location); } return location; } @@ -1128,11 +1128,11 @@ namespace FlaxEngine.GUI /// /// Input location of the point to convert /// Converted point location in local control's space - public virtual Vector2 ScreenToClient(Vector2 location) + public virtual Vector2 PointFromScreen(Vector2 location) { if (_parent != null) { - location = _parent.ScreenToClient(location); + location = _parent.PointFromScreen(location); } return PointFromParent(ref location); } diff --git a/Source/Engine/UI/GUI/Tooltip.cs b/Source/Engine/UI/GUI/Tooltip.cs index d0f78227d..29708b540 100644 --- a/Source/Engine/UI/GUI/Tooltip.cs +++ b/Source/Engine/UI/GUI/Tooltip.cs @@ -71,7 +71,7 @@ namespace FlaxEngine.GUI float dpiScale = Platform.DpiScale; Vector2 dpiSize = Size * dpiScale; Vector2 locationWS = target.PointToWindow(location); - Vector2 locationSS = parentWin.ClientToScreen(locationWS * dpiScale); + Vector2 locationSS = parentWin.PointToScreen(locationWS); Vector2 screenSize = Platform.VirtualDesktopSize; Vector2 rightBottomLocationSS = locationSS + dpiSize; if (screenSize.Y < rightBottomLocationSS.Y) @@ -194,7 +194,7 @@ namespace FlaxEngine.GUI { // Auto hide if mouse leaves control area Vector2 mousePos = Input.MouseScreenPosition; - Vector2 location = _showTarget.ScreenToClient(mousePos); + Vector2 location = _showTarget.PointFromScreen(mousePos); if (!_showTarget.OnTestTooltipOverControl(ref location)) { // Mouse left or sth diff --git a/Source/Engine/UI/GUI/WindowRootControl.cs b/Source/Engine/UI/GUI/WindowRootControl.cs index eb4e1b85c..03191292f 100644 --- a/Source/Engine/UI/GUI/WindowRootControl.cs +++ b/Source/Engine/UI/GUI/WindowRootControl.cs @@ -232,15 +232,15 @@ namespace FlaxEngine.GUI } /// - public override Vector2 ScreenToClient(Vector2 location) + public override Vector2 PointFromScreen(Vector2 location) { - return _window.ScreenToClient(location) / Platform.DpiScale; + return _window.ScreenToClient(location) / _window._dpiScale; } /// - public override Vector2 ClientToScreen(Vector2 location) + public override Vector2 PointToScreen(Vector2 location) { - return _window.ClientToScreen(location); + return _window.ClientToScreen(location * _window._dpiScale); } ///