Browse Source

Revert "Add and implement IsHostedInColorPicker property to ColorView"

This reverts commit 2575a10fb0.
pull/9140/head
robloo 4 years ago
parent
commit
7b69d2ae57
  1. 3
      src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs
  2. 24
      src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs
  3. 20
      src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs
  4. 4
      src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml

3
src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs

@ -11,6 +11,9 @@
/// </summary>
public ColorPicker() : base()
{
// Completely ignore property changes here
// The ColorView in the control template is responsible to manage this
base.ignorePropertyChanged = true;
}
}
}

24
src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs

@ -148,14 +148,6 @@ namespace Avalonia.Controls
nameof(IsHexInputVisible),
true);
/// <summary>
/// Defines the <see cref="IsHostedInColorPicker"/> property.
/// </summary>
public static readonly StyledProperty<bool> IsHostedInColorPickerProperty =
AvaloniaProperty.Register<ColorView, bool>(
nameof(IsHostedInColorPicker),
false);
/// <summary>
/// Defines the <see cref="MaxHue"/> property.
/// </summary>
@ -403,22 +395,6 @@ namespace Avalonia.Controls
set => SetValue(IsHexInputVisibleProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether this <see cref="ColorView"/> is hosted
/// inside a <see cref="ColorPicker"/>'s control template.
/// </summary>
/// <remarks>
/// This is a special property to change how the <see cref="ColorView"/> internally
/// processes property updates. When a <see cref="ColorView"/> is hosted within a
/// <see cref="ColorPicker"/>, it does not need to handle most property changes.
/// Instead, the primary calculations are done within the <see cref="ColorPicker"/> itself.
/// </remarks>
public bool IsHostedInColorPicker
{
get => GetValue(IsHostedInColorPickerProperty);
set => SetValue(IsHostedInColorPickerProperty, value);
}
/// <inheritdoc cref="ColorSpectrum.MaxHue"/>
public int MaxHue
{

20
src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs

@ -206,26 +206,6 @@ namespace Avalonia.Controls
return;
}
// Special handling for when hosted within a ColorPicker and the ColorPicker is
// responsible for most of the internal processing and property updates.
if (IsHostedInColorPicker)
{
if (change.Property == ColorProperty ||
change.Property == HsvColorProperty)
{
ignorePropertyChanged = true;
// The Hex text isn't currently bound with the ColorPicker and therefore
// must still be updated here.
SetColorToHexTextBox();
ignorePropertyChanged = false;
}
base.OnPropertyChanged(change);
return;
}
// Always keep the two color properties in sync
if (change.Property == ColorProperty)
{

4
src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorPicker.xaml

@ -43,11 +43,7 @@
</DropDownButton.Content>
<DropDownButton.Flyout>
<Flyout FlyoutPresenterClasses="nopadding">
<!-- Note that IsHostedInColorPicker should always be set first.
This tells the ColorView to avoid some internal processing that may
conflict with the ColorPicker that is now the primary control. -->
<ColorView x:Name="FlyoutColorView"
IsHostedInColorPicker="True"
Color="{Binding Color, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
ColorModel="{Binding ColorModel, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
ColorSpectrumComponents="{TemplateBinding ColorSpectrumComponents}"

Loading…
Cancel
Save