Merge pull request #83851 from Calinou/colorpicker-raw-mode-increase-precision

Increase precision of RAW mode in ColorPicker
This commit is contained in:
Rémi Verschelde 2023-10-24 10:54:52 +02:00
commit 2dc932e62d
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 5 additions and 1 deletions

View File

@ -43,6 +43,7 @@ public:
virtual int get_slider_count() const { return 3; }; virtual int get_slider_count() const { return 3; };
virtual float get_slider_step() const = 0; virtual float get_slider_step() const = 0;
virtual float get_spinbox_arrow_step() const { return get_slider_step(); };
virtual String get_slider_label(int idx) const = 0; virtual String get_slider_label(int idx) const = 0;
virtual float get_slider_max(int idx) const = 0; virtual float get_slider_max(int idx) const = 0;
virtual float get_slider_value(int idx) const = 0; virtual float get_slider_value(int idx) const = 0;
@ -109,7 +110,8 @@ public:
virtual String get_name() const override { return "RAW"; } virtual String get_name() const override { return "RAW"; }
virtual float get_slider_step() const override { return 0.01; } virtual float get_slider_step() const override { return 0.001; }
virtual float get_spinbox_arrow_step() const override { return 0.01; }
virtual String get_slider_label(int idx) const override; virtual String get_slider_label(int idx) const override;
virtual float get_slider_max(int idx) const override; virtual float get_slider_max(int idx) const override;
virtual float get_slider_value(int idx) const override; virtual float get_slider_value(int idx) const override;

View File

@ -575,9 +575,11 @@ void ColorPicker::_update_color(bool p_update_sliders) {
if (p_update_sliders) { if (p_update_sliders) {
float step = modes[current_mode]->get_slider_step(); float step = modes[current_mode]->get_slider_step();
float spinbox_arrow_step = modes[current_mode]->get_spinbox_arrow_step();
for (int i = 0; i < current_slider_count; i++) { for (int i = 0; i < current_slider_count; i++) {
sliders[i]->set_max(modes[current_mode]->get_slider_max(i)); sliders[i]->set_max(modes[current_mode]->get_slider_max(i));
sliders[i]->set_step(step); sliders[i]->set_step(step);
values[i]->set_custom_arrow_step(spinbox_arrow_step);
sliders[i]->set_value(modes[current_mode]->get_slider_value(i)); sliders[i]->set_value(modes[current_mode]->get_slider_value(i));
} }
alpha_slider->set_max(modes[current_mode]->get_slider_max(current_slider_count)); alpha_slider->set_max(modes[current_mode]->get_slider_max(current_slider_count));