Skip to content

Commit fc52e9e

Browse files
authored
Merge pull request #685 from Shallowmallow/ColorSelector
ColorPicker - always set pixels
2 parents 422ddfd + 026d483 commit fc52e9e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

haxe/ui/components/ColorPicker.hx

Lines changed: 11 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

@@ -253,6 +253,8 @@ private class HSVColorPickerImpl extends ColorPickerImpl {
253253
var requiresRedraw = true;
254254
if (_saturationValueGraphLastHue != null && _saturationValueGraphLastHue == _currentColorHSV.h) {
255255
requiresRedraw = false;
256+
// Sometimes html element image data "disappears" so we still need to set pixels
257+
saturationValueGraph.componentGraphics.setPixels(_saturationValueGraphBytes);
256258
}
257259

258260
//Seemingly breaks the color picker for no reason, commenting just in case.
@@ -559,7 +561,7 @@ private class HSVColorPickerImpl extends ColorPickerImpl {
559561
var b = Std.parseInt("0x" + hexB);
560562

561563
if (_trackingSaturationValue == false && _sliderTracking == false) {
562-
applyHSV(ColorUtil.rgbfToHSV(r, g, b));
564+
applyRGBA({r:r, g:g, b:b});
563565
}
564566
}
565567

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

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

0 commit comments

Comments
 (0)