From e11e9d2b9a7b14f6deea6eb3490146bbac0d3773 Mon Sep 17 00:00:00 2001 From: dinoplane Date: Tue, 20 Jun 2023 11:03:30 -0700 Subject: [PATCH] Use cached saturation for color picker when value is 0 --- scene/gui/color_mode.cpp | 9 +++++++-- scene/gui/color_picker.cpp | 3 +++ scene/gui/color_picker.h | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scene/gui/color_mode.cpp b/scene/gui/color_mode.cpp index e95b2b9107e..38e6048b913 100644 --- a/scene/gui/color_mode.cpp +++ b/scene/gui/color_mode.cpp @@ -124,8 +124,13 @@ float ColorModeHSV::get_slider_value(int idx) const { return color_picker->get_cached_hue(); } } - case 1: - return color_picker->get_pick_color().get_s() * 100.0; + case 1: { + 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: return color_picker->get_pick_color().get_v() * 100.0; case 3: diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 768502c6587..604f09a3d9e 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -380,6 +380,9 @@ void ColorPicker::_value_changed(double) { if (sliders[1]->get_value() > 0 || sliders[0]->get_value() != cached_hue) { 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) { diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index bc7eadf2231..425213be90f 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -205,6 +205,7 @@ private: float s = 0.0; float v = 0.0; float cached_hue = 0.0; + float cached_saturation = 0.0; Color last_color; struct ThemeCache { @@ -296,6 +297,7 @@ public: void set_editor_settings(Object *p_editor_settings); #endif float get_cached_hue() { return cached_hue; }; + float get_cached_saturation() { return cached_saturation; }; HSlider *get_slider(int idx); Vector get_active_slider_values();