Browse Source

Adds RenderScaling and DesktopScaling back to the public API together with ScalingChanged

pull/11124/head
Max Katz 3 years ago
parent
commit
decf80cb77
  1. 8
      src/Avalonia.Controls/TopLevel.cs
  2. 5
      src/Avalonia.Controls/WindowBase.cs

8
src/Avalonia.Controls/TopLevel.cs

@ -285,6 +285,11 @@ namespace Avalonia.Controls
/// </summary>
public event EventHandler? Closed;
/// <summary>
/// Gets or sets a method called when the TopLevel's scaling changes.
/// </summary>
public event EventHandler? ScalingChanged;
/// <summary>
/// Gets or sets the client size of the window.
/// </summary>
@ -428,7 +433,7 @@ namespace Avalonia.Controls
double ILayoutRoot.LayoutScaling => PlatformImpl?.RenderScaling ?? 1;
/// <inheritdoc/>
double IRenderRoot.RenderScaling => PlatformImpl?.RenderScaling ?? 1;
public double RenderScaling => PlatformImpl?.RenderScaling ?? 1;
IStyleHost IStyleHost.StylingParent => _globalStyles!;
@ -590,6 +595,7 @@ namespace Avalonia.Controls
protected virtual void HandleScalingChanged(double scaling)
{
LayoutHelper.InvalidateSelfAndChildrenMeasure(this);
ScalingChanged?.Invoke(this, EventArgs.Empty);
}
private static bool TransparencyLevelsMatch (WindowTransparencyLevel requested, WindowTransparencyLevel received)

5
src/Avalonia.Controls/WindowBase.cs

@ -116,6 +116,11 @@ namespace Avalonia.Controls
set { SetValue(TopmostProperty, value); }
}
/// <summary>
/// Gets the scaling factor for Window positioning and sizing.
/// </summary>
public double DesktopScaling => PlatformImpl?.DesktopScaling ?? 1;
/// <summary>
/// Activates the window.
/// </summary>

Loading…
Cancel
Save