Browse Source

Pass shadow extents to the platform (#21385)

pull/21394/head
Nikita Tsukanov 4 months ago
committed by GitHub
parent
commit
b44cf368a2
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      src/Avalonia.Controls/Platform/IWindowImpl.cs
  2. 4
      src/Avalonia.Controls/Window.cs

8
src/Avalonia.Controls/Platform/IWindowImpl.cs

@ -172,5 +172,13 @@ namespace Avalonia.Platform
/// Gets or sets a callback invoked when <see cref="AllowedWindowActions"/> changes.
/// </summary>
Action<PlatformAllowedWindowActions>? AllowedWindowActionsChanged { get => null; set { } }
/// <summary>
/// Informs the platform about the thickness of application-drawn shadow decorations
/// so that the platform can distinguish the window content area from shadows.
/// It's platform's responsibility to synchronize this with window resize and rendering of the next frame
/// </summary>
/// <param name="extents">The shadow thickness on each side, in DIPs.</param>
void SetShadowExtents(Thickness extents) { }
}
}

4
src/Avalonia.Controls/Window.cs

@ -805,6 +805,7 @@ namespace Avalonia.Controls
// Only use platform margins if drawn decorations are not active
WindowDecorationMargin = PlatformImpl?.ExtendedMargins ?? default;
TopLevelHost.DecorationInset = default;
PlatformImpl?.SetShadowExtents(default);
return;
}
@ -815,6 +816,9 @@ namespace Avalonia.Controls
? decorations.FrameThickness : default;
var shadow = parts.HasFlag(Chrome.DrawnWindowDecorationParts.Shadow)
? decorations.ShadowThickness : default;
PlatformImpl?.SetShadowExtents(shadow);
var margin = new Thickness(
frame.Left + shadow.Left,
titleBarHeight + frame.Top + shadow.Top,

Loading…
Cancel
Save