|
|
@ -251,17 +251,20 @@ namespace Avalonia.Controls.Presenters |
|
|
return scrollable.BringIntoView(control, targetRect); |
|
|
return scrollable.BringIntoView(control, targetRect); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var transform = target.TransformToVisual(this); |
|
|
// The `viewport` rectangle computed below is in extent coordinates, so transform
|
|
|
|
|
|
// `targetRect` into that space too. Going via Child rather than via this + Offset
|
|
|
if (transform == null) |
|
|
// keeps the result independent of Offset, which may have changed since the last
|
|
|
|
|
|
// arrange.
|
|
|
|
|
|
if (target.TransformToVisual(Child) is not { } transform) |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
transform *= Matrix.CreateTranslation(Offset); |
|
|
var childPadding = GetChildPadding(); |
|
|
|
|
|
var childMargin = GetChildMargin(); |
|
|
var rectangle = targetRect.TransformToAABB(transform.Value); |
|
|
var childContentOrigin = new Vector(childPadding.Left + childMargin.Left, childPadding.Top + childMargin.Top); |
|
|
Rect viewport = new Rect(Offset.X, Offset.Y, Viewport.Width, Viewport.Height); |
|
|
var rectangle = targetRect.TransformToAABB(transform).Translate(childContentOrigin); |
|
|
|
|
|
var viewport = new Rect(Offset.X, Offset.Y, Viewport.Width, Viewport.Height); |
|
|
|
|
|
|
|
|
double minX = ComputeScrollOffsetWithMinimalScroll(viewport.Left, viewport.Right, rectangle.Left, rectangle.Right); |
|
|
double minX = ComputeScrollOffsetWithMinimalScroll(viewport.Left, viewport.Right, rectangle.Left, rectangle.Right); |
|
|
double minY = ComputeScrollOffsetWithMinimalScroll(viewport.Top, viewport.Bottom, rectangle.Top, rectangle.Bottom); |
|
|
double minY = ComputeScrollOffsetWithMinimalScroll(viewport.Top, viewport.Bottom, rectangle.Top, rectangle.Bottom); |
|
|
@ -528,16 +531,26 @@ namespace Avalonia.Controls.Presenters |
|
|
return padding + borderThickness; |
|
|
return padding + borderThickness; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private Size ComputeExtent(Size viewportSize, Thickness padding) |
|
|
private Thickness GetChildMargin() |
|
|
{ |
|
|
{ |
|
|
var childMargin = Child!.Margin; |
|
|
if (Child is not { } child) |
|
|
|
|
|
return default; |
|
|
|
|
|
|
|
|
|
|
|
var margin = child.Margin; |
|
|
|
|
|
|
|
|
if (Child.UseLayoutRounding) |
|
|
if (Child.UseLayoutRounding) |
|
|
{ |
|
|
{ |
|
|
var scale = LayoutHelper.GetLayoutScale(Child); |
|
|
var scale = LayoutHelper.GetLayoutScale(Child); |
|
|
childMargin = LayoutHelper.RoundLayoutThickness(childMargin, scale); |
|
|
margin = LayoutHelper.RoundLayoutThickness(margin, scale); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return margin; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Size ComputeExtent(Size viewportSize, Thickness padding) |
|
|
|
|
|
{ |
|
|
|
|
|
var childMargin = GetChildMargin(); |
|
|
|
|
|
|
|
|
var extent = Child!.Bounds.Size.Inflate(childMargin).Inflate(padding); |
|
|
var extent = Child!.Bounds.Size.Inflate(childMargin).Inflate(padding); |
|
|
|
|
|
|
|
|
if (MathUtilities.AreClose(extent.Width, viewportSize.Width, LayoutHelper.LayoutEpsilon)) |
|
|
if (MathUtilities.AreClose(extent.Width, viewportSize.Width, LayoutHelper.LayoutEpsilon)) |
|
|
|