From ca85843f99b26c7377ad81414df25567bb3f9d8e Mon Sep 17 00:00:00 2001 From: robloo Date: Sun, 23 Oct 2022 16:20:16 -0400 Subject: [PATCH] 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 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +