diff options
author | Ryan Schmitt <ryanschmittdev@gmail.com> | 2018-11-08 19:48:44 -0800 |
---|---|---|
committer | Ryan Schmitt <ryanschmittdev@gmail.com> | 2018-11-08 19:48:44 -0800 |
commit | e890a7d6275d1230690c3ec3ca9134eab61f8b5d (patch) | |
tree | 2e4351066c3a7f73c0f293d0621d78e4ba130ac2 | |
parent | da1f53c8d995aeb393f67d9aeb8a0842751a1180 (diff) |
Improve dragging behavior of editor_spin_slider
Fixes issues with changing the size or position of a Rect. Fixes #23011
-rw-r--r-- | editor/editor_spin_slider.cpp | 6 | ||||
-rw-r--r-- | editor/editor_spin_slider.h | 1 |
2 files changed, 5 insertions, 2 deletions
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index b6e4375ce9..e017935cf7 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -63,6 +63,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { grabbing_spinner_attempt = true; grabbing_spinner_dist_cache = 0; + pre_grab_value = get_value(); grabbing_spinner = false; grabbing_spinner_mouse_pos = Input::get_singleton()->get_mouse_position(); } @@ -107,10 +108,10 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { if (ABS(grabbing_spinner_dist_cache) > 6) { set_value(get_value() + SGN(grabbing_spinner_dist_cache)); grabbing_spinner_dist_cache = 0; + pre_grab_value = get_value(); } } else { - set_value(get_value() + get_step() * grabbing_spinner_dist_cache * 10); - grabbing_spinner_dist_cache = 0; + set_value(pre_grab_value + get_step() * grabbing_spinner_dist_cache * 10); } } } else if (updown_offset != -1) { @@ -434,6 +435,7 @@ EditorSpinSlider::EditorSpinSlider() { grabbing_spinner_attempt = false; grabbing_spinner = false; grabbing_spinner_dist_cache = 0; + pre_grab_value = 0; set_focus_mode(FOCUS_ALL); updown_offset = -1; hover_updown = false; diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h index e48eb171b8..9d43bd2884 100644 --- a/editor/editor_spin_slider.h +++ b/editor/editor_spin_slider.h @@ -59,6 +59,7 @@ class EditorSpinSlider : public Range { bool read_only; float grabbing_spinner_dist_cache; Vector2 grabbing_spinner_mouse_pos; + double pre_grab_value; LineEdit *value_input; bool value_input_just_closed; |