Browse Source

Tweak effective viewport calculation.

This logic isn't in the UWP version as it only clips to scrollports.
pull/4173/head
Steven Kirk 6 years ago
parent
commit
64174f37af
  1. 17
      src/Avalonia.Layout/LayoutManager.cs

17
src/Avalonia.Layout/LayoutManager.cs

@ -355,20 +355,27 @@ namespace Avalonia.Layout
private void CalculateEffectiveViewport(IVisual target, IVisual control, ref Rect viewport)
{
// Recurse until the top level control.
if (control.VisualParent is object)
{
CalculateEffectiveViewport(target, control.VisualParent, ref viewport);
}
if (control.ClipToBounds || control.VisualParent is null)
else
{
viewport = control.Bounds;
viewport = new Rect(control.Bounds.Size);
}
else
// Apply the control clip bounds if it's not the target control. We don't apply it to
// the target control because it may itself be clipped to bounds and if so the viewport
// we calculate would be of no use.
if (control != target && control.ClipToBounds)
{
viewport = viewport.Translate(-control.Bounds.Position);
viewport = control.Bounds.Intersect(viewport);
}
// Translate the viewport into this control's coordinate space.
viewport = viewport.Translate(-control.Bounds.Position);
if (control != target && control.RenderTransform is object)
{
var origin = control.RenderTransformOrigin.ToPixels(control.Bounds.Size);

Loading…
Cancel
Save