From 03b080ae047d9e5f8c649966bd4ba159ce9c638e Mon Sep 17 00:00:00 2001 From: robloo Date: Tue, 21 Jun 2022 20:44:22 -0400 Subject: [PATCH] Remove 'Custom' term from Palette properties --- .../ColorView/ColorView.Properties.cs | 122 ++++++++++-------- .../ColorView/ColorView.cs | 12 +- .../Themes/Fluent/ColorPicker.xaml | 6 +- .../Themes/Fluent/ColorView.xaml | 6 +- 4 files changed, 81 insertions(+), 65 deletions(-) diff --git a/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs b/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs index 8c58834c97..bed27ecb73 100644 --- a/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs +++ b/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs @@ -44,30 +44,6 @@ namespace Avalonia.Controls nameof(ColorSpectrumShape), ColorSpectrumShape.Box); - /// - /// Defines the property. - /// - public static readonly DirectProperty> CustomPaletteColorsProperty = - AvaloniaProperty.RegisterDirect>( - nameof(CustomPaletteColors), - o => o.CustomPaletteColors); - - /// - /// Defines the property. - /// - public static readonly StyledProperty CustomPaletteColumnCountProperty = - AvaloniaProperty.Register( - nameof(CustomPaletteColumnCount), - 4); - - /// - /// Defines the property. - /// - public static readonly StyledProperty CustomPaletteProperty = - AvaloniaProperty.Register( - nameof(CustomPalette), - null); - /// /// Defines the property. /// @@ -197,6 +173,30 @@ namespace Avalonia.Controls nameof(MinValue), 0); + /// + /// Defines the property. + /// + public static readonly DirectProperty> PaletteColorsProperty = + AvaloniaProperty.RegisterDirect>( + nameof(PaletteColors), + o => o.PaletteColors); + + /// + /// Defines the property. + /// + public static readonly StyledProperty PaletteColumnCountProperty = + AvaloniaProperty.Register( + nameof(PaletteColumnCount), + 4); + + /// + /// Defines the property. + /// + public static readonly StyledProperty PaletteProperty = + AvaloniaProperty.Register( + nameof(Palette), + null); + /// /// Defines the property. /// @@ -245,35 +245,6 @@ namespace Avalonia.Controls set => SetValue(ColorSpectrumShapeProperty, value); } - /// - /// Gets the list of custom palette colors. - /// - public ObservableCollection CustomPaletteColors - { - get => _customPaletteColors; - } - - /// - /// Gets or sets the number of colors in each row (section) of the custom color palette. - /// Within a standard palette, rows are shades and columns are colors. - /// - public int CustomPaletteColumnCount - { - get => GetValue(CustomPaletteColumnCountProperty); - set => SetValue(CustomPaletteColumnCountProperty, value); - } - - /// - /// Gets or sets the custom color palette. - /// This will automatically set and - /// overwriting any existing values. - /// - public IColorPalette? CustomPalette - { - get => GetValue(CustomPaletteProperty); - set => SetValue(CustomPaletteProperty, value); - } - /// public HsvColor HsvColor { @@ -420,6 +391,51 @@ namespace Avalonia.Controls set => SetValue(MinValueProperty, value); } + /// + /// Gets the list of individual colors in the palette. + /// + /// + /// This is not commonly set manually. Instead, it should be set automatically by + /// providing an to the property. + ///

+ /// Also note that this property is what should be bound in the control template. + /// is too high-level to use on its own. + ///
+ public ObservableCollection PaletteColors + { + get => _paletteColors; + } + + /// + /// Gets or sets the number of colors in each row (section) of the color palette. + /// Within a standard palette, rows are shades and columns are colors. + /// + /// + /// This is not commonly set manually. Instead, it should be set automatically by + /// providing an to the property. + ///

+ /// Also note that this property is what should be bound in the control template. + /// is too high-level to use on its own. + ///
+ public int PaletteColumnCount + { + get => GetValue(PaletteColumnCountProperty); + set => SetValue(PaletteColumnCountProperty, value); + } + + /// + /// Gets or sets the color palette. + /// + /// + /// This will automatically set both and + /// overwriting any existing values. + /// + public IColorPalette? Palette + { + get => GetValue(PaletteProperty); + set => SetValue(PaletteProperty, value); + } + /// /// Gets or sets the index of the selected tab/panel/page (subview). /// diff --git a/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs b/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs index 194b4a2f06..659318edb0 100644 --- a/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs +++ b/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs @@ -25,7 +25,7 @@ namespace Avalonia.Controls private TextBox? _hexTextBox; private TabControl? _tabControl; - private ObservableCollection _customPaletteColors = new ObservableCollection(); + private ObservableCollection _paletteColors = new ObservableCollection(); private ColorToHexConverter colorToHexConverter = new ColorToHexConverter(); protected bool ignorePropertyChanged = false; @@ -214,22 +214,22 @@ namespace Avalonia.Controls ignorePropertyChanged = false; } - else if (change.Property == CustomPaletteProperty) + else if (change.Property == PaletteProperty) { - IColorPalette? palette = CustomPalette; + IColorPalette? palette = Palette; // Any custom palette change must be automatically synced with the // bound properties controlling the palette grid if (palette != null) { - CustomPaletteColumnCount = palette.ColorCount; - CustomPaletteColors.Clear(); + PaletteColumnCount = palette.ColorCount; + PaletteColors.Clear(); for (int shadeIndex = 0; shadeIndex < palette.ShadeCount; shadeIndex++) { for (int colorIndex = 0; colorIndex < palette.ColorCount; colorIndex++) { - CustomPaletteColors.Add(palette.GetColor(colorIndex, shadeIndex)); + PaletteColors.Add(palette.GetColor(colorIndex, shadeIndex)); } } } diff --git a/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml b/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml index 2b8bdf74e1..f6fb3236af 100644 --- a/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml +++ b/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml @@ -46,15 +46,13 @@ diff --git a/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorView.xaml b/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorView.xaml index 62aafa67ad..3758a37120 100644 --- a/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorView.xaml +++ b/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorView.xaml @@ -81,7 +81,7 @@