1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Native pan and zoom for macOS

This commit is contained in:
Bernhard Liebl
2017-11-01 21:49:39 +01:00
parent 5ff84070ca
commit 80ad8afc85
21 changed files with 549 additions and 133 deletions

View File

@@ -1442,6 +1442,22 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
}
}
Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid()) {
_zoom_on_position(zoom * magnify_gesture->get_factor(), magnify_gesture->get_position());
return;
}
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
const Vector2 delta = (int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom) * pan_gesture->get_delta();
h_scroll->set_value(h_scroll->get_value() + delta.x);
v_scroll->set_value(v_scroll->get_value() + delta.y);
return;
}
Ref<InputEventMouseButton> b = p_event;
if (b.is_valid()) {
// Button event