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 3b42940770d638f59501dca59276cb29bd2e8372 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 28 Oct 2022 11:48:27 +0100 Subject: [PATCH 4/4] use didResignKey notification instead of override resignKey --- native/Avalonia.Native/src/OSX/AvnWindow.mm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/native/Avalonia.Native/src/OSX/AvnWindow.mm b/native/Avalonia.Native/src/OSX/AvnWindow.mm index ebd9f39d30..4c7341f834 100644 --- a/native/Avalonia.Native/src/OSX/AvnWindow.mm +++ b/native/Avalonia.Native/src/OSX/AvnWindow.mm @@ -385,7 +385,7 @@ return true; } --(void)resignKeyWindow +-(void)windowDidResignKey:(NSNotification *)notification { if(_parent) _parent->BaseEvents->Deactivated(); @@ -393,8 +393,6 @@ [self showAppMenuOnly]; [self invalidateShadow]; - - [super resignKeyWindow]; } - (void)windowDidMove:(NSNotification *_Nonnull)notification