Browse Source

Merge pull request #35731 from timothyqiu/texture-region-gestures

Adds pan and zoom gestures to TextureRegion editor
Rémi Verschelde 5 years ago
parent
commit
6aaff5dc68
1 changed files with 11 additions and 0 deletions
  1. 11 0
      editor/plugins/texture_region_editor_plugin.cpp

+ 11 - 0
editor/plugins/texture_region_editor_plugin.cpp

@@ -546,6 +546,17 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
 			edit_draw->update();
 		}
 	}
+
+	Ref<InputEventMagnifyGesture> magnify_gesture = p_input;
+	if (magnify_gesture.is_valid()) {
+		_zoom_on_position(draw_zoom * magnify_gesture->get_factor(), magnify_gesture->get_position());
+	}
+
+	Ref<InputEventPanGesture> 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) {