mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-29 07:16:33 +08:00
Fix popup shadow layer bug on macos
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user