From c959c0594ff111f2e1a9342cfe046a3a4d7a50c7 Mon Sep 17 00:00:00 2001 From: robloo Date: Sun, 23 Oct 2022 16:08:09 -0400 Subject: [PATCH 1/4] Update palettes used in the ColorPickerPage --- .../ControlCatalog/Pages/ColorPickerPage.xaml | 21 ++++++++++++++++--- .../Pages/ColorPickerPage.xaml.cs | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/samples/ControlCatalog/Pages/ColorPickerPage.xaml b/samples/ControlCatalog/Pages/ColorPickerPage.xaml index 69ceaea328..c0bb95ae92 100644 --- a/samples/ControlCatalog/Pages/ColorPickerPage.xaml +++ b/samples/ControlCatalog/Pages/ColorPickerPage.xaml @@ -24,18 +24,19 @@ HsvColor="hsv(120, 1, 1)" Margin="0,50,0,0"> - + + RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"> + - + + diff --git a/samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs b/samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs index 4671bbdb7c..52d63ded32 100644 --- a/samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs @@ -20,6 +20,7 @@ namespace ControlCatalog.Pages Color = Colors.Blue, Margin = new Thickness(0, 50, 0, 0), HorizontalAlignment = HorizontalAlignment.Center, + Palette = new MaterialHalfColorPalette(), }; Grid.SetColumn(colorPicker, 2); Grid.SetRow(colorPicker, 1); From ca85843f99b26c7377ad81414df25567bb3f9d8e Mon Sep 17 00:00:00 2001 From: robloo Date: Sun, 23 Oct 2022 16:20:16 -0400 Subject: [PATCH 2/4] Rework ColorPicker control template duplicating from ColorView --- .../ColorPicker/ColorPicker.cs | 28 - .../Themes/Fluent/ColorPicker.xaml | 484 +++++++++++++++-- .../Themes/Simple/ColorPicker.xaml | 486 ++++++++++++++++-- 3 files changed, 907 insertions(+), 91 deletions(-) diff --git a/src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs b/src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs index 29f9f3c571..01cb745ba7 100644 --- a/src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs +++ b/src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs @@ -14,33 +14,5 @@ namespace Avalonia.Controls public ColorPicker() : base() { } - - /// - protected override void OnApplyTemplate(TemplateAppliedEventArgs e) - { - base.OnApplyTemplate(e); - - // Until this point the ColorPicker itself is responsible to process property updates. - // This, for example, syncs Color with HsvColor and updates primitive controls. - // - // However, when the template is created, hand-off this change processing to the - // ColorView within the control template itself. Remember ColorPicker derives from - // ColorView so we don't want two instances of the same logic fighting each other. - // It is best to hand-off to the ColorView in the control template because that is the - // primary point of user-interaction for the overall control. It also simplifies binding. - // - // Keep in mind this hand-off is not possible until the template controls are created - // which is done after the ColorPicker is instantiated. The ColorPicker must still - // process updates before the template is applied to ensure all property changes in - // XAML or object initializers are handled correctly. Otherwise, there can be bugs - // such as setting the Color property doesn't work because the HsvColor is never updated - // and then the Color value is lost once the template loads (and the template ColorView - // takes over). - // - // In order to complete this hand-off, completely ignore property changes here in the - // ColorPicker. This means the ColorView in the control template is now responsible to - // process property changes and handle primary calculations. - base.ignorePropertyChanged = true; - } } } diff --git a/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml b/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml index 74a1df4991..1bcd17393d 100644 --- a/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml +++ b/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml @@ -1,8 +1,15 @@  + + + + @@ -43,39 +50,454 @@ - - + + + + + 5,5,0,0 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Controls.ColorPicker/Themes/Simple/ColorPicker.xaml b/src/Avalonia.Controls.ColorPicker/Themes/Simple/ColorPicker.xaml index 560d326f92..fdee64dfd2 100644 --- a/src/Avalonia.Controls.ColorPicker/Themes/Simple/ColorPicker.xaml +++ b/src/Avalonia.Controls.ColorPicker/Themes/Simple/ColorPicker.xaml @@ -1,8 +1,15 @@  + + + + @@ -42,40 +49,455 @@ - - - + + + + + + 0,0,0,0 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From ae570453c7b33bd7abdc5cac792a9e306de2cb59 Mon Sep 17 00:00:00 2001 From: robloo Date: Sun, 23 Oct 2022 16:32:52 -0400 Subject: [PATCH 3/4] Allow derived controls to call ColorSpectrum.ThirdComponent.set() --- .../ColorSpectrum/ColorSpectrum.Properties.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls.ColorPicker/ColorSpectrum/ColorSpectrum.Properties.cs b/src/Avalonia.Controls.ColorPicker/ColorSpectrum/ColorSpectrum.Properties.cs index 39b7b7f660..5c7de2459b 100644 --- a/src/Avalonia.Controls.ColorPicker/ColorSpectrum/ColorSpectrum.Properties.cs +++ b/src/Avalonia.Controls.ColorPicker/ColorSpectrum/ColorSpectrum.Properties.cs @@ -240,7 +240,7 @@ namespace Avalonia.Controls.Primitives public ColorComponent ThirdComponent { get => GetValue(ThirdComponentProperty); - private set => SetValue(ThirdComponentProperty, value); + protected set => SetValue(ThirdComponentProperty, value); } } } From 7278dce4e24c7fb40f143faaec2d9db8c00c774b Mon Sep 17 00:00:00 2001 From: workgroupengineering Date: Fri, 28 Oct 2022 13:24:33 +0200 Subject: [PATCH 4/4] fix: make StringCompatibilityExtensions internal (#9289) * fix: make StringCompatibilityExtensions internal * fix: missnig commit --- Avalonia.sln | 1 + src/Avalonia.Base/Avalonia.Base.csproj | 2 ++ src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj | 5 +++++ .../StringCompatibilityExtensions.cs | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) rename src/{Avalonia.Base/Compatibility => Shared}/StringCompatibilityExtensions.cs (83%) diff --git a/Avalonia.sln b/Avalonia.sln index c000f56d09..461de8530b 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -41,6 +41,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{A689DE src\Shared\IsExternalInit.cs = src\Shared\IsExternalInit.cs src\Shared\ModuleInitializer.cs = src\Shared\ModuleInitializer.cs src\Shared\SourceGeneratorAttributes.cs = src\Shared\SourceGeneratorAttributes.cs + src\Avalonia.Base\Compatibility\StringCompatibilityExtensions.cs = src\Avalonia.Base\Compatibility\StringCompatibilityExtensions.cs EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.ReactiveUI", "src\Avalonia.ReactiveUI\Avalonia.ReactiveUI.csproj", "{6417B24E-49C2-4985-8DB2-3AB9D898EC91}" diff --git a/src/Avalonia.Base/Avalonia.Base.csproj b/src/Avalonia.Base/Avalonia.Base.csproj index 402bc3a099..bdb5882ef2 100644 --- a/src/Avalonia.Base/Avalonia.Base.csproj +++ b/src/Avalonia.Base/Avalonia.Base.csproj @@ -23,6 +23,7 @@ + @@ -46,6 +47,7 @@ + diff --git a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj index d0c39f0289..75746273c2 100644 --- a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj +++ b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj @@ -9,6 +9,7 @@ CS1591 + @@ -68,4 +69,8 @@ + + + + diff --git a/src/Avalonia.Base/Compatibility/StringCompatibilityExtensions.cs b/src/Shared/StringCompatibilityExtensions.cs similarity index 83% rename from src/Avalonia.Base/Compatibility/StringCompatibilityExtensions.cs rename to src/Shared/StringCompatibilityExtensions.cs index 45e41b44d6..7c894dba97 100644 --- a/src/Avalonia.Base/Compatibility/StringCompatibilityExtensions.cs +++ b/src/Shared/StringCompatibilityExtensions.cs @@ -3,7 +3,7 @@ namespace System; #if !NET6_0_OR_GREATER -public static class StringCompatibilityExtensions +internal static class StringCompatibilityExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Contains(this string str, char search) =>