Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cached saturation for color picker when value is 0 #78486

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scene/gui/color_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions scene/gui/color_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions scene/gui/color_picker.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class ColorPicker : public VBoxContainer {
float s = 0.0;
float v = 0.0;
float cached_hue = 0.0;
float cached_saturation = 0.0;
Color last_color;

struct ThemeCache {
Expand Down Expand Up @@ -296,6 +297,7 @@ class ColorPicker : public VBoxContainer {
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<float> get_active_slider_values();
Expand Down