diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 7172df9ff4..d7ddc6a5b3 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -1372,87 +1372,6 @@ void InputEventGesture::_bind_methods() { /////////////////////////////////// -void InputEventMagnifyGesture::set_factor(real_t p_factor) { - factor = p_factor; -} - -real_t InputEventMagnifyGesture::get_factor() const { - return factor; -} - -Ref InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { - Ref ev; - ev.instantiate(); - - ev->set_device(get_device()); - ev->set_window_id(get_window_id()); - - ev->set_modifiers_from_event(this); - - ev->set_position(p_xform.xform(get_position() + p_local_ofs)); - ev->set_factor(get_factor()); - - return ev; -} - -String InputEventMagnifyGesture::as_text() const { - return vformat(RTR("Magnify Gesture at (%s) with factor %s"), String(get_position()), rtos(get_factor())); -} - -String InputEventMagnifyGesture::to_string() { - return vformat("InputEventMagnifyGesture: factor=%.2f, position=(%s)", factor, String(get_position())); -} - -void InputEventMagnifyGesture::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMagnifyGesture::set_factor); - ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMagnifyGesture::get_factor); - - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor"); -} - -/////////////////////////////////// - -void InputEventPanGesture::set_delta(const Vector2 &p_delta) { - delta = p_delta; -} - -Vector2 InputEventPanGesture::get_delta() const { - return delta; -} - -Ref InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { - Ref ev; - ev.instantiate(); - - ev->set_device(get_device()); - ev->set_window_id(get_window_id()); - - ev->set_modifiers_from_event(this); - - ev->set_position(p_xform.xform(get_position() + p_local_ofs)); - ev->set_delta(get_delta()); - ev->set_touches(get_touches()); - - return ev; -} - -String InputEventPanGesture::as_text() const { - return vformat(RTR("Pan Gesture at (%s) with delta (%s)"), String(get_position()), String(get_delta())); -} - -String InputEventPanGesture::to_string() { - return vformat("InputEventPanGesture: delta=(%s), position=(%s)", String(get_delta()), String(get_position())); -} - -void InputEventPanGesture::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_delta", "delta"), &InputEventPanGesture::set_delta); - ClassDB::bind_method(D_METHOD("get_delta"), &InputEventPanGesture::get_delta); - - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "delta"), "set_delta", "get_delta"); -} - -/////////////////////////////////// - void InputEventGesturePan::set_relative(const Vector2 &p_relative) { relative = p_relative; } diff --git a/core/input/input_event.h b/core/input/input_event.h index eef22fc20a..92ca2c80c8 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -464,42 +464,6 @@ public: int get_touches() const; }; -class InputEventMagnifyGesture : public InputEventGesture { - GDCLASS(InputEventMagnifyGesture, InputEventGesture); - real_t factor = 1.0; - -protected: - static void _bind_methods(); - -public: - void set_factor(real_t p_factor); - real_t get_factor() const; - - virtual Ref xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override; - virtual String as_text() const override; - virtual String to_string() override; - - InputEventMagnifyGesture() {} -}; - -class InputEventPanGesture : public InputEventGesture { - GDCLASS(InputEventPanGesture, InputEventGesture); - Vector2 delta; - -protected: - static void _bind_methods(); - -public: - void set_delta(const Vector2 &p_delta); - Vector2 get_delta() const; - - virtual Ref xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override; - virtual String as_text() const override; - virtual String to_string() override; - - InputEventPanGesture() {} -}; - class InputEventGesturePan : public InputEventGesture { GDCLASS(InputEventGesturePan, InputEventGesture); Vector2 relative; diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 941f0339cb..21300850e3 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -161,8 +161,6 @@ void register_core_types() { GDREGISTER_CLASS(InputEventScreenTouch); GDREGISTER_CLASS(InputEventAction); GDREGISTER_VIRTUAL_CLASS(InputEventGesture); - GDREGISTER_CLASS(InputEventMagnifyGesture); - GDREGISTER_CLASS(InputEventPanGesture); GDREGISTER_CLASS(InputEventGesturePan); GDREGISTER_CLASS(InputEventGesturePinch); GDREGISTER_CLASS(InputEventGestureTwist); diff --git a/doc/classes/InputEvent.xml b/doc/classes/InputEvent.xml index 07fdccc8ce..47122e174e 100644 --- a/doc/classes/InputEvent.xml +++ b/doc/classes/InputEvent.xml @@ -96,7 +96,7 @@ - Returns a copy of the given input event which has been offset by [code]local_ofs[/code] and transformed by [code]xform[/code]. Relevant for events of type [InputEventMouseButton], [InputEventMouseMotion], [InputEventScreenTouch], [InputEventScreenDrag], [InputEventMagnifyGesture], [InputEventPanGesture], [InputEventGesturePan], [InputEventGesturePinch] and [InputEventGestureTwist]. + Returns a copy of the given input event which has been offset by [code]local_ofs[/code] and transformed by [code]xform[/code]. Relevant for events of type [InputEventMouseButton], [InputEventMouseMotion], [InputEventScreenTouch], [InputEventScreenDrag], [InputEventGesturePan], [InputEventGesturePinch] and [InputEventGestureTwist]. diff --git a/doc/classes/InputEventMagnifyGesture.xml b/doc/classes/InputEventMagnifyGesture.xml deleted file mode 100644 index ed0860a63a..0000000000 --- a/doc/classes/InputEventMagnifyGesture.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/doc/classes/InputEventPanGesture.xml b/doc/classes/InputEventPanGesture.xml deleted file mode 100644 index 2de3459df7..0000000000 --- a/doc/classes/InputEventPanGesture.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 1902ae66fb..052d6497e8 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -774,10 +774,10 @@ void CodeTextEditor::_text_editor_gui_input(const Ref &p_event) { } } - Ref magnify_gesture = p_event; - if (magnify_gesture.is_valid()) { + Ref pinch_gesture = p_event; + if (pinch_gesture.is_valid()) { font_size = text_editor->get_theme_font_size(SNAME("font_size")); - font_size *= powf(magnify_gesture->get_factor(), 0.25); + font_size *= powf(pinch_gesture->get_factor(), 0.25); _add_font_size((int)font_size - text_editor->get_theme_font_size(SNAME("font_size"))); return; diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index a1f96f21bf..985857c659 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -387,7 +387,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref pan_gesture = p_event; + Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8); v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 061483decf..56de35e2ac 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1254,14 +1254,14 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref &p_event, bo } } - Ref magnify_gesture = p_event; - if (magnify_gesture.is_valid() && !p_already_accepted) { + Ref pinch_gesture = p_event; + if (pinch_gesture.is_valid() && !p_already_accepted) { // Zoom gesture - _zoom_on_position(zoom * magnify_gesture->get_factor(), magnify_gesture->get_position()); + _zoom_on_position(zoom * pinch_gesture->get_factor(), pinch_gesture->get_position()); return true; } - Ref pan_gesture = p_event; + Ref pan_gesture = p_event; if (pan_gesture.is_valid() && !p_already_accepted) { // If ctrl key pressed, then zoom instead of pan. if (pan_gesture->is_ctrl_pressed()) { diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 5b1cbe6f00..9558549524 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2149,16 +2149,16 @@ void Node3DEditorViewport::_sinput(const Ref &p_event) { } } - Ref magnify_gesture = p_event; - if (magnify_gesture.is_valid()) { + Ref pinch_gesture = p_event; + if (pinch_gesture.is_valid()) { if (is_freelook_active()) { - scale_freelook_speed(magnify_gesture->get_factor()); + scale_freelook_speed(pinch_gesture->get_factor()); } else { - scale_cursor_distance(1.0 / magnify_gesture->get_factor()); + scale_cursor_distance(1.0 / pinch_gesture->get_factor()); } } - Ref pan_gesture = p_event; + Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); NavigationMode nav_mode = NAVIGATION_NONE; diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 5afe9ed60c..496fc29572 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -913,12 +913,12 @@ void Polygon2DEditor::_uv_input(const Ref &p_input) { } } - Ref magnify_gesture = p_input; - if (magnify_gesture.is_valid()) { - uv_zoom->set_value(uv_zoom->get_value() * magnify_gesture->get_factor()); + Ref pinch_gesture = p_input; + if (pinch_gesture.is_valid()) { + uv_zoom->set_value(uv_zoom->get_value() * pinch_gesture->get_factor()); } - Ref pan_gesture = p_input; + Ref pan_gesture = p_input; if (pan_gesture.is_valid()) { uv_hscroll->set_value(uv_hscroll->get_value() + uv_hscroll->get_page() * pan_gesture->get_delta().x / 8); uv_vscroll->set_value(uv_vscroll->get_value() + uv_vscroll->get_page() * pan_gesture->get_delta().y / 8); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index ce90d61616..875d39cc64 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -597,12 +597,12 @@ void TextureRegionEditor::_region_input(const Ref &p_input) { } } - Ref magnify_gesture = p_input; - if (magnify_gesture.is_valid()) { - _zoom_on_position(draw_zoom * magnify_gesture->get_factor(), magnify_gesture->get_position()); + Ref pinch_gesture = p_input; + if (pinch_gesture.is_valid()) { + _zoom_on_position(draw_zoom * pinch_gesture->get_factor(), pinch_gesture->get_position()); } - Ref pan_gesture = p_input; + 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); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 08d55de976..56f6d5615d 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -752,7 +752,7 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D } } - Ref pan_gesture = p_event; + Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { if (pan_gesture->is_alt_pressed() && (pan_gesture->is_command_pressed() || pan_gesture->is_shift_pressed())) { const real_t delta = pan_gesture->get_delta().y * 0.5; diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp index e03375e8d9..7fab413b01 100644 --- a/platform/android/android_input_handler.cpp +++ b/platform/android/android_input_handler.cpp @@ -385,11 +385,11 @@ MouseButton AndroidInputHandler::_android_button_mask_to_godot_button_mask(int a } void AndroidInputHandler::process_scroll(Point2 p_pos) { - Ref ev; + Ref ev; ev.instantiate(); _set_key_modifier_state(ev); ev->set_position(p_pos); - ev->set_delta(p_pos - scroll_prev_pos); + ev->set_relative(p_pos - scroll_prev_pos); Input::get_singleton()->parse_input_event(ev); scroll_prev_pos = p_pos; } diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 03301af0af..5e138c93aa 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -862,7 +862,7 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M ERR_FAIL_COND(!DS_OSX->windows.has(window_id)); DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id]; - Ref ev; + Ref ev; ev.instantiate(); ev->set_window_id(window_id); _get_key_modifier_state([event modifierFlags], ev); @@ -1379,13 +1379,13 @@ inline void sendPanEvent(DisplayServer::WindowID window_id, double dx, double dy ERR_FAIL_COND(!DS_OSX->windows.has(window_id)); DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id]; - Ref pg; + Ref pg; pg.instantiate(); pg->set_window_id(window_id); _get_key_modifier_state(modifierFlags, pg); pg->set_position(wd.mouse_pos); - pg->set_delta(Vector2(-dx, -dy)); + pg->set_relative(Vector2(-dx, -dy)); Input::get_singleton()->parse_input_event(pg); } diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 35e31be9af..edad42165c 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -1313,12 +1313,12 @@ void GraphEdit::gui_input(const Ref &p_ev) { } } - Ref magnify_gesture = p_ev; - if (magnify_gesture.is_valid()) { - set_zoom_custom(zoom * magnify_gesture->get_factor(), magnify_gesture->get_position()); + Ref pinch_gesture = p_ev; + if (pinch_gesture.is_valid()) { + set_zoom_custom(zoom * pinch_gesture->get_factor(), pinch_gesture->get_position()); } - Ref pan_gesture = p_ev; + Ref pan_gesture = p_ev; if (pan_gesture.is_valid()) { h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8); v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 8470003b3e..8a149d0ae4 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -823,7 +823,7 @@ void ItemList::gui_input(const Ref &p_event) { } } - Ref pan_gesture = p_event; + Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { scroll_bar->set_value(scroll_bar->get_value() + scroll_bar->get_page() * pan_gesture->get_delta().y / 8); } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 308880ef18..2b57f9a9b7 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1648,7 +1648,7 @@ void RichTextLabel::gui_input(const Ref &p_event) { } } - Ref pan_gesture = p_event; + Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { if (scroll_active) { vscroll->set_value(vscroll->get_value() + vscroll->get_page() * pan_gesture->get_delta().y * 0.5 / 8); diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 0c0ec39c7f..a361edc0d1 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -195,7 +195,7 @@ void ScrollContainer::gui_input(const Ref &p_gui_input) { } } - Ref pan_gesture = p_gui_input; + Ref pan_gesture = p_gui_input; if (pan_gesture.is_valid()) { if (h_scroll->is_visible_in_tree()) { h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index cb7a6c0978..db9fbad94a 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1589,7 +1589,7 @@ void TextEdit::gui_input(const Ref &p_gui_input) { } } - const Ref pan_gesture = p_gui_input; + const Ref pan_gesture = p_gui_input; if (pan_gesture.is_valid()) { const real_t delta = pan_gesture->get_delta().y; if (delta < 0) { diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 1245a37c4d..c6498ceef5 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3386,7 +3386,7 @@ void Tree::gui_input(const Ref &p_event) { } } - Ref pan_gesture = p_event; + Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { double prev_v = v_scroll->get_value(); v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 31e8c20991..1c8fa6de3c 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1263,7 +1263,7 @@ void Viewport::_gui_call_input(Control *p_control, const Ref &p_inpu mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP || mb->get_button_index() == MOUSE_BUTTON_WHEEL_LEFT || mb->get_button_index() == MOUSE_BUTTON_WHEEL_RIGHT)); - Ref pn = p_input; + Ref pn = p_input; cant_stop_me_now = pn.is_valid() || cant_stop_me_now; bool ismouse = ev.is_valid() || Object::cast_to(*p_input) != nullptr;