From f6cba5ab698f36ffd6e6c88044415f735c0fcecf Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 2 Jul 2019 23:45:39 +0200 Subject: [PATCH] Implemented NonVirtualizingLayout. --- src/Avalonia.Layout/NonVirtualizingLayout.cs | 82 ++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/Avalonia.Layout/NonVirtualizingLayout.cs b/src/Avalonia.Layout/NonVirtualizingLayout.cs index 681096ab19..ad4dc302b0 100644 --- a/src/Avalonia.Layout/NonVirtualizingLayout.cs +++ b/src/Avalonia.Layout/NonVirtualizingLayout.cs @@ -11,5 +11,87 @@ namespace Avalonia.Layout /// public abstract class NonVirtualizingLayout : AttachedLayout { + /// + public sealed override void InitializeForContext(LayoutContext context) + { + InitializeForContextCore((VirtualizingLayoutContext)context); + } + + /// + public sealed override void UninitializeForContext(LayoutContext context) + { + UninitializeForContextCore((VirtualizingLayoutContext)context); + } + + /// + public sealed override Size Measure(LayoutContext context, Size availableSize) + { + return MeasureOverride((VirtualizingLayoutContext)context, availableSize); + } + + /// + public sealed override Size Arrange(LayoutContext context, Size finalSize) + { + return ArrangeOverride((VirtualizingLayoutContext)context, finalSize); + } + + /// + /// When overridden in a derived class, initializes any per-container state the layout + /// requires when it is attached to an ILayoutable container. + /// + /// + /// The context object that facilitates communication between the layout and its host + /// container. + /// + protected virtual void InitializeForContextCore(VirtualizingLayoutContext context) + { + } + + /// + /// When overridden in a derived class, removes any state the layout previously stored on + /// the ILayoutable container. + /// + /// + /// The context object that facilitates communication between the layout and its host + /// container. + /// + protected virtual void UninitializeForContextCore(VirtualizingLayoutContext context) + { + } + + /// + /// Provides the behavior for the "Measure" pass of the layout cycle. Classes can override + /// this method to define their own "Measure" pass behavior. + /// + /// + /// The context object that facilitates communication between the layout and its host + /// container. + /// + /// + /// The available size that this object can give to child objects. Infinity can be + /// specified as a value to indicate that the object will size to whatever content is + /// available. + /// + /// + /// The size that this object determines it needs during layout, based on its calculations + /// of the allocated sizes for child objects or based on other considerations such as a + /// fixed container size. + /// + protected abstract Size MeasureOverride(VirtualizingLayoutContext context, Size availableSize); + + /// + /// When implemented in a derived class, provides the behavior for the "Arrange" pass of + /// layout. Classes can override this method to define their own "Arrange" pass behavior. + /// + /// + /// The context object that facilitates communication between the layout and its host + /// container. + /// + /// + /// The final area within the container that this object should use to arrange itself and + /// its children. + /// + /// The actual size that is used after the element is arranged in layout. + protected virtual Size ArrangeOverride(VirtualizingLayoutContext context, Size finalSize) => finalSize; } }