aboutsummaryrefslogtreecommitdiff
path: root/editor/plugins/canvas_item_editor_plugin.cpp
diff options
context:
space:
mode:
authorRémi Verschelde2017-03-24 22:50:34 +0100
committerGitHub2017-03-24 22:50:34 +0100
commita9d63bcf6f0b863d4e0fad1ed1bc5c3ca343e29d (patch)
tree02520083f859138f053795d8488180cd9cc4834c /editor/plugins/canvas_item_editor_plugin.cpp
parent2c95976ef7300081128959d66f3e3afa4f1b0049 (diff)
parent2c2c48ffb3bd381d09d1e0e4389a2b86255fe20f (diff)
downloadgodot-a9d63bcf6f0b863d4e0fad1ed1bc5c3ca343e29d.tar.gz
godot-a9d63bcf6f0b863d4e0fad1ed1bc5c3ca343e29d.tar.zst
godot-a9d63bcf6f0b863d4e0fad1ed1bc5c3ca343e29d.zip
Merge pull request #8107 from RandomShaper/warped-panning-2.1
Implement warped mouse panning for 2D & 3D editors (2.1)
Diffstat (limited to 'editor/plugins/canvas_item_editor_plugin.cpp')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index e7189b0f4..f86f53168 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1462,8 +1462,15 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
if ((m.button_mask & BUTTON_MASK_LEFT && tool == TOOL_PAN) || m.button_mask & BUTTON_MASK_MIDDLE || (m.button_mask & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
- h_scroll->set_val(h_scroll->get_val() - m.relative_x / zoom);
- v_scroll->set_val(v_scroll->get_val() - m.relative_y / zoom);
+ Point2i relative;
+ if (bool(EditorSettings::get_singleton()->get("2d_editor/warped_mouse_panning"))) {
+ relative = Input::get_singleton()->warp_mouse_motion(m, viewport->get_global_rect());
+ } else {
+ relative = Point2i(m.relative_x, m.relative_y);
+ }
+
+ h_scroll->set_val(h_scroll->get_val() - relative.x / zoom);
+ v_scroll->set_val(v_scroll->get_val() - relative.y / zoom);
}
return;