From 692c0c155dd2f9c8285fb95ede288a18f2ded600 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 24 Nov 2022 23:13:05 +0100 Subject: [PATCH 01/64] Begin refactoring ItemsPresenter. A lot still broken, in particular virtualization is completely removed.`ItemsPresenter` now no longer has an `Items` or `ItemTemplate` property; it detects when it's hosted in an `ItemsControl`. `IItemsPresenter` interface removed. --- .../ControlCatalog/Pages/DialogsPage.xaml.cs | 588 +++--- .../HamburgerMenu/HamburgerMenu.xaml | 4 +- .../Themes/Fluent/ColorView.xaml | 5 +- .../Themes/Simple/ColorView.xaml | 5 +- src/Avalonia.Controls/ComboBox.cs | 2 +- src/Avalonia.Controls/IVirtualizingPanel.cs | 78 - src/Avalonia.Controls/ItemsControl.cs | 12 +- src/Avalonia.Controls/ListBox.cs | 2 +- .../Presenters/CarouselPresenter.cs | 344 ++-- .../Presenters/IItemsPresenter.cs | 18 - .../Presenters/IItemsPresenterHost.cs | 4 +- .../Presenters/ItemContainerSync.cs | 125 -- .../Presenters/ItemVirtualizer.cs | 303 --- .../Presenters/ItemVirtualizerNone.cs | 106 - .../Presenters/ItemVirtualizerSimple.cs | 606 ------ .../Presenters/ItemsPresenter.cs | 187 +- .../Presenters/ItemsPresenterBase.cs | 308 --- .../ItemsPresenterContainerGenerator.cs | 108 + .../Primitives/SelectingItemsControl.cs | 2 +- .../VirtualizingStackPanel.cs | 252 +-- .../Controls/Carousel.xaml | 1 - .../Controls/ComboBox.xaml | 5 +- .../Controls/ContextMenu.xaml | 2 - .../Controls/ItemsControl.xaml | 4 +- .../Controls/ListBox.xaml | 5 +- .../Controls/ManagedFileChooser.xaml | 5 +- src/Avalonia.Themes.Fluent/Controls/Menu.xaml | 4 - .../Controls/MenuFlyoutPresenter.xaml | 2 - .../Controls/MenuItem.xaml | 2 - .../Controls/TabControl.xaml | 2 - .../Controls/TabStrip.xaml | 4 +- .../Controls/TreeView.xaml | 1 - .../Controls/TreeViewItem.xaml | 1 - .../Controls/Carousel.xaml | 1 - .../Controls/ComboBox.xaml | 5 +- .../Controls/ContextMenu.xaml | 2 - .../Controls/ItemsControl.xaml | 2 - .../Controls/ListBox.xaml | 5 +- src/Avalonia.Themes.Simple/Controls/Menu.xaml | 4 - .../Controls/MenuFlyoutPresenter.xaml | 2 - .../Controls/MenuItem.xaml | 2 - .../Controls/TabControl.xaml | 2 - .../Controls/TabStrip.xaml | 2 - .../Controls/TreeView.xaml | 1 - .../Controls/TreeViewItem.xaml | 1 - .../CarouselTests.cs | 1 - .../ComboBoxTests.cs | 1 - .../ItemsControlTests.cs | 4 +- .../ListBoxTests.cs | 52 +- .../ListBoxTests_Multiple.cs | 1 - .../ListBoxTests_Single.cs | 1 - .../Presenters/CarouselPresenterTests.cs | 1464 ++++++------- .../Presenters/ItemsPresenterTests.cs | 370 +--- .../ItemsPresenterTests_Virtualization.cs | 748 +++---- ...emsPresenterTests_Virtualization_Simple.cs | 1822 ++++++++--------- .../Primitives/PopupTests.cs | 5 +- .../Primitives/SelectingItemsControlTests.cs | 2 - .../SelectingItemsControlTests_AutoSelect.cs | 1 - .../SelectingItemsControlTests_Multiple.cs | 1 - .../Primitives/TabStripTests.cs | 1 - .../TreeViewTests.cs | 2 - .../VirtualizingStackPanelTests.cs | 522 ++--- .../AutoDataTemplateBindingHookTest.cs | 1 - tests/Avalonia.UnitTests/TestExtensions.cs | 1 - 64 files changed, 3040 insertions(+), 5086 deletions(-) delete mode 100644 src/Avalonia.Controls/Presenters/IItemsPresenter.cs delete mode 100644 src/Avalonia.Controls/Presenters/ItemContainerSync.cs delete mode 100644 src/Avalonia.Controls/Presenters/ItemVirtualizer.cs delete mode 100644 src/Avalonia.Controls/Presenters/ItemVirtualizerNone.cs delete mode 100644 src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs delete mode 100644 src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs create mode 100644 src/Avalonia.Controls/Presenters/ItemsPresenterContainerGenerator.cs diff --git a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs index 67e9ef4e407..41a5b86ebda 100644 --- a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs +++ b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs @@ -24,301 +24,301 @@ public DialogsPage() { this.InitializeComponent(); - var results = this.Get("PickerLastResults"); - var resultsVisible = this.Get("PickerLastResultsVisible"); - var bookmarkContainer = this.Get("BookmarkContainer"); - var openedFileContent = this.Get("OpenedFileContent"); - var openMultiple = this.Get("OpenMultiple"); - - IStorageFolder? lastSelectedDirectory = null; - - List GetFilters() - { - if (this.Get("UseFilters").IsChecked != true) - return new List(); - return new List - { - new FileDialogFilter - { - Name = "Text files (.txt)", Extensions = new List {"txt"} - }, - new FileDialogFilter - { - Name = "All files", - Extensions = new List {"*"} - } - }; - } - - List? GetFileTypes() - { - if (this.Get("UseFilters").IsChecked != true) - return null; - return new List - { - FilePickerFileTypes.All, - FilePickerFileTypes.TextPlain - }; - } - - this.Get