From d1b1edba84a76614368fa9e7eb2459ed0dc95da5 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Thu, 30 Jan 2020 11:39:13 +0800 Subject: [PATCH] Adds pan and zoom gestures to TextureRegion editor --- editor/plugins/texture_region_editor_plugin.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 507ea0b83d8..94aef60f1ff 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -546,6 +546,17 @@ void TextureRegionEditor::_region_input(const Ref &p_input) { edit_draw->update(); } } + + Ref magnify_gesture = p_input; + if (magnify_gesture.is_valid()) { + _zoom_on_position(draw_zoom * magnify_gesture->get_factor(), magnify_gesture->get_position()); + } + + Ref pan_gesture = p_input; + if (pan_gesture.is_valid()) { + hscroll->set_value(hscroll->get_value() + hscroll->get_page() * pan_gesture->get_delta().x / 8); + vscroll->set_value(vscroll->get_value() + vscroll->get_page() * pan_gesture->get_delta().y / 8); + } } void TextureRegionEditor::_scroll_changed(float) {