1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-18 14:21:41 +00:00

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
This commit is contained in:
Pedro J. Estébanez
2017-03-22 21:18:47 +01:00
parent 9c75b9dddf
commit 2c2c48ffb3
6 changed files with 34 additions and 3 deletions

View File

@@ -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;