Merge pull request #78486 from dinoplane/fix-sat-slider

Use cached saturation for color picker when value is 0
This commit is contained in:
Rémi Verschelde 2023-06-22 10:30:04 +02:00
commit 9d9740fc35
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 12 additions and 2 deletions

View file

@ -124,8 +124,13 @@ float ColorModeHSV::get_slider_value(int idx) const {
return color_picker->get_cached_hue(); return color_picker->get_cached_hue();
} }
} }
case 1: case 1: {
return color_picker->get_pick_color().get_s() * 100.0; if (color_picker->get_pick_color().get_v() > 0) {
return color_picker->get_pick_color().get_s() * 100.0;
} else {
return color_picker->get_cached_saturation();
}
}
case 2: case 2:
return color_picker->get_pick_color().get_v() * 100.0; return color_picker->get_pick_color().get_v() * 100.0;
case 3: case 3:

View file

@ -380,6 +380,9 @@ void ColorPicker::_value_changed(double) {
if (sliders[1]->get_value() > 0 || sliders[0]->get_value() != cached_hue) { if (sliders[1]->get_value() > 0 || sliders[0]->get_value() != cached_hue) {
cached_hue = sliders[0]->get_value(); cached_hue = sliders[0]->get_value();
} }
if (sliders[2]->get_value() > 0 || sliders[1]->get_value() != cached_saturation) {
cached_saturation = sliders[1]->get_value();
}
} }
if (current_mode == MODE_HSV || current_mode == MODE_OKHSL) { if (current_mode == MODE_HSV || current_mode == MODE_OKHSL) {

View file

@ -205,6 +205,7 @@ private:
float s = 0.0; float s = 0.0;
float v = 0.0; float v = 0.0;
float cached_hue = 0.0; float cached_hue = 0.0;
float cached_saturation = 0.0;
Color last_color; Color last_color;
struct ThemeCache { struct ThemeCache {
@ -296,6 +297,7 @@ public:
void set_editor_settings(Object *p_editor_settings); void set_editor_settings(Object *p_editor_settings);
#endif #endif
float get_cached_hue() { return cached_hue; }; float get_cached_hue() { return cached_hue; };
float get_cached_saturation() { return cached_saturation; };
HSlider *get_slider(int idx); HSlider *get_slider(int idx);
Vector<float> get_active_slider_values(); Vector<float> get_active_slider_values();