@ -21,6 +21,7 @@ namespace Avalonia.Layout
private readonly Layoutable _ owner ;
private readonly LayoutQueue < Layoutable > _ toMeasure = new LayoutQueue < Layoutable > ( v = > ! v . IsMeasureValid ) ;
private readonly LayoutQueue < Layoutable > _ toArrange = new LayoutQueue < Layoutable > ( v = > ! v . IsArrangeValid ) ;
private readonly List < Layoutable > _ toArrangeAfterMeasure = new ( ) ;
private readonly Action _ executeLayoutPass ;
private List < EffectiveViewportChangedListener > ? _ effectiveViewportChangedListeners ;
private bool _d isposed ;
@ -266,9 +267,14 @@ namespace Avalonia.Layout
if ( ! control . IsArrangeValid )
{
Arrange ( control ) ;
if ( Arrange ( control ) = = ArrangeResult . AncestorMeasureInvalid )
_ toArrangeAfterMeasure . Add ( control ) ;
}
}
foreach ( var i in _ toArrangeAfterMeasure )
InvalidateArrange ( i ) ;
_ toArrangeAfterMeasure . Clear ( ) ;
}
private bool Measure ( Layoutable control )
@ -304,19 +310,19 @@ namespace Avalonia.Layout
return true ;
}
private bool Arrange ( Layoutable control )
private ArrangeResult Arrange ( Layoutable control )
{
if ( ! control . IsVisible | | ! control . IsAttachedToVisualTree )
return fals e;
return ArrangeResult . NotVisibl e;
if ( control . VisualParent is Layoutable parent )
{
if ( ! Arrange ( parent ) )
return false ;
if ( Arrange ( parent ) is var parentResult & & parentResult ! = ArrangeResult . Arranged )
return parentResult ;
}
if ( ! control . IsMeasureValid )
return false ;
return ArrangeResult . AncestorMeasureInvalid ;
if ( ! control . IsArrangeValid )
{
@ -332,7 +338,7 @@ namespace Avalonia.Layout
}
}
return true ;
return ArrangeResult . Arranged ;
}
private void QueueLayoutPass ( )
@ -435,5 +441,12 @@ namespace Avalonia.Layout
public Layoutable Listener { get ; }
public Rect Viewport { get ; set ; }
}
private enum ArrangeResult
{
Arranged ,
NotVisible ,
AncestorMeasureInvalid ,
}
}
}