diff options
author | toger5 <toger5@hotmail.de> | 2017-02-22 00:45:31 +0200 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-05-07 14:23:56 +0200 |
commit | 304a1f5b5a3ce6975952f5cd22d688a246367790 (patch) | |
tree | 14de7920daa3f90af91c668b3edcccdf439ed6f2 /editor | |
parent | c8aea60324e3e219945a805f871363c10292f38b (diff) |
Implemented scrolling factor for smooth trackpad scrolling
Working platforms platform: OSX, Windows.
Support for almost all ui elements, including project list.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/animation_editor.cpp | 18 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/polygon_2d_editor_plugin.cpp | 4 |
3 files changed, 20 insertions, 6 deletions
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 63ed27e60c..1e6562fcf2 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -1871,21 +1871,35 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent &p_input) { if (mb.button_index == BUTTON_WHEEL_UP && mb.pressed) { if (mb.mod.command) { + zoom->set_value(zoom->get_value() + zoom->get_step()); } else { - v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() / 8); + + v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * mb.factor / 8); } } if (mb.button_index == BUTTON_WHEEL_DOWN && mb.pressed) { if (mb.mod.command) { + zoom->set_value(zoom->get_value() - zoom->get_step()); } else { - v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() / 8); + + v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * mb.factor / 8); } } + if (mb.button_index == BUTTON_WHEEL_RIGHT && mb.pressed) { + + h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() * mb.factor / 8); + } + + if (mb.button_index == BUTTON_WHEEL_LEFT && mb.pressed) { + + v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * mb.factor / 8); + } + if (mb.button_index == BUTTON_RIGHT && mb.pressed) { Point2 mpos = Point2(mb.x, mb.y) - ofs; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 430a5adeb1..27be6ea8f0 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1049,7 +1049,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent &p_event) { return; float prev_zoom = zoom; - zoom = zoom * 0.95; + zoom = zoom * (1 - (0.05 * b.factor)); { Point2 ofs(b.x, b.y); ofs = ofs / prev_zoom - ofs / zoom; @@ -1067,7 +1067,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent &p_event) { return; float prev_zoom = zoom; - zoom = zoom * (1.0 / 0.95); + zoom = zoom * ((0.95 + (0.05 * b.factor)) / 0.95); { Point2 ofs(b.x, b.y); ofs = ofs / prev_zoom - ofs / zoom; diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index e84e782580..896a26c8e8 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -522,10 +522,10 @@ void Polygon2DEditor::_uv_input(const InputEvent &p_input) { } else if (mb.button_index == BUTTON_WHEEL_UP && mb.pressed) { - uv_zoom->set_value(uv_zoom->get_value() / 0.9); + uv_zoom->set_value(uv_zoom->get_value() / (1 - (0.1 * mb.factor))); } else if (mb.button_index == BUTTON_WHEEL_DOWN && mb.pressed) { - uv_zoom->set_value(uv_zoom->get_value() * 0.9); + uv_zoom->set_value(uv_zoom->get_value() * (1 - (0.1 * mb.factor))); } } else if (p_input.type == InputEvent::MOUSE_MOTION) { |