diff options
| author | Pedro J. Estébanez | 2017-03-22 21:18:47 +0100 |
|---|---|---|
| committer | Pedro J. Estébanez | 2017-03-22 21:36:52 +0100 |
| commit | f5004b78d0468641cd03619ecfecb42429621a70 (patch) | |
| tree | 42011a7bf4ab8b602899e9d3dacbc1fdeb21952f /editor/plugins/canvas_item_editor_plugin.cpp | |
| parent | 33a2c5def0f55ef67196e35ac3309d3f9b70d967 (diff) | |
| download | godot-f5004b78d0468641cd03619ecfecb42429621a70.tar.gz godot-f5004b78d0468641cd03619ecfecb42429621a70.tar.zst godot-f5004b78d0468641cd03619ecfecb42429621a70.zip | |
Implement warped mouse panning for 2D & 3D editors
Enabled by default as in Blender, but can be disabled separately for 2D & 3D;
the core functionality is in Input so this could be reused or even exposed to scripts in the future
Diffstat (limited to 'editor/plugins/canvas_item_editor_plugin.cpp')
| -rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 7b015e484..7f2daae42 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1471,8 +1471,16 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent &p_event) { if (drag == DRAG_NONE) { 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_value(h_scroll->get_value() - m.relative_x / zoom); - v_scroll->set_value(v_scroll->get_value() - m.relative_y / zoom); + + Point2i relative; + if (bool(EditorSettings::get_singleton()->get("editors/2d/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_value(h_scroll->get_value() - relative.x / zoom); + v_scroll->set_value(v_scroll->get_value() - relative.y / zoom); } return; |
