Per window DPI

This commit is contained in:
stefnotch
2021-02-07 17:26:41 +01:00
parent 28f53339e7
commit f5b48e03e9
16 changed files with 98 additions and 41 deletions

View File

@@ -310,7 +310,7 @@ namespace FlaxEngine.GUI
/// <summary>
/// Gets the GUI window root control which contains that control (or null if not linked to any).
/// </summary>
public virtual WindowRootControl RootWindow => _parent?.RootWindow;
public virtual WindowRootControl RootWindow => _parent?.RootWindow; // TODO: Why doesn't this just go "_root?.RootWindow" or something?
/// <summary>
/// Gets screen position of the control (upper left corner).

View File

@@ -221,7 +221,7 @@ namespace FlaxEngine.GUI
/// </summary>
public void SyncBackbufferSize()
{
float scale = ResolutionScale * Platform.DpiScale;
float scale = ResolutionScale * (Root?.RootWindow?.Window?.DpiScale ?? 1); // TODO: Figure this out
int width = Mathf.CeilToInt(Width * scale);
int height = Mathf.CeilToInt(Height * scale);
if (_customResolution.HasValue)

View File

@@ -68,7 +68,7 @@ namespace FlaxEngine.GUI
var parentWin = target.Root;
if (parentWin == null)
return;
float dpiScale = Platform.DpiScale;
float dpiScale = target.RootWindow.Window.DpiScale;
Vector2 dpiSize = Size * dpiScale;
Vector2 locationWS = target.PointToWindow(location);
Vector2 locationSS = parentWin.PointToScreen(locationWS);
@@ -185,7 +185,7 @@ namespace FlaxEngine.GUI
{
if (_window)
{
_window.ClientSize = Size * Platform.DpiScale;
_window.ClientSize = Size * _window.DpiScale;
}
}

View File

@@ -151,7 +151,7 @@ namespace FlaxEngine.GUI
}
/// <inheritdoc />
public override Vector2 TrackingMouseOffset => _window.TrackingMouseOffset / _window._dpiScale;
public override Vector2 TrackingMouseOffset => _window.TrackingMouseOffset / _window.DpiScale;
/// <inheritdoc />
public override WindowRootControl RootWindow => this;
@@ -159,8 +159,8 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public override Vector2 MousePosition
{
get => _window.MousePosition / _window._dpiScale;
set => _window.MousePosition = value * _window._dpiScale;
get => _window.MousePosition / _window.DpiScale;
set => _window.MousePosition = value * _window.DpiScale;
}
/// <inheritdoc />
@@ -234,13 +234,13 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public override Vector2 PointFromScreen(Vector2 location)
{
return _window.ScreenToClient(location) / _window._dpiScale;
return _window.ScreenToClient(location) / _window.DpiScale;
}
/// <inheritdoc />
public override Vector2 PointToScreen(Vector2 location)
{
return _window.ClientToScreen(location * _window._dpiScale);
return _window.ClientToScreen(location * _window.DpiScale);
}
/// <inheritdoc />