diff options
author | ajreckof <tbonhoure@ymail.Com> | 2023-09-19 10:47:46 +0200 |
---|---|---|
committer | ajreckof <tbonhoure@ymail.Com> | 2023-10-13 14:35:47 +0200 |
commit | 3160add2b0b030ae5b8ae0ad3c3b55d4367f2455 (patch) | |
tree | e19a8bd5e6d56fd41fe1c4839085bd67afb5ba74 /scene/gui/color_picker.cpp | |
parent | 571cd0eb791b37e9a8adda9f909251138170f6b7 (diff) | |
download | redot-engine-3160add2b0b030ae5b8ae0ad3c3b55d4367f2455.tar.gz |
Fix ColorPicker deferred mode not working for sliders.
Diffstat (limited to 'scene/gui/color_picker.cpp')
-rw-r--r-- | scene/gui/color_picker.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 5ec0714b64..c2512bed66 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -341,7 +341,11 @@ bool ColorPicker::is_editing_alpha() const { return edit_alpha; } -void ColorPicker::_value_changed(double) { +void ColorPicker::_slider_drag_started() { + currently_dragging = true; +} + +void ColorPicker::_slider_value_changed() { if (updating) { return; } @@ -357,7 +361,16 @@ void ColorPicker::_value_changed(double) { } _set_pick_color(color, false); - emit_signal(SNAME("color_changed"), color); + if (!deferred_mode_enabled || !currently_dragging) { + emit_signal(SNAME("color_changed"), color); + } +} + +void ColorPicker::_slider_drag_ended() { + currently_dragging = false; + if (deferred_mode_enabled) { + emit_signal(SNAME("color_changed"), color); + } } void ColorPicker::add_mode(ColorMode *p_mode) { @@ -388,7 +401,9 @@ void ColorPicker::create_slider(GridContainer *gc, int idx) { slider->set_h_size_flags(SIZE_EXPAND_FILL); - slider->connect("value_changed", callable_mp(this, &ColorPicker::_value_changed)); + slider->connect("drag_started", callable_mp(this, &ColorPicker::_slider_drag_started)); + slider->connect("value_changed", callable_mp(this, &ColorPicker::_slider_value_changed).unbind(1)); + slider->connect("drag_ended", callable_mp(this, &ColorPicker::_slider_drag_ended).unbind(1)); slider->connect("draw", callable_mp(this, &ColorPicker::_slider_draw).bind(idx)); slider->connect("gui_input", callable_mp(this, &ColorPicker::_slider_or_spin_input)); @@ -1242,7 +1257,6 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) { _copy_hsv_to_color(); last_color = color; set_pick_color(color); - _update_color(); if (!deferred_mode_enabled) { emit_signal(SNAME("color_changed"), color); @@ -1293,7 +1307,6 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) { _copy_hsv_to_color(); last_color = color; set_pick_color(color); - _update_color(); if (!deferred_mode_enabled) { emit_signal(SNAME("color_changed"), color); @@ -1321,7 +1334,6 @@ void ColorPicker::_w_input(const Ref<InputEvent> &p_event) { _copy_hsv_to_color(); last_color = color; set_pick_color(color); - _update_color(); if (!bev->is_pressed() && bev->get_button_index() == MouseButton::LEFT) { add_recent_preset(color); @@ -1347,7 +1359,6 @@ void ColorPicker::_w_input(const Ref<InputEvent> &p_event) { _copy_hsv_to_color(); last_color = color; set_pick_color(color); - _update_color(); if (!deferred_mode_enabled) { emit_signal(SNAME("color_changed"), color); |