From 03d6ca9374f932a7d411dc3a9b2003fc0cb277eb Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 22 Dec 2021 00:33:26 -0500 Subject: [PATCH 01/13] Better fix for #6830 Previous numericupdown bugfix (see https://github.com/AvaloniaUI/Avalonia/pull/6830/files) introduced another bug (see https://github.com/AvaloniaUI/Avalonia/discussions/7230#discussioncomment-1855837). This PR solves both problems. --- src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml index 1e58259358..36ab07e3e3 100644 --- a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml @@ -38,7 +38,7 @@ BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="{TemplateBinding CornerRadius}" Padding="0" - MinWidth="{TemplateBinding MinWidth}" + MinWidth="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" AllowSpin="{TemplateBinding AllowSpin}" @@ -50,7 +50,7 @@ BorderBrush="Transparent" Margin="-1" Padding="{TemplateBinding Padding}" - MinWidth="{TemplateBinding MinWidth}" + MinWidth="0" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" Watermark="{TemplateBinding Watermark}" From f8634108a35506f814dd8369651519781fa41411 Mon Sep 17 00:00:00 2001 From: Benedikt Stebner Date: Wed, 12 Jan 2022 07:50:37 +0100 Subject: [PATCH 02/13] Enable Skia ClearType support on Windows --- src/Skia/Avalonia.Skia/DrawingContextImpl.cs | 11 ----------- src/Skia/Avalonia.Skia/PlatformRenderInterface.cs | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs index 4dedd27445..17c86daa94 100644 --- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs +++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs @@ -459,8 +459,6 @@ namespace Avalonia.Skia { var glyphRunImpl = (GlyphRunImpl)glyphRun.GlyphRunImpl; - ConfigureTextRendering(paintWrapper); - Canvas.DrawText(glyphRunImpl.TextBlob, (float)glyphRun.BaselineOrigin.X, (float)glyphRun.BaselineOrigin.Y, paintWrapper.Paint); } @@ -606,15 +604,6 @@ namespace Avalonia.Skia } } - internal void ConfigureTextRendering(PaintWrapper wrapper) - { - var paint = wrapper.Paint; - - paint.IsEmbeddedBitmapText = true; - paint.SubpixelText = true; - paint.LcdRenderText = _canTextUseLcdRendering; - } - /// /// Configure paint wrapper for using gradient brush. /// diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index 4130d38f17..c3ac5e1774 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -198,7 +198,7 @@ namespace Avalonia.Skia private static readonly SKFont s_font = new SKFont { Subpixel = true, - Edging = SKFontEdging.Antialias, + Edging = SKFontEdging.SubpixelAntialias, Hinting = SKFontHinting.Full, LinearMetrics = true }; From 60a6a5273508db4b4ce4e36937d7b5b7b1f4c81d Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Thu, 13 Jan 2022 17:06:33 +0200 Subject: [PATCH 03/13] wip --- .../Resources/Resource.Designer.cs | 2 +- .../Avalonia.Themes.Default.csproj | 5 +- .../{ => Controls}/AutoCompleteBox.xaml | 0 .../{ => Controls}/Button.xaml | 0 .../{ => Controls}/ButtonSpinner.xaml | 0 .../{ => Controls}/Calendar.xaml | 0 .../{ => Controls}/CalendarButton.xaml | 0 .../{ => Controls}/CalendarDatePicker.xaml | 0 .../{ => Controls}/CalendarDayButton.xaml | 0 .../{ => Controls}/CalendarItem.xaml | 0 .../{ => Controls}/CaptionButtons.xaml | 0 .../{ => Controls}/Carousel.xaml | 0 .../{ => Controls}/CheckBox.xaml | 0 .../{ => Controls}/ComboBox.xaml | 0 .../{ => Controls}/ComboBoxItem.xaml | 0 .../{ => Controls}/ContentControl.xaml | 0 .../{ => Controls}/ContextMenu.xaml | 0 .../{ => Controls}/DataValidationErrors.xaml | 0 .../{ => Controls}/DatePicker.xaml | 0 .../{ => Controls}/EmbeddableControlRoot.xaml | 0 .../{ => Controls}/Expander.xaml | 0 .../{ => Controls}/FlyoutPresenter.xaml | 0 .../{ => Controls}/FocusAdorner.xaml | 0 .../{ => Controls}/GridSplitter.xaml | 0 .../{ => Controls}/ItemsControl.xaml | 0 .../{ => Controls}/Label.xaml | 0 .../{ => Controls}/ListBox.xaml | 0 .../{ => Controls}/ListBoxItem.xaml | 0 .../{ => Controls}/ManagedFileChooser.xaml | 0 .../{ => Controls}/Menu.xaml | 0 .../{ => Controls}/MenuFlyoutPresenter.xaml | 0 .../{ => Controls}/MenuItem.xaml | 0 .../{ => Controls}/NativeMenuBar.xaml | 0 .../{ => Controls}/NotificationCard.xaml | 0 .../{ => Controls}/NumericUpDown.xaml | 0 .../{ => Controls}/OverlayPopupHost.xaml | 0 .../{ => Controls}/PathIcon.xaml | 0 .../{ => Controls}/PopupRoot.xaml | 0 .../{ => Controls}/ProgressBar.xaml | 0 .../{ => Controls}/RadioButton.xaml | 0 .../{ => Controls}/RepeatButton.xaml | 0 .../{ => Controls}/ScrollBar.xaml | 0 .../{ => Controls}/ScrollViewer.xaml | 0 .../{ => Controls}/Separator.xaml | 0 .../{ => Controls}/Slider.xaml | 0 .../{ => Controls}/SplitView.xaml | 0 .../{ => Controls}/TabControl.xaml | 0 .../{ => Controls}/TabItem.xaml | 0 .../{ => Controls}/TabStrip.xaml | 0 .../{ => Controls}/TabStripItem.xaml | 0 .../{ => Controls}/TextBox.xaml | 0 .../{ => Controls}/TimePicker.xaml | 0 .../{ => Controls}/TitleBar.xaml | 0 .../{ => Controls}/ToggleButton.xaml | 0 .../{ => Controls}/ToggleSwitch.xaml | 0 .../{ => Controls}/ToolTip.xaml | 0 .../{ => Controls}/TreeView.xaml | 0 .../{ => Controls}/TreeViewItem.xaml | 0 .../{ => Controls}/UserControl.xaml | 0 .../{ => Controls}/Window.xaml | 0 .../WindowNotificationManager.xaml | 0 src/Avalonia.Themes.Default/DefaultTheme.xaml | 118 +++++++-------- .../DefaultTheme.xaml.cs | 1 - src/Avalonia.Themes.Default/SimpleTheme.cs | 140 ++++++++++++++++++ .../SimpleThemeMode.cs | 8 + 65 files changed, 209 insertions(+), 65 deletions(-) rename src/Avalonia.Themes.Default/{ => Controls}/AutoCompleteBox.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/Button.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ButtonSpinner.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/Calendar.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/CalendarButton.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/CalendarDatePicker.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/CalendarDayButton.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/CalendarItem.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/CaptionButtons.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/Carousel.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/CheckBox.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ComboBox.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ComboBoxItem.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ContentControl.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ContextMenu.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/DataValidationErrors.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/DatePicker.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/EmbeddableControlRoot.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/Expander.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/FlyoutPresenter.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/FocusAdorner.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/GridSplitter.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ItemsControl.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/Label.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ListBox.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ListBoxItem.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ManagedFileChooser.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/Menu.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/MenuFlyoutPresenter.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/MenuItem.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/NativeMenuBar.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/NotificationCard.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/NumericUpDown.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/OverlayPopupHost.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/PathIcon.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/PopupRoot.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ProgressBar.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/RadioButton.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/RepeatButton.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ScrollBar.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ScrollViewer.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/Separator.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/Slider.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/SplitView.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/TabControl.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/TabItem.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/TabStrip.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/TabStripItem.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/TextBox.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/TimePicker.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/TitleBar.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ToggleButton.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ToggleSwitch.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/ToolTip.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/TreeView.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/TreeViewItem.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/UserControl.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/Window.xaml (100%) rename src/Avalonia.Themes.Default/{ => Controls}/WindowNotificationManager.xaml (100%) create mode 100644 src/Avalonia.Themes.Default/SimpleTheme.cs create mode 100644 src/Avalonia.Themes.Default/SimpleThemeMode.cs diff --git a/src/Android/Avalonia.AndroidTestApplication/Resources/Resource.Designer.cs b/src/Android/Avalonia.AndroidTestApplication/Resources/Resource.Designer.cs index 87fd47df25..3f11aa9593 100644 --- a/src/Android/Avalonia.AndroidTestApplication/Resources/Resource.Designer.cs +++ b/src/Android/Avalonia.AndroidTestApplication/Resources/Resource.Designer.cs @@ -14,7 +14,7 @@ namespace Avalonia.AndroidTestApplication { - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.1.99.62")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.1.0.11")] public partial class Resource { diff --git a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj index 678f75b43f..ef200b5532 100644 --- a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj +++ b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj @@ -13,10 +13,7 @@ - - - - + diff --git a/src/Avalonia.Themes.Default/AutoCompleteBox.xaml b/src/Avalonia.Themes.Default/Controls/AutoCompleteBox.xaml similarity index 100% rename from src/Avalonia.Themes.Default/AutoCompleteBox.xaml rename to src/Avalonia.Themes.Default/Controls/AutoCompleteBox.xaml diff --git a/src/Avalonia.Themes.Default/Button.xaml b/src/Avalonia.Themes.Default/Controls/Button.xaml similarity index 100% rename from src/Avalonia.Themes.Default/Button.xaml rename to src/Avalonia.Themes.Default/Controls/Button.xaml diff --git a/src/Avalonia.Themes.Default/ButtonSpinner.xaml b/src/Avalonia.Themes.Default/Controls/ButtonSpinner.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ButtonSpinner.xaml rename to src/Avalonia.Themes.Default/Controls/ButtonSpinner.xaml diff --git a/src/Avalonia.Themes.Default/Calendar.xaml b/src/Avalonia.Themes.Default/Controls/Calendar.xaml similarity index 100% rename from src/Avalonia.Themes.Default/Calendar.xaml rename to src/Avalonia.Themes.Default/Controls/Calendar.xaml diff --git a/src/Avalonia.Themes.Default/CalendarButton.xaml b/src/Avalonia.Themes.Default/Controls/CalendarButton.xaml similarity index 100% rename from src/Avalonia.Themes.Default/CalendarButton.xaml rename to src/Avalonia.Themes.Default/Controls/CalendarButton.xaml diff --git a/src/Avalonia.Themes.Default/CalendarDatePicker.xaml b/src/Avalonia.Themes.Default/Controls/CalendarDatePicker.xaml similarity index 100% rename from src/Avalonia.Themes.Default/CalendarDatePicker.xaml rename to src/Avalonia.Themes.Default/Controls/CalendarDatePicker.xaml diff --git a/src/Avalonia.Themes.Default/CalendarDayButton.xaml b/src/Avalonia.Themes.Default/Controls/CalendarDayButton.xaml similarity index 100% rename from src/Avalonia.Themes.Default/CalendarDayButton.xaml rename to src/Avalonia.Themes.Default/Controls/CalendarDayButton.xaml diff --git a/src/Avalonia.Themes.Default/CalendarItem.xaml b/src/Avalonia.Themes.Default/Controls/CalendarItem.xaml similarity index 100% rename from src/Avalonia.Themes.Default/CalendarItem.xaml rename to src/Avalonia.Themes.Default/Controls/CalendarItem.xaml diff --git a/src/Avalonia.Themes.Default/CaptionButtons.xaml b/src/Avalonia.Themes.Default/Controls/CaptionButtons.xaml similarity index 100% rename from src/Avalonia.Themes.Default/CaptionButtons.xaml rename to src/Avalonia.Themes.Default/Controls/CaptionButtons.xaml diff --git a/src/Avalonia.Themes.Default/Carousel.xaml b/src/Avalonia.Themes.Default/Controls/Carousel.xaml similarity index 100% rename from src/Avalonia.Themes.Default/Carousel.xaml rename to src/Avalonia.Themes.Default/Controls/Carousel.xaml diff --git a/src/Avalonia.Themes.Default/CheckBox.xaml b/src/Avalonia.Themes.Default/Controls/CheckBox.xaml similarity index 100% rename from src/Avalonia.Themes.Default/CheckBox.xaml rename to src/Avalonia.Themes.Default/Controls/CheckBox.xaml diff --git a/src/Avalonia.Themes.Default/ComboBox.xaml b/src/Avalonia.Themes.Default/Controls/ComboBox.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ComboBox.xaml rename to src/Avalonia.Themes.Default/Controls/ComboBox.xaml diff --git a/src/Avalonia.Themes.Default/ComboBoxItem.xaml b/src/Avalonia.Themes.Default/Controls/ComboBoxItem.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ComboBoxItem.xaml rename to src/Avalonia.Themes.Default/Controls/ComboBoxItem.xaml diff --git a/src/Avalonia.Themes.Default/ContentControl.xaml b/src/Avalonia.Themes.Default/Controls/ContentControl.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ContentControl.xaml rename to src/Avalonia.Themes.Default/Controls/ContentControl.xaml diff --git a/src/Avalonia.Themes.Default/ContextMenu.xaml b/src/Avalonia.Themes.Default/Controls/ContextMenu.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ContextMenu.xaml rename to src/Avalonia.Themes.Default/Controls/ContextMenu.xaml diff --git a/src/Avalonia.Themes.Default/DataValidationErrors.xaml b/src/Avalonia.Themes.Default/Controls/DataValidationErrors.xaml similarity index 100% rename from src/Avalonia.Themes.Default/DataValidationErrors.xaml rename to src/Avalonia.Themes.Default/Controls/DataValidationErrors.xaml diff --git a/src/Avalonia.Themes.Default/DatePicker.xaml b/src/Avalonia.Themes.Default/Controls/DatePicker.xaml similarity index 100% rename from src/Avalonia.Themes.Default/DatePicker.xaml rename to src/Avalonia.Themes.Default/Controls/DatePicker.xaml diff --git a/src/Avalonia.Themes.Default/EmbeddableControlRoot.xaml b/src/Avalonia.Themes.Default/Controls/EmbeddableControlRoot.xaml similarity index 100% rename from src/Avalonia.Themes.Default/EmbeddableControlRoot.xaml rename to src/Avalonia.Themes.Default/Controls/EmbeddableControlRoot.xaml diff --git a/src/Avalonia.Themes.Default/Expander.xaml b/src/Avalonia.Themes.Default/Controls/Expander.xaml similarity index 100% rename from src/Avalonia.Themes.Default/Expander.xaml rename to src/Avalonia.Themes.Default/Controls/Expander.xaml diff --git a/src/Avalonia.Themes.Default/FlyoutPresenter.xaml b/src/Avalonia.Themes.Default/Controls/FlyoutPresenter.xaml similarity index 100% rename from src/Avalonia.Themes.Default/FlyoutPresenter.xaml rename to src/Avalonia.Themes.Default/Controls/FlyoutPresenter.xaml diff --git a/src/Avalonia.Themes.Default/FocusAdorner.xaml b/src/Avalonia.Themes.Default/Controls/FocusAdorner.xaml similarity index 100% rename from src/Avalonia.Themes.Default/FocusAdorner.xaml rename to src/Avalonia.Themes.Default/Controls/FocusAdorner.xaml diff --git a/src/Avalonia.Themes.Default/GridSplitter.xaml b/src/Avalonia.Themes.Default/Controls/GridSplitter.xaml similarity index 100% rename from src/Avalonia.Themes.Default/GridSplitter.xaml rename to src/Avalonia.Themes.Default/Controls/GridSplitter.xaml diff --git a/src/Avalonia.Themes.Default/ItemsControl.xaml b/src/Avalonia.Themes.Default/Controls/ItemsControl.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ItemsControl.xaml rename to src/Avalonia.Themes.Default/Controls/ItemsControl.xaml diff --git a/src/Avalonia.Themes.Default/Label.xaml b/src/Avalonia.Themes.Default/Controls/Label.xaml similarity index 100% rename from src/Avalonia.Themes.Default/Label.xaml rename to src/Avalonia.Themes.Default/Controls/Label.xaml diff --git a/src/Avalonia.Themes.Default/ListBox.xaml b/src/Avalonia.Themes.Default/Controls/ListBox.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ListBox.xaml rename to src/Avalonia.Themes.Default/Controls/ListBox.xaml diff --git a/src/Avalonia.Themes.Default/ListBoxItem.xaml b/src/Avalonia.Themes.Default/Controls/ListBoxItem.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ListBoxItem.xaml rename to src/Avalonia.Themes.Default/Controls/ListBoxItem.xaml diff --git a/src/Avalonia.Themes.Default/ManagedFileChooser.xaml b/src/Avalonia.Themes.Default/Controls/ManagedFileChooser.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ManagedFileChooser.xaml rename to src/Avalonia.Themes.Default/Controls/ManagedFileChooser.xaml diff --git a/src/Avalonia.Themes.Default/Menu.xaml b/src/Avalonia.Themes.Default/Controls/Menu.xaml similarity index 100% rename from src/Avalonia.Themes.Default/Menu.xaml rename to src/Avalonia.Themes.Default/Controls/Menu.xaml diff --git a/src/Avalonia.Themes.Default/MenuFlyoutPresenter.xaml b/src/Avalonia.Themes.Default/Controls/MenuFlyoutPresenter.xaml similarity index 100% rename from src/Avalonia.Themes.Default/MenuFlyoutPresenter.xaml rename to src/Avalonia.Themes.Default/Controls/MenuFlyoutPresenter.xaml diff --git a/src/Avalonia.Themes.Default/MenuItem.xaml b/src/Avalonia.Themes.Default/Controls/MenuItem.xaml similarity index 100% rename from src/Avalonia.Themes.Default/MenuItem.xaml rename to src/Avalonia.Themes.Default/Controls/MenuItem.xaml diff --git a/src/Avalonia.Themes.Default/NativeMenuBar.xaml b/src/Avalonia.Themes.Default/Controls/NativeMenuBar.xaml similarity index 100% rename from src/Avalonia.Themes.Default/NativeMenuBar.xaml rename to src/Avalonia.Themes.Default/Controls/NativeMenuBar.xaml diff --git a/src/Avalonia.Themes.Default/NotificationCard.xaml b/src/Avalonia.Themes.Default/Controls/NotificationCard.xaml similarity index 100% rename from src/Avalonia.Themes.Default/NotificationCard.xaml rename to src/Avalonia.Themes.Default/Controls/NotificationCard.xaml diff --git a/src/Avalonia.Themes.Default/NumericUpDown.xaml b/src/Avalonia.Themes.Default/Controls/NumericUpDown.xaml similarity index 100% rename from src/Avalonia.Themes.Default/NumericUpDown.xaml rename to src/Avalonia.Themes.Default/Controls/NumericUpDown.xaml diff --git a/src/Avalonia.Themes.Default/OverlayPopupHost.xaml b/src/Avalonia.Themes.Default/Controls/OverlayPopupHost.xaml similarity index 100% rename from src/Avalonia.Themes.Default/OverlayPopupHost.xaml rename to src/Avalonia.Themes.Default/Controls/OverlayPopupHost.xaml diff --git a/src/Avalonia.Themes.Default/PathIcon.xaml b/src/Avalonia.Themes.Default/Controls/PathIcon.xaml similarity index 100% rename from src/Avalonia.Themes.Default/PathIcon.xaml rename to src/Avalonia.Themes.Default/Controls/PathIcon.xaml diff --git a/src/Avalonia.Themes.Default/PopupRoot.xaml b/src/Avalonia.Themes.Default/Controls/PopupRoot.xaml similarity index 100% rename from src/Avalonia.Themes.Default/PopupRoot.xaml rename to src/Avalonia.Themes.Default/Controls/PopupRoot.xaml diff --git a/src/Avalonia.Themes.Default/ProgressBar.xaml b/src/Avalonia.Themes.Default/Controls/ProgressBar.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ProgressBar.xaml rename to src/Avalonia.Themes.Default/Controls/ProgressBar.xaml diff --git a/src/Avalonia.Themes.Default/RadioButton.xaml b/src/Avalonia.Themes.Default/Controls/RadioButton.xaml similarity index 100% rename from src/Avalonia.Themes.Default/RadioButton.xaml rename to src/Avalonia.Themes.Default/Controls/RadioButton.xaml diff --git a/src/Avalonia.Themes.Default/RepeatButton.xaml b/src/Avalonia.Themes.Default/Controls/RepeatButton.xaml similarity index 100% rename from src/Avalonia.Themes.Default/RepeatButton.xaml rename to src/Avalonia.Themes.Default/Controls/RepeatButton.xaml diff --git a/src/Avalonia.Themes.Default/ScrollBar.xaml b/src/Avalonia.Themes.Default/Controls/ScrollBar.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ScrollBar.xaml rename to src/Avalonia.Themes.Default/Controls/ScrollBar.xaml diff --git a/src/Avalonia.Themes.Default/ScrollViewer.xaml b/src/Avalonia.Themes.Default/Controls/ScrollViewer.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ScrollViewer.xaml rename to src/Avalonia.Themes.Default/Controls/ScrollViewer.xaml diff --git a/src/Avalonia.Themes.Default/Separator.xaml b/src/Avalonia.Themes.Default/Controls/Separator.xaml similarity index 100% rename from src/Avalonia.Themes.Default/Separator.xaml rename to src/Avalonia.Themes.Default/Controls/Separator.xaml diff --git a/src/Avalonia.Themes.Default/Slider.xaml b/src/Avalonia.Themes.Default/Controls/Slider.xaml similarity index 100% rename from src/Avalonia.Themes.Default/Slider.xaml rename to src/Avalonia.Themes.Default/Controls/Slider.xaml diff --git a/src/Avalonia.Themes.Default/SplitView.xaml b/src/Avalonia.Themes.Default/Controls/SplitView.xaml similarity index 100% rename from src/Avalonia.Themes.Default/SplitView.xaml rename to src/Avalonia.Themes.Default/Controls/SplitView.xaml diff --git a/src/Avalonia.Themes.Default/TabControl.xaml b/src/Avalonia.Themes.Default/Controls/TabControl.xaml similarity index 100% rename from src/Avalonia.Themes.Default/TabControl.xaml rename to src/Avalonia.Themes.Default/Controls/TabControl.xaml diff --git a/src/Avalonia.Themes.Default/TabItem.xaml b/src/Avalonia.Themes.Default/Controls/TabItem.xaml similarity index 100% rename from src/Avalonia.Themes.Default/TabItem.xaml rename to src/Avalonia.Themes.Default/Controls/TabItem.xaml diff --git a/src/Avalonia.Themes.Default/TabStrip.xaml b/src/Avalonia.Themes.Default/Controls/TabStrip.xaml similarity index 100% rename from src/Avalonia.Themes.Default/TabStrip.xaml rename to src/Avalonia.Themes.Default/Controls/TabStrip.xaml diff --git a/src/Avalonia.Themes.Default/TabStripItem.xaml b/src/Avalonia.Themes.Default/Controls/TabStripItem.xaml similarity index 100% rename from src/Avalonia.Themes.Default/TabStripItem.xaml rename to src/Avalonia.Themes.Default/Controls/TabStripItem.xaml diff --git a/src/Avalonia.Themes.Default/TextBox.xaml b/src/Avalonia.Themes.Default/Controls/TextBox.xaml similarity index 100% rename from src/Avalonia.Themes.Default/TextBox.xaml rename to src/Avalonia.Themes.Default/Controls/TextBox.xaml diff --git a/src/Avalonia.Themes.Default/TimePicker.xaml b/src/Avalonia.Themes.Default/Controls/TimePicker.xaml similarity index 100% rename from src/Avalonia.Themes.Default/TimePicker.xaml rename to src/Avalonia.Themes.Default/Controls/TimePicker.xaml diff --git a/src/Avalonia.Themes.Default/TitleBar.xaml b/src/Avalonia.Themes.Default/Controls/TitleBar.xaml similarity index 100% rename from src/Avalonia.Themes.Default/TitleBar.xaml rename to src/Avalonia.Themes.Default/Controls/TitleBar.xaml diff --git a/src/Avalonia.Themes.Default/ToggleButton.xaml b/src/Avalonia.Themes.Default/Controls/ToggleButton.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ToggleButton.xaml rename to src/Avalonia.Themes.Default/Controls/ToggleButton.xaml diff --git a/src/Avalonia.Themes.Default/ToggleSwitch.xaml b/src/Avalonia.Themes.Default/Controls/ToggleSwitch.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ToggleSwitch.xaml rename to src/Avalonia.Themes.Default/Controls/ToggleSwitch.xaml diff --git a/src/Avalonia.Themes.Default/ToolTip.xaml b/src/Avalonia.Themes.Default/Controls/ToolTip.xaml similarity index 100% rename from src/Avalonia.Themes.Default/ToolTip.xaml rename to src/Avalonia.Themes.Default/Controls/ToolTip.xaml diff --git a/src/Avalonia.Themes.Default/TreeView.xaml b/src/Avalonia.Themes.Default/Controls/TreeView.xaml similarity index 100% rename from src/Avalonia.Themes.Default/TreeView.xaml rename to src/Avalonia.Themes.Default/Controls/TreeView.xaml diff --git a/src/Avalonia.Themes.Default/TreeViewItem.xaml b/src/Avalonia.Themes.Default/Controls/TreeViewItem.xaml similarity index 100% rename from src/Avalonia.Themes.Default/TreeViewItem.xaml rename to src/Avalonia.Themes.Default/Controls/TreeViewItem.xaml diff --git a/src/Avalonia.Themes.Default/UserControl.xaml b/src/Avalonia.Themes.Default/Controls/UserControl.xaml similarity index 100% rename from src/Avalonia.Themes.Default/UserControl.xaml rename to src/Avalonia.Themes.Default/Controls/UserControl.xaml diff --git a/src/Avalonia.Themes.Default/Window.xaml b/src/Avalonia.Themes.Default/Controls/Window.xaml similarity index 100% rename from src/Avalonia.Themes.Default/Window.xaml rename to src/Avalonia.Themes.Default/Controls/Window.xaml diff --git a/src/Avalonia.Themes.Default/WindowNotificationManager.xaml b/src/Avalonia.Themes.Default/Controls/WindowNotificationManager.xaml similarity index 100% rename from src/Avalonia.Themes.Default/WindowNotificationManager.xaml rename to src/Avalonia.Themes.Default/Controls/WindowNotificationManager.xaml diff --git a/src/Avalonia.Themes.Default/DefaultTheme.xaml b/src/Avalonia.Themes.Default/DefaultTheme.xaml index 109fde390c..702fcc7c7a 100644 --- a/src/Avalonia.Themes.Default/DefaultTheme.xaml +++ b/src/Avalonia.Themes.Default/DefaultTheme.xaml @@ -2,65 +2,65 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Avalonia.Themes.Default.DefaultTheme"> - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Default/DefaultTheme.xaml.cs b/src/Avalonia.Themes.Default/DefaultTheme.xaml.cs index effdb88537..598b418977 100644 --- a/src/Avalonia.Themes.Default/DefaultTheme.xaml.cs +++ b/src/Avalonia.Themes.Default/DefaultTheme.xaml.cs @@ -1,4 +1,3 @@ -using Avalonia.Markup.Xaml; using Avalonia.Styling; namespace Avalonia.Themes.Default diff --git a/src/Avalonia.Themes.Default/SimpleTheme.cs b/src/Avalonia.Themes.Default/SimpleTheme.cs new file mode 100644 index 0000000000..afdd959182 --- /dev/null +++ b/src/Avalonia.Themes.Default/SimpleTheme.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using Avalonia.Markup.Xaml.Styling; +using Avalonia.Styling; +#nullable enable + +namespace Avalonia.Themes.Default +{ + public class SimpleTheme : AvaloniaObject, IStyle, IResourceProvider + { + private readonly Uri _baseUri; + private bool _isLoading; + private Styles _simpleDark = new(); + private Styles _simpleLight = new(); + private IStyle? _loaded; + + /// + /// Initializes a new instance of the class. + /// + /// The base URL for the XAML context. + public SimpleTheme(Uri baseUri) + { + _baseUri = baseUri; + InitStyles(_baseUri); + } + + /// + /// Initializes a new instance of the class. + /// + /// The XAML service provider. + public SimpleTheme(IServiceProvider serviceProvider) + { + _baseUri = ((IUriContext)serviceProvider.GetService(typeof(IUriContext))).BaseUri; + InitStyles(_baseUri); + } + + public static readonly StyledProperty ModeProperty = + AvaloniaProperty.Register(nameof(Mode)); + /// + /// Gets or sets the mode of the fluent theme (light, dark). + /// + public SimpleThemeMode Mode + { + get => GetValue(ModeProperty); + set => SetValue(ModeProperty, value); + } + public IStyle Loaded + { + get + { + if (_loaded == null) + { + _isLoading = true; + + if (Mode == SimpleThemeMode.Light) + { + _loaded = _simpleLight; + } + else if (Mode == SimpleThemeMode.Dark) + { + _loaded = _simpleDark; + } + _isLoading = false; + } + + return _loaded!; + } + } + + public IResourceHost? Owner => (Loaded as IResourceProvider)?.Owner; + + bool IResourceNode.HasResources => (Loaded as IResourceProvider)?.HasResources ?? false; + + IReadOnlyList IStyle.Children => _loaded?.Children ?? Array.Empty(); + + public event EventHandler OwnerChanged + { + add + { + if (Loaded is IResourceProvider rp) + { + rp.OwnerChanged += value; + } + } + remove + { + if (Loaded is IResourceProvider rp) + { + rp.OwnerChanged -= value; + } + } + } + + public SelectorMatchResult TryAttach(IStyleable target, IStyleHost? host) => Loaded.TryAttach(target, host); + + public bool TryGetResource(object key, out object? value) + { + if (!_isLoading && Loaded is IResourceProvider p) + { + return p.TryGetResource(key, out value); + } + + value = null; + return false; + } + + void IResourceProvider.AddOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.AddOwner(owner); + void IResourceProvider.RemoveOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.RemoveOwner(owner); + private void InitStyles(Uri baseUri) + { + + _simpleLight = new Styles + { + new StyleInclude(baseUri) + { + Source = new Uri("avares://Avalonia.Themes.Default/Accents/BaseLight.xaml") + }, + new StyleInclude(baseUri) + { + Source = new Uri("avares://Avalonia.Themes.Default/DefaultTheme.xaml") + } + }; + + _simpleDark = new Styles + { + new StyleInclude(baseUri) + { + Source = new Uri("avares://Avalonia.Themes.Default/Accents/BaseDark.xaml") + }, + new StyleInclude(baseUri) + { + Source = new Uri("avares://Avalonia.Themes.Default/DefaultTheme.xaml") + } + }; + } + + } +} diff --git a/src/Avalonia.Themes.Default/SimpleThemeMode.cs b/src/Avalonia.Themes.Default/SimpleThemeMode.cs new file mode 100644 index 0000000000..be33466327 --- /dev/null +++ b/src/Avalonia.Themes.Default/SimpleThemeMode.cs @@ -0,0 +1,8 @@ +namespace Avalonia.Themes.Default +{ + public enum SimpleThemeMode + { + Light, + Dark + } +} From 25c51567251865fcc3d5ef892c74bd1446597e92 Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Thu, 13 Jan 2022 17:53:31 +0200 Subject: [PATCH 04/13] wip --- samples/ControlCatalog/App.xaml.cs | 21 +++-------- samples/ControlCatalog/MainView.xaml.cs | 2 + src/Avalonia.Themes.Default/SimpleTheme.cs | 44 ++++++++++++++++------ 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/samples/ControlCatalog/App.xaml.cs b/samples/ControlCatalog/App.xaml.cs index 505f486a6d..f6d382f99d 100644 --- a/samples/ControlCatalog/App.xaml.cs +++ b/samples/ControlCatalog/App.xaml.cs @@ -5,6 +5,7 @@ using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml.Styling; using Avalonia.Styling; +using Avalonia.Themes.Default; using Avalonia.Themes.Fluent; using ControlCatalog.ViewModels; @@ -29,6 +30,8 @@ namespace ControlCatalog public static FluentTheme Fluent = new FluentTheme(new Uri("avares://ControlCatalog/Styles")); + public static SimpleTheme Default = new SimpleTheme(new Uri("avares://ControlCatalog/Styles")); + public static Styles DefaultLight = new Styles { new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) @@ -43,14 +46,7 @@ namespace ControlCatalog { Source = new Uri("avares://Avalonia.Themes.Fluent/Accents/BaseLight.xaml") }, - new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) - { - Source = new Uri("avares://Avalonia.Themes.Default/Accents/BaseLight.xaml") - }, - new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) - { - Source = new Uri("avares://Avalonia.Themes.Default/DefaultTheme.xaml") - } + Default }; public static Styles DefaultDark = new Styles @@ -67,14 +63,7 @@ namespace ControlCatalog { Source = new Uri("avares://Avalonia.Themes.Fluent/Accents/BaseDark.xaml") }, - new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) - { - Source = new Uri("avares://Avalonia.Themes.Default/Accents/BaseDark.xaml") - }, - new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) - { - Source = new Uri("avares://Avalonia.Themes.Default/DefaultTheme.xaml") - } + Default }; public override void Initialize() diff --git a/samples/ControlCatalog/MainView.xaml.cs b/samples/ControlCatalog/MainView.xaml.cs index 0579355831..79cf07c8d9 100644 --- a/samples/ControlCatalog/MainView.xaml.cs +++ b/samples/ControlCatalog/MainView.xaml.cs @@ -63,11 +63,13 @@ namespace ControlCatalog } else if (theme == CatalogTheme.DefaultLight) { + App.Default.Mode = Avalonia.Themes.Default.SimpleThemeMode.Light; Application.Current.Styles[0] = App.DefaultLight; Application.Current.Styles[1] = App.DataGridDefault; } else if (theme == CatalogTheme.DefaultDark) { + App.Default.Mode = Avalonia.Themes.Default.SimpleThemeMode.Dark; Application.Current.Styles[0] = App.DefaultDark; Application.Current.Styles[1] = App.DataGridDefault; } diff --git a/src/Avalonia.Themes.Default/SimpleTheme.cs b/src/Avalonia.Themes.Default/SimpleTheme.cs index afdd959182..f5daf9ce55 100644 --- a/src/Avalonia.Themes.Default/SimpleTheme.cs +++ b/src/Avalonia.Themes.Default/SimpleTheme.cs @@ -14,6 +14,7 @@ namespace Avalonia.Themes.Default private bool _isLoading; private Styles _simpleDark = new(); private Styles _simpleLight = new(); + private Styles _sharedStyles = new(); private IStyle? _loaded; /// @@ -32,7 +33,12 @@ namespace Avalonia.Themes.Default /// The XAML service provider. public SimpleTheme(IServiceProvider serviceProvider) { - _baseUri = ((IUriContext)serviceProvider.GetService(typeof(IUriContext))).BaseUri; + var service = serviceProvider.GetService(typeof(IUriContext)); + if (service == null) + { + throw new Exception("There is no service object of type IUriContext!"); + } + _baseUri = ((IUriContext)service).BaseUri; InitStyles(_baseUri); } @@ -46,6 +52,22 @@ namespace Avalonia.Themes.Default get => GetValue(ModeProperty); set => SetValue(ModeProperty, value); } + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + if (change.Property == ModeProperty) + { + if (Mode == SimpleThemeMode.Dark) + { + (Loaded as Styles)![1] = _simpleDark[0]; + } + else + { + (Loaded as Styles)![1] = _simpleLight[0]; + } + } + } + public IStyle Loaded { get @@ -56,11 +78,11 @@ namespace Avalonia.Themes.Default if (Mode == SimpleThemeMode.Light) { - _loaded = _simpleLight; + _loaded = new Styles { _sharedStyles , _simpleLight}; } else if (Mode == SimpleThemeMode.Dark) { - _loaded = _simpleDark; + _loaded = new Styles { _sharedStyles, _simpleDark }; } _isLoading = false; } @@ -110,16 +132,18 @@ namespace Avalonia.Themes.Default void IResourceProvider.RemoveOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.RemoveOwner(owner); private void InitStyles(Uri baseUri) { - - _simpleLight = new Styles + _sharedStyles = new Styles { new StyleInclude(baseUri) { - Source = new Uri("avares://Avalonia.Themes.Default/Accents/BaseLight.xaml") - }, + Source = new Uri("avares://Avalonia.Themes.Default/DefaultTheme.xaml") + } + }; + _simpleLight = new Styles + { new StyleInclude(baseUri) { - Source = new Uri("avares://Avalonia.Themes.Default/DefaultTheme.xaml") + Source = new Uri("avares://Avalonia.Themes.Default/Accents/BaseLight.xaml") } }; @@ -128,10 +152,6 @@ namespace Avalonia.Themes.Default new StyleInclude(baseUri) { Source = new Uri("avares://Avalonia.Themes.Default/Accents/BaseDark.xaml") - }, - new StyleInclude(baseUri) - { - Source = new Uri("avares://Avalonia.Themes.Default/DefaultTheme.xaml") } }; } From 31cdd4e0b0ee7038c82c85200f22cb4ffc302c5b Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Thu, 13 Jan 2022 18:01:01 +0200 Subject: [PATCH 05/13] reformat --- src/Avalonia.Themes.Default/SimpleTheme.cs | 88 +++++++++++----------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/src/Avalonia.Themes.Default/SimpleTheme.cs b/src/Avalonia.Themes.Default/SimpleTheme.cs index f5daf9ce55..c0aba17818 100644 --- a/src/Avalonia.Themes.Default/SimpleTheme.cs +++ b/src/Avalonia.Themes.Default/SimpleTheme.cs @@ -10,13 +10,15 @@ namespace Avalonia.Themes.Default { public class SimpleTheme : AvaloniaObject, IStyle, IResourceProvider { + public static readonly StyledProperty ModeProperty = + AvaloniaProperty.Register(nameof(Mode)); + private readonly Uri _baseUri; private bool _isLoading; + private IStyle? _loaded; + private Styles _sharedStyles = new(); private Styles _simpleDark = new(); private Styles _simpleLight = new(); - private Styles _sharedStyles = new(); - private IStyle? _loaded; - /// /// Initializes a new instance of the class. /// @@ -42,32 +44,28 @@ namespace Avalonia.Themes.Default InitStyles(_baseUri); } - public static readonly StyledProperty ModeProperty = - AvaloniaProperty.Register(nameof(Mode)); - /// - /// Gets or sets the mode of the fluent theme (light, dark). - /// - public SimpleThemeMode Mode - { - get => GetValue(ModeProperty); - set => SetValue(ModeProperty, value); - } - protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + public event EventHandler OwnerChanged { - base.OnPropertyChanged(change); - if (change.Property == ModeProperty) + add { - if (Mode == SimpleThemeMode.Dark) + if (Loaded is IResourceProvider rp) { - (Loaded as Styles)![1] = _simpleDark[0]; + rp.OwnerChanged += value; } - else + } + remove + { + if (Loaded is IResourceProvider rp) { - (Loaded as Styles)![1] = _simpleLight[0]; + rp.OwnerChanged -= value; } } } + IReadOnlyList IStyle.Children => _loaded?.Children ?? Array.Empty(); + + bool IResourceNode.HasResources => (Loaded as IResourceProvider)?.HasResources ?? false; + public IStyle Loaded { get @@ -78,7 +76,7 @@ namespace Avalonia.Themes.Default if (Mode == SimpleThemeMode.Light) { - _loaded = new Styles { _sharedStyles , _simpleLight}; + _loaded = new Styles { _sharedStyles, _simpleLight }; } else if (Mode == SimpleThemeMode.Dark) { @@ -91,29 +89,19 @@ namespace Avalonia.Themes.Default } } + /// + /// Gets or sets the mode of the fluent theme (light, dark). + /// + public SimpleThemeMode Mode + { + get => GetValue(ModeProperty); + set => SetValue(ModeProperty, value); + } public IResourceHost? Owner => (Loaded as IResourceProvider)?.Owner; - bool IResourceNode.HasResources => (Loaded as IResourceProvider)?.HasResources ?? false; - - IReadOnlyList IStyle.Children => _loaded?.Children ?? Array.Empty(); + void IResourceProvider.AddOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.AddOwner(owner); - public event EventHandler OwnerChanged - { - add - { - if (Loaded is IResourceProvider rp) - { - rp.OwnerChanged += value; - } - } - remove - { - if (Loaded is IResourceProvider rp) - { - rp.OwnerChanged -= value; - } - } - } + void IResourceProvider.RemoveOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.RemoveOwner(owner); public SelectorMatchResult TryAttach(IStyleable target, IStyleHost? host) => Loaded.TryAttach(target, host); @@ -128,8 +116,22 @@ namespace Avalonia.Themes.Default return false; } - void IResourceProvider.AddOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.AddOwner(owner); - void IResourceProvider.RemoveOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.RemoveOwner(owner); + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + if (change.Property == ModeProperty) + { + if (Mode == SimpleThemeMode.Dark) + { + (Loaded as Styles)![1] = _simpleDark[0]; + } + else + { + (Loaded as Styles)![1] = _simpleLight[0]; + } + } + } + private void InitStyles(Uri baseUri) { _sharedStyles = new Styles From 5a4e05fee3ae425fe0e2bd71d58226b45a26b59c Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Thu, 13 Jan 2022 18:25:53 +0200 Subject: [PATCH 06/13] wip --- src/Avalonia.Themes.Default/Accents/Base.xaml | 64 +++++++++++++++ .../Accents/BaseDark.xaml | 77 ++++------------- .../Accents/BaseLight.xaml | 82 +++++-------------- src/Avalonia.Themes.Default/SimpleTheme.cs | 4 + 4 files changed, 105 insertions(+), 122 deletions(-) create mode 100644 src/Avalonia.Themes.Default/Accents/Base.xaml diff --git a/src/Avalonia.Themes.Default/Accents/Base.xaml b/src/Avalonia.Themes.Default/Accents/Base.xaml new file mode 100644 index 0000000000..1f7d703b54 --- /dev/null +++ b/src/Avalonia.Themes.Default/Accents/Base.xaml @@ -0,0 +1,64 @@ + diff --git a/src/Avalonia.Themes.Default/Accents/BaseDark.xaml b/src/Avalonia.Themes.Default/Accents/BaseDark.xaml index 5f18bac44a..7ab89d96e4 100644 --- a/src/Avalonia.Themes.Default/Accents/BaseDark.xaml +++ b/src/Avalonia.Themes.Default/Accents/BaseDark.xaml @@ -1,13 +1,9 @@ - diff --git a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml index 30c6d39856..62ed6883c1 100644 --- a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml +++ b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml @@ -1,82 +1,38 @@ - diff --git a/src/Avalonia.Themes.Default/SimpleTheme.cs b/src/Avalonia.Themes.Default/SimpleTheme.cs index c0aba17818..1d9f2d5f9d 100644 --- a/src/Avalonia.Themes.Default/SimpleTheme.cs +++ b/src/Avalonia.Themes.Default/SimpleTheme.cs @@ -139,6 +139,10 @@ namespace Avalonia.Themes.Default new StyleInclude(baseUri) { Source = new Uri("avares://Avalonia.Themes.Default/DefaultTheme.xaml") + }, + new StyleInclude(baseUri) + { + Source = new Uri("avares://Avalonia.Themes.Default/Accents/Base.xaml") } }; _simpleLight = new Styles From eabc2be815d713712a3784edeb7f36df69b76965 Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Thu, 13 Jan 2022 18:28:57 +0200 Subject: [PATCH 07/13] wip --- .../Accents/BaseDark.xaml | 28 +++++++++---------- .../Accents/BaseLight.xaml | 26 ++++++++--------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Avalonia.Themes.Default/Accents/BaseDark.xaml b/src/Avalonia.Themes.Default/Accents/BaseDark.xaml index 7ab89d96e4..1843abebfd 100644 --- a/src/Avalonia.Themes.Default/Accents/BaseDark.xaml +++ b/src/Avalonia.Themes.Default/Accents/BaseDark.xaml @@ -19,20 +19,20 @@ #FFDEDEDE #FF119EDA - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml index 62ed6883c1..8f6155e481 100644 --- a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml +++ b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml @@ -19,19 +19,19 @@ #FF000000 #FF086F9E - - - - - - - - - - - - - + + + + + + + + + + + + + From d9df6cf15f8b3f4ed816904d4527c0a13b4811bd Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Thu, 13 Jan 2022 18:33:50 +0200 Subject: [PATCH 08/13] wip --- src/Avalonia.Themes.Default/Accents/BaseLight.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml index 8f6155e481..6247815303 100644 --- a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml +++ b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml @@ -33,6 +33,6 @@ - + From ddb8f9c7deb71125f45f125d5bb2a8410c62aa7e Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 14 Jan 2022 13:21:52 +0100 Subject: [PATCH 09/13] Update unit tests to use new default theme URLs. --- tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs | 2 +- tests/Avalonia.UnitTests/TestServices.cs | 2 +- tests/Avalonia.UnitTests/UnitTestApplication.cs | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs index 6db4b9e624..f20faa2287 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs @@ -528,7 +528,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml var xaml = @" - + "; var styles = AvaloniaRuntimeXamlLoader.Parse(xaml); diff --git a/tests/Avalonia.UnitTests/TestServices.cs b/tests/Avalonia.UnitTests/TestServices.cs index 8d27562146..1e586e3bb1 100644 --- a/tests/Avalonia.UnitTests/TestServices.cs +++ b/tests/Avalonia.UnitTests/TestServices.cs @@ -168,7 +168,7 @@ namespace Avalonia.UnitTests }; var baseLight = (IStyle)AvaloniaXamlLoader.Load( - new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default")); + new Uri("avares://Avalonia.Themes.Default/Accents/BaseLight.xaml")); result.Add(baseLight); return result; diff --git a/tests/Avalonia.UnitTests/UnitTestApplication.cs b/tests/Avalonia.UnitTests/UnitTestApplication.cs index 2d37057779..dc10754ea2 100644 --- a/tests/Avalonia.UnitTests/UnitTestApplication.cs +++ b/tests/Avalonia.UnitTests/UnitTestApplication.cs @@ -10,6 +10,7 @@ using System.Reactive.Disposables; using System.Reactive.Concurrency; using Avalonia.Input.Platform; using Avalonia.Animation; +using Avalonia.Shared.PlatformSupport; namespace Avalonia.UnitTests { @@ -29,6 +30,11 @@ namespace Avalonia.UnitTests RegisterServices(); } + static UnitTestApplication() + { + AssetLoader.RegisterResUriParsers(); + } + public static new UnitTestApplication Current => (UnitTestApplication)Application.Current; public TestServices Services => _services; From 54d83f65c3bf281595048591e38107fecc50ab7b Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Fri, 14 Jan 2022 15:49:42 +0200 Subject: [PATCH 10/13] fix tests --- tests/Avalonia.DesignerSupport.TestApp/App.xaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/Avalonia.DesignerSupport.TestApp/App.xaml b/tests/Avalonia.DesignerSupport.TestApp/App.xaml index 56c0e8059a..5a33ffff80 100644 --- a/tests/Avalonia.DesignerSupport.TestApp/App.xaml +++ b/tests/Avalonia.DesignerSupport.TestApp/App.xaml @@ -1,8 +1,10 @@ - + - - + + + From bb0dd4168217a03637bd97d083fd725307a3097b Mon Sep 17 00:00:00 2001 From: JamDoggie Date: Sun, 16 Jan 2022 04:11:39 -0500 Subject: [PATCH 11/13] Set antialias to true when calling ClipRoundRect --- src/Skia/Avalonia.Skia/DrawingContextImpl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs index 4dedd27445..acec8ac0e7 100644 --- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs +++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs @@ -482,7 +482,7 @@ namespace Avalonia.Skia public void PushClip(RoundedRect clip) { Canvas.Save(); - Canvas.ClipRoundRect(clip.ToSKRoundRect()); + Canvas.ClipRoundRect(clip.ToSKRoundRect(), antialias:true); } /// From 8dd4271c475feb14496fe88b0720f55f64aafe06 Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Mon, 17 Jan 2022 14:04:00 +0200 Subject: [PATCH 12/13] revert unwanted change --- .../Resources/Resource.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Android/Avalonia.AndroidTestApplication/Resources/Resource.Designer.cs b/src/Android/Avalonia.AndroidTestApplication/Resources/Resource.Designer.cs index 3f11aa9593..87fd47df25 100644 --- a/src/Android/Avalonia.AndroidTestApplication/Resources/Resource.Designer.cs +++ b/src/Android/Avalonia.AndroidTestApplication/Resources/Resource.Designer.cs @@ -14,7 +14,7 @@ namespace Avalonia.AndroidTestApplication { - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.1.0.11")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.1.99.62")] public partial class Resource { From a7e79211385c9aa89960d835ddb14fd63e6dde1a Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Tue, 18 Jan 2022 13:09:25 +0200 Subject: [PATCH 13/13] Use new syntax for simple theme and fix the crash. --- src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml b/src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml index 45bfe5ff81..c32638f6ca 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml @@ -2,6 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:views="clr-namespace:Avalonia.Diagnostics.Views" xmlns:diag="clr-namespace:Avalonia.Diagnostics" + xmlns:default="using:Avalonia.Themes.Default" Title="Avalonia DevTools" x:Class="Avalonia.Diagnostics.Views.MainWindow"> @@ -9,8 +10,7 @@ - - +