Skip to content

Commit 026d483

Browse files
committed
Color picker - returned color should be the same as set color if no changes
1 parent a6715ed commit 026d483

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

haxe/ui/components/ColorPicker.hx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private class ColorPickerImpl extends Box {
108108
<stack id="controlsStack" width="100%" selectedIndex="0">
109109
<grid id="hsvControls" columns="4" width="100%" style="spacing:0px">
110110
<label text="{{hue}}" styleName="text-tiny" />
111-
<slider id="sliderHue" max="360" allowFocus="false" styleName="simple-slider" />
111+
<slider id="sliderHue" max="360" allowFocus="false" styleName="simple-slider" step="1" />
112112
<spacer width="5" />
113113
<textfield id="inputHue" restrictChars="0-9" styleName="text-tiny" allowFocus="false" />
114114
@@ -168,7 +168,7 @@ private class HSVColorPickerImpl extends ColorPickerImpl {
168168

169169
private override function set_currentColor(value:Null<Color>):Null<Color> {
170170
_currentColorHSV = ColorUtil.toHSV(value);
171-
_currentColorRGBF = ColorUtil.hsvToRGBF(_currentColorHSV.h, _currentColorHSV.s, _currentColorHSV.v);
171+
_currentColorRGBF = {r:value.r, g:value.g, b:value.b};
172172
return super.set_currentColor(value);
173173
}
174174

@@ -561,7 +561,7 @@ private class HSVColorPickerImpl extends ColorPickerImpl {
561561
var b = Std.parseInt("0x" + hexB);
562562

563563
if (_trackingSaturationValue == false && _sliderTracking == false) {
564-
applyHSV(ColorUtil.rgbfToHSV(r, g, b));
564+
applyRGBA({r:r, g:g, b:b});
565565
}
566566
}
567567

@@ -574,6 +574,12 @@ private class HSVColorPickerImpl extends ColorPickerImpl {
574574
_currentColorRGBF = ColorUtil.hsvToRGBF(newHSV.h, newHSV.s, newHSV.v);
575575
onCurrentColorChanged();
576576
}
577+
578+
private function applyRGBA(newRGBF:RGBF) {
579+
_currentColorHSV = ColorUtil.rgbfToHSV(newRGBF.r, newRGBF.g, newRGBF.b);
580+
_currentColorRGBF = newRGBF;
581+
onCurrentColorChanged();
582+
}
577583

578584
private var _trackingSaturationValue:Bool = false;
579585
@:bind(saturationValueGraph, MouseEvent.MOUSE_DOWN)

0 commit comments

Comments
 (0)