summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-08-18 11:03:28 +0200
committerGitHub <noreply@github.com>2019-08-18 11:03:28 +0200
commitd154e55f45e68efb17a65adea5b86416d37998f0 (patch)
treef7d0ff77420d2c2a834336ac2cb124b4296f4037 /editor
parent7f7e0f9dfc7b880b82275a70ff644ffa6324ca2d (diff)
parent8a0e6e23a778bc84ba349974f9444e74c1df0e48 (diff)
Merge pull request #31442 from KoBeWi/grounded_grabber
Update Slider grabber position when using mouse wheel
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_spin_slider.cpp56
1 files changed, 31 insertions, 25 deletions
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 379b8a2980..46a30b7554 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -47,42 +47,48 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
return;
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid()) {
- if (mb->is_pressed()) {
+ if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->is_pressed()) {
- if (updown_offset != -1 && mb->get_position().x > updown_offset) {
- //there is an updown, so use it.
- if (mb->get_position().y < get_size().height / 2) {
- set_value(get_value() + get_step());
+ if (updown_offset != -1 && mb->get_position().x > updown_offset) {
+ //there is an updown, so use it.
+ if (mb->get_position().y < get_size().height / 2) {
+ set_value(get_value() + get_step());
+ } else {
+ set_value(get_value() - get_step());
+ }
+ return;
} else {
- set_value(get_value() - get_step());
+
+ 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();
}
- return;
} else {
- 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();
- }
- } else {
+ if (grabbing_spinner_attempt) {
- if (grabbing_spinner_attempt) {
+ if (grabbing_spinner) {
- if (grabbing_spinner) {
+ Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+ Input::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos);
+ update();
+ } else {
+ _focus_entered();
+ }
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
- Input::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos);
- update();
- } else {
- _focus_entered();
+ grabbing_spinner = false;
+ grabbing_spinner_attempt = false;
}
-
- grabbing_spinner = false;
- grabbing_spinner_attempt = false;
}
+ } else if (mb->get_button_index() == BUTTON_WHEEL_UP || mb->get_button_index() == BUTTON_WHEEL_DOWN) {
+
+ if (grabber->is_visible())
+ call_deferred("update");
}
}