Merge pull request #94904 from bruvzg/tile_poly_gestures

[GenericTilePolygonEditor] Add support for Pan and Magnify gestures.
This commit is contained in:
Rémi Verschelde 2024-08-16 14:32:45 +02:00
commit 8f6116d3f4
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 15 additions and 0 deletions

View File

@ -523,6 +523,21 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
xform.set_origin(base_control->get_size() / 2 + panning); xform.set_origin(base_control->get_size() / 2 + panning);
xform.set_scale(Vector2(editor_zoom_widget->get_zoom(), editor_zoom_widget->get_zoom())); xform.set_scale(Vector2(editor_zoom_widget->get_zoom(), editor_zoom_widget->get_zoom()));
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
panning += pan_gesture->get_delta() * 8;
drag_last_pos = Vector2();
button_center_view->set_disabled(panning.is_zero_approx());
accept_event();
}
Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid()) {
editor_zoom_widget->set_zoom(editor_zoom_widget->get_zoom() * magnify_gesture->get_factor());
_zoom_changed();
accept_event();
}
Ref<InputEventMouseMotion> mm = p_event; Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) { if (mm.is_valid()) {
if (drag_type == DRAG_TYPE_DRAG_POINT) { if (drag_type == DRAG_TYPE_DRAG_POINT) {