diff options
author | Bernhard Liebl <Bernhard.Liebl@gmx.org> | 2017-11-01 21:49:39 +0100 |
---|---|---|
committer | Bernhard Liebl <Bernhard.Liebl@gmx.org> | 2017-11-21 09:11:39 +0100 |
commit | 80ad8afc85a90e6fda1b136b13c1eb42e35c115e (patch) | |
tree | bc145bc5c008a2abfa159f4d5437c8d0b8813aca /scene/main/viewport.cpp | |
parent | 5ff84070ca3604b43e86562a3d000ed924a604a2 (diff) |
Native pan and zoom for macOS
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r-- | scene/main/viewport.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 0a02f471c1..1f539041fd 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2013,6 +2013,30 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } } + Ref<InputEventGesture> gesture_event = p_event; + if (gesture_event.is_valid()) { + + Size2 pos = gesture_event->get_position(); + + Control *over = _gui_find_control(pos); + if (over) { + + if (over->can_process()) { + + gesture_event = gesture_event->xformed_by(Transform2D()); //make a copy + if (over == gui.mouse_focus) { + pos = gui.focus_inv_xform.xform(pos); + } else { + pos = over->get_global_transform_with_canvas().affine_inverse().xform(pos); + } + gesture_event->set_position(pos); + _gui_call_input(over, gesture_event); + } + get_tree()->set_input_as_handled(); + return; + } + } + Ref<InputEventScreenDrag> drag_event = p_event; if (drag_event.is_valid()) { |