summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2019-01-18 22:18:37 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2019-01-18 22:19:19 +0100
commit4b7830645945653b6053565462fa47f6962a19b1 (patch)
tree176e7895e91811e27209c8531ed2cc490e457c2d
parent93d8f3cdd5f0166fcbf8456488e98bfd4d9e02bb (diff)
Fix a rounding error in ColorPicker
This closes #25063.
-rw-r--r--scene/gui/color_picker.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index b99128e65f..6ed465562e 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -176,14 +176,15 @@ void ColorPicker::_update_color() {
updating = true;
for (int i = 0; i < 4; i++) {
- scroll[i]->set_step(0.01);
if (raw_mode_enabled) {
+ scroll[i]->set_step(0.01);
scroll[i]->set_max(100);
if (i == 3)
scroll[i]->set_max(1);
scroll[i]->set_value(color.components[i]);
} else {
- const int byte_value = color.components[i] * 255;
+ scroll[i]->set_step(1);
+ const float byte_value = color.components[i] * 255.0;
scroll[i]->set_max(next_power_of_2(MAX(255, byte_value)) - 1);
scroll[i]->set_value(byte_value);
}