Browse Source

fixes the overlay popup glitch where it renders at 0,0 before applying the offet.

use the media context api to sync with layout and render.
pull/11584/head
Dan Walmsley 3 years ago
parent
commit
d99697f4ae
  1. 9
      src/Avalonia.Base/Media/MediaContext.cs
  2. 8
      src/Avalonia.Controls/Primitives/OverlayPopupHost.cs

9
src/Avalonia.Base/Media/MediaContext.cs

@ -212,7 +212,12 @@ internal partial class MediaContext : ICompositorScheduler
}
while (count > 0);
}
/// <summary>
/// Executes the <param name="callback">callback</param> in the layout pass that will occur
/// immediately before the next rendered frame.
/// </summary>
/// <param name="callback">Code to execute.</param>
public void BeginInvokeOnRender(Action callback)
{
if (_invokeOnRenderCallbacks == null)
@ -224,4 +229,4 @@ internal partial class MediaContext : ICompositorScheduler
if (!_isRendering)
ScheduleRender(true);
}
}
}

8
src/Avalonia.Controls/Primitives/OverlayPopupHost.cs

@ -120,11 +120,11 @@ namespace Avalonia.Controls.Primitives
void IManagedPopupPositionerPopup.MoveAndResize(Point devicePoint, Size virtualSize)
{
_lastRequestedPosition = devicePoint;
Dispatcher.UIThread.Post(() =>
MediaContext.Instance.BeginInvokeOnRender(() =>
{
OverlayLayer.SetLeft(this, _lastRequestedPosition.X);
OverlayLayer.SetTop(this, _lastRequestedPosition.Y);
}, DispatcherPriority.Render);
Canvas.SetLeft(this, _lastRequestedPosition.X);
Canvas.SetTop(this, _lastRequestedPosition.Y);
});
}
double IManagedPopupPositionerPopup.Scaling => 1;

Loading…
Cancel
Save