Browse Source

Rename 'ColorPickerHsvChannel' to 'HsvChannel'

pull/7842/head
robloo 5 years ago
parent
commit
96bf2cbc7d
  1. 32
      src/Avalonia.Controls/ColorPicker/ColorSpectrum/ColorHelpers.cs
  2. 24
      src/Avalonia.Controls/ColorPicker/ColorSpectrum/ColorSpectrum.cs
  3. 2
      src/Avalonia.Controls/ColorPicker/HsvChannel.cs

32
src/Avalonia.Controls/ColorPicker/ColorSpectrum/ColorHelpers.cs

@ -28,7 +28,7 @@ namespace Avalonia.Controls.Primitives
public static Hsv IncrementColorChannel( public static Hsv IncrementColorChannel(
Hsv originalHsv, Hsv originalHsv,
ColorPickerHsvChannel channel, HsvChannel channel,
IncrementDirection direction, IncrementDirection direction,
IncrementAmount amount, IncrementAmount amount,
bool shouldWrap, bool shouldWrap,
@ -54,23 +54,23 @@ namespace Avalonia.Controls.Primitives
// for saturation and value, this is every increment of 10. // for saturation and value, this is every increment of 10.
switch (channel) switch (channel)
{ {
case ColorPickerHsvChannel.Hue: case HsvChannel.Hue:
valueToIncrement = ref newHsv.H; valueToIncrement = ref newHsv.H;
incrementAmount = amount == IncrementAmount.Small ? 1 : 30; incrementAmount = amount == IncrementAmount.Small ? 1 : 30;
break; break;
case ColorPickerHsvChannel.Saturation: case HsvChannel.Saturation:
valueToIncrement = ref newHsv.S; valueToIncrement = ref newHsv.S;
incrementAmount = amount == IncrementAmount.Small ? 1 : 10; incrementAmount = amount == IncrementAmount.Small ? 1 : 10;
break; break;
case ColorPickerHsvChannel.Value: case HsvChannel.Value:
valueToIncrement = ref newHsv.V; valueToIncrement = ref newHsv.V;
incrementAmount = amount == IncrementAmount.Small ? 1 : 10; incrementAmount = amount == IncrementAmount.Small ? 1 : 10;
break; break;
default: default:
throw new InvalidOperationException("Invalid ColorPickerHsvChannel."); throw new InvalidOperationException("Invalid HsvChannel.");
} }
double previousValue = valueToIncrement; double previousValue = valueToIncrement;
@ -99,8 +99,8 @@ namespace Avalonia.Controls.Primitives
// While working with named colors, we're going to need to be working in actual HSV units, // While working with named colors, we're going to need to be working in actual HSV units,
// so we'll divide the min bound and max bound by 100 in the case of saturation or value, // so we'll divide the min bound and max bound by 100 in the case of saturation or value,
// since we'll have received units between 0-100 and we need them within 0-1. // since we'll have received units between 0-100 and we need them within 0-1.
if (channel == ColorPickerHsvChannel.Saturation || if (channel == HsvChannel.Saturation ||
channel == ColorPickerHsvChannel.Value) channel == HsvChannel.Value)
{ {
minBound /= 100; minBound /= 100;
maxBound /= 100; maxBound /= 100;
@ -114,7 +114,7 @@ namespace Avalonia.Controls.Primitives
public static Hsv FindNextNamedColor( public static Hsv FindNextNamedColor(
Hsv originalHsv, Hsv originalHsv,
ColorPickerHsvChannel channel, HsvChannel channel,
IncrementDirection direction, IncrementDirection direction,
bool shouldWrap, bool shouldWrap,
double minBound, double minBound,
@ -138,26 +138,26 @@ namespace Avalonia.Controls.Primitives
switch (channel) switch (channel)
{ {
case ColorPickerHsvChannel.Hue: case HsvChannel.Hue:
originalValue = originalHsv.H; originalValue = originalHsv.H;
newValue = ref newHsv.H; newValue = ref newHsv.H;
incrementAmount = 1; incrementAmount = 1;
break; break;
case ColorPickerHsvChannel.Saturation: case HsvChannel.Saturation:
originalValue = originalHsv.S; originalValue = originalHsv.S;
newValue = ref newHsv.S; newValue = ref newHsv.S;
incrementAmount = 0.01; incrementAmount = 0.01;
break; break;
case ColorPickerHsvChannel.Value: case HsvChannel.Value:
originalValue = originalHsv.V; originalValue = originalHsv.V;
newValue = ref newHsv.V; newValue = ref newHsv.V;
incrementAmount = 0.01; incrementAmount = 0.01;
break; break;
default: default:
throw new InvalidOperationException("Invalid ColorPickerHsvChannel."); throw new InvalidOperationException("Invalid HsvChannel.");
} }
bool shouldFindMidPoint = true; bool shouldFindMidPoint = true;
@ -230,26 +230,26 @@ namespace Avalonia.Controls.Primitives
switch (channel) switch (channel)
{ {
case ColorPickerHsvChannel.Hue: case HsvChannel.Hue:
startValue = ref startHsv.H; startValue = ref startHsv.H;
currentValue = ref currentHsv.H; currentValue = ref currentHsv.H;
wrapIncrement = 360.0; wrapIncrement = 360.0;
break; break;
case ColorPickerHsvChannel.Saturation: case HsvChannel.Saturation:
startValue = ref startHsv.S; startValue = ref startHsv.S;
currentValue = ref currentHsv.S; currentValue = ref currentHsv.S;
wrapIncrement = 1.0; wrapIncrement = 1.0;
break; break;
case ColorPickerHsvChannel.Value: case HsvChannel.Value:
startValue = ref startHsv.V; startValue = ref startHsv.V;
currentValue = ref currentHsv.V; currentValue = ref currentHsv.V;
wrapIncrement = 1.0; wrapIncrement = 1.0;
break; break;
default: default:
throw new InvalidOperationException("Invalid ColorPickerHsvChannel."); throw new InvalidOperationException("Invalid HsvChannel.");
} }
while (newColorName == currentColorName) while (newColorName == currentColorName)

24
src/Avalonia.Controls/ColorPicker/ColorSpectrum/ColorSpectrum.cs

@ -190,7 +190,7 @@ namespace Avalonia.Controls.Primitives
bool isControlDown = e.KeyModifiers.HasFlag(KeyModifiers.Control); bool isControlDown = e.KeyModifiers.HasFlag(KeyModifiers.Control);
ColorPickerHsvChannel incrementChannel = ColorPickerHsvChannel.Hue; HsvChannel incrementChannel = HsvChannel.Hue;
if (key == Key.Left || if (key == Key.Left ||
key == Key.Right) key == Key.Right)
@ -199,17 +199,17 @@ namespace Avalonia.Controls.Primitives
{ {
case ColorSpectrumChannels.HueSaturation: case ColorSpectrumChannels.HueSaturation:
case ColorSpectrumChannels.HueValue: case ColorSpectrumChannels.HueValue:
incrementChannel = ColorPickerHsvChannel.Hue; incrementChannel = HsvChannel.Hue;
break; break;
case ColorSpectrumChannels.SaturationHue: case ColorSpectrumChannels.SaturationHue:
case ColorSpectrumChannels.SaturationValue: case ColorSpectrumChannels.SaturationValue:
incrementChannel = ColorPickerHsvChannel.Saturation; incrementChannel = HsvChannel.Saturation;
break; break;
case ColorSpectrumChannels.ValueHue: case ColorSpectrumChannels.ValueHue:
case ColorSpectrumChannels.ValueSaturation: case ColorSpectrumChannels.ValueSaturation:
incrementChannel = ColorPickerHsvChannel.Value; incrementChannel = HsvChannel.Value;
break; break;
} }
} }
@ -220,17 +220,17 @@ namespace Avalonia.Controls.Primitives
{ {
case ColorSpectrumChannels.SaturationHue: case ColorSpectrumChannels.SaturationHue:
case ColorSpectrumChannels.ValueHue: case ColorSpectrumChannels.ValueHue:
incrementChannel = ColorPickerHsvChannel.Hue; incrementChannel = HsvChannel.Hue;
break; break;
case ColorSpectrumChannels.HueSaturation: case ColorSpectrumChannels.HueSaturation:
case ColorSpectrumChannels.ValueSaturation: case ColorSpectrumChannels.ValueSaturation:
incrementChannel = ColorPickerHsvChannel.Saturation; incrementChannel = HsvChannel.Saturation;
break; break;
case ColorSpectrumChannels.HueValue: case ColorSpectrumChannels.HueValue:
case ColorSpectrumChannels.SaturationValue: case ColorSpectrumChannels.SaturationValue:
incrementChannel = ColorPickerHsvChannel.Value; incrementChannel = HsvChannel.Value;
break; break;
} }
} }
@ -240,17 +240,17 @@ namespace Avalonia.Controls.Primitives
switch (incrementChannel) switch (incrementChannel)
{ {
case ColorPickerHsvChannel.Hue: case HsvChannel.Hue:
minBound = MinHue; minBound = MinHue;
maxBound = MaxHue; maxBound = MaxHue;
break; break;
case ColorPickerHsvChannel.Saturation: case HsvChannel.Saturation:
minBound = MinSaturation; minBound = MinSaturation;
maxBound = MaxSaturation; maxBound = MaxSaturation;
break; break;
case ColorPickerHsvChannel.Value: case HsvChannel.Value:
minBound = MinValue; minBound = MinValue;
maxBound = MaxValue; maxBound = MaxValue;
break; break;
@ -260,8 +260,8 @@ namespace Avalonia.Controls.Primitives
// so we want left and up to be lower for hue, but higher for saturation and value. // so we want left and up to be lower for hue, but higher for saturation and value.
// This will ensure that the icon always moves in the direction of the key press. // This will ensure that the icon always moves in the direction of the key press.
IncrementDirection direction = IncrementDirection direction =
(incrementChannel == ColorPickerHsvChannel.Hue && (key == Key.Left || key == Key.Up)) || (incrementChannel == HsvChannel.Hue && (key == Key.Left || key == Key.Up)) ||
(incrementChannel != ColorPickerHsvChannel.Hue && (key == Key.Right || key == Key.Down)) ? (incrementChannel != HsvChannel.Hue && (key == Key.Right || key == Key.Down)) ?
IncrementDirection.Lower : IncrementDirection.Lower :
IncrementDirection.Higher; IncrementDirection.Higher;

2
src/Avalonia.Controls/ColorPicker/ColorPickerHsvChannel.cs → src/Avalonia.Controls/ColorPicker/HsvChannel.cs

@ -8,7 +8,7 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Defines a specific HSV color model channel. /// Defines a specific HSV color model channel.
/// </summary> /// </summary>
public enum ColorPickerHsvChannel public enum HsvChannel
{ {
/// <summary> /// <summary>
/// The Hue channel. /// The Hue channel.
Loading…
Cancel
Save