Fix popup shadow layer bug on macos

This commit is contained in:
chinboy
2025-06-20 18:48:53 +08:00
parent 1ed7cb9365
commit 46db07296b
3 changed files with 27 additions and 11 deletions
+3 -3
View File
@@ -11,7 +11,7 @@ namespace AtomUI.MotionScene;
internal class SceneLayer : WindowBase, IHostedVisualTreeRoot, IDisposable
{
private readonly IManagedPopupPositionerPopup? _managedPopupPositionerPopup;
protected readonly IManagedPopupPositionerPopup? ManagedPopupPositionerPopup;
private readonly Canvas _layout;
private SceneMotionActorControl? _motionActorControl;
@@ -49,7 +49,7 @@ internal class SceneLayer : WindowBase, IHostedVisualTreeRoot, IDisposable
this.SetWindowIgnoreMouseEvents(true);
if (PlatformImpl?.PopupPositioner is ManagedPopupPositioner managedPopupPositioner)
{
_managedPopupPositionerPopup = managedPopupPositioner.GetManagedPopupPositionerPopup();
ManagedPopupPositionerPopup = managedPopupPositioner.GetManagedPopupPositionerPopup();
}
_layout = new Canvas();
@@ -155,7 +155,7 @@ internal class SceneLayer : WindowBase, IHostedVisualTreeRoot, IDisposable
{
Width = size.Width;
Height = size.Height;
_managedPopupPositionerPopup?.MoveAndResize(new Point(Math.Round(point.X), Math.Floor(point.Y + 0.5)), size);
ManagedPopupPositionerPopup?.MoveAndResize(new Point(Math.Round(point.X), Math.Floor(point.Y + 0.5)), size);
}
protected override void OnOpened(EventArgs e)
+23 -1
View File
@@ -113,10 +113,32 @@ internal class PopupBuddyLayer : SceneLayer, IPopupBuddyLayer, IShadowAwareLayer
{
scaling = windowBase.DesktopScaling;
}
var offset = new Point(popupOffset.X, popupOffset.Y);
var offset = new Point(popupOffset.X, popupOffset.Y);
var maskShadowsThickness = MaskShadows.Thickness();
var layerOffset = new Point(offset.X - maskShadowsThickness.Left * scaling,
offset.Y - maskShadowsThickness.Top * scaling);
if (OperatingSystem.IsMacOS())
{
var topOffsetMark = 0d;
if (ManagedPopupPositionerPopup != null)
{
var screens = ManagedPopupPositionerPopup.Screens;
foreach (var screen in screens)
{
topOffsetMark = Math.Max(topOffsetMark, screen.WorkingArea.Top);
}
}
var delta = layerOffset.Y - topOffsetMark;
if (delta < 0)
{
RenderTransform = new TranslateTransform(0, delta);
}
else
{
RenderTransform = null;
}
}
MoveAndResize(layerOffset, popupRoot.ClientSize.Inflate(MaskShadows.Thickness()));
}
+1 -7
View File
@@ -34,13 +34,7 @@ public class TextBlock : AvaloniaTextBlock, IResourceBindingManager
base.OnDetachedFromVisualTree(e);
this.DisposeTokenBindings();
}
protected override Size MeasureOverride(Size availableSize)
{
var size = base.MeasureOverride(availableSize);
return new Size(size.Width, size.Height + Math.Abs(_deltaOffsetY));
}
protected override void RenderTextLayout(DrawingContext context, Point origin)
{
base.RenderTextLayout(context, new Point(origin.X, origin.Y + _deltaOffsetY));