From b6eb2db442581b97fd7d8a610a2c705ba087094e Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 11 Aug 2022 02:24:30 +0200 Subject: [PATCH] Backported returning AfterGUIInput from forward_spatial_gui_input from Godot4. Also removed the first index parameter. This fully broke the skeleton editor, it will be fixed soon. --- doc/classes/EditorPlugin.xml | 18 ++++---- editor/editor_node.cpp | 15 ++++--- editor/editor_node.h | 2 +- editor/editor_plugin.cpp | 13 ++++-- editor/editor_plugin.h | 13 ++++-- .../collision_polygon_editor_plugin.cpp | 28 ++++++------- .../plugins/collision_polygon_editor_plugin.h | 4 +- editor/plugins/path_editor_plugin.cpp | 22 +++++----- editor/plugins/path_editor_plugin.h | 2 +- editor/plugins/spatial_editor_plugin.cpp | 4 +- .../editor/mdi_ed_plugin.cpp | 8 ++-- .../mesh_data_resource/editor/mdi_ed_plugin.h | 2 +- .../mesh_data_resource/editor/mdi_gizmo.cpp | 41 +++++++++++-------- modules/mesh_data_resource/editor/mdi_gizmo.h | 14 +++---- .../skeleton_editor_plugin.cpp | 11 +++-- .../skeleton_editor/skeleton_editor_plugin.h | 10 ++--- .../terraman/world/terrain_world_editor.cpp | 20 ++++----- modules/terraman/world/terrain_world_editor.h | 6 +-- .../world/terrain_2d_world_editor.cpp | 14 +++---- .../world/terrain_2d_world_editor.h | 6 +-- modules/voxelman/world/voxel_world_editor.cpp | 20 ++++----- modules/voxelman/world/voxel_world_editor.h | 6 +-- 22 files changed, 152 insertions(+), 127 deletions(-) diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index a027caa32..ae2b839bb 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -243,25 +243,23 @@ - - - - + + + Called when there is a root node in the current edited scene, [method handles] is implemented and an [InputEvent] happens in the 3D viewport. Intercepts the [InputEvent], if [code]return true[/code] [EditorPlugin] consumes the [code]event[/code], otherwise forwards [code]event[/code] to other Editor classes. Example: [codeblock] # Prevents the InputEvent to reach other Editor classes - func forward_spatial_gui_input(index, camera, event): - var forward = true - return forward + func forward_spatial_gui_input(camera, event): + return EditorPlugin.AFTER_GUI_INPUT_STOP [/codeblock] Must [code]return false[/code] in order to forward the [InputEvent] to other Editor classes. Example: [codeblock] # Consumes InputEventMouseMotion and forwards other InputEvent types - func forward_spatial_gui_input(index, camera, event): - var forward = false + func forward_spatial_gui_input(camera, event): + var forward = EditorPlugin.AFTER_GUI_INPUT_STOP if event is InputEventMouseMotion: - forward = true + forward = EditorPlugin.AFTER_GUI_INPUT_PASS return forward [/codeblock] diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index edf1bfdb5..981c3bda9 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -7022,20 +7022,25 @@ bool EditorPluginList::forward_gui_input(const Ref &p_event) { return discard; } -bool EditorPluginList::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event, bool serve_when_force_input_enabled) { - bool discard = false; +EditorPlugin::AfterGUIInput EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref &p_event, bool serve_when_force_input_enabled) { + EditorPlugin::AfterGUIInput after = EditorPlugin::AFTER_GUI_INPUT_PASS; for (int i = 0; i < plugins_list.size(); i++) { if ((!serve_when_force_input_enabled) && plugins_list[i]->is_input_event_forwarding_always_enabled()) { continue; } - if (plugins_list[i]->forward_spatial_gui_input(p_index, p_camera, p_event)) { - discard = true; + EditorPlugin::AfterGUIInput current_after = plugins_list[i]->forward_spatial_gui_input(p_camera, p_event); + if (current_after == EditorPlugin::AFTER_GUI_INPUT_STOP) { + after = EditorPlugin::AFTER_GUI_INPUT_STOP; + } + + if (after != EditorPlugin::AFTER_GUI_INPUT_STOP && current_after == EditorPlugin::AFTER_GUI_INPUT_DESELECT) { + after = EditorPlugin::AFTER_GUI_INPUT_DESELECT; } } - return discard; + return after; } void EditorPluginList::forward_canvas_draw_over_viewport(Control *p_overlay) { diff --git a/editor/editor_node.h b/editor/editor_node.h index 8e6dfe9bf..2591fd272 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -962,7 +962,7 @@ public: bool forward_gui_input(const Ref &p_event); void forward_canvas_draw_over_viewport(Control *p_overlay); void forward_canvas_force_draw_over_viewport(Control *p_overlay); - bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event, bool serve_when_force_input_enabled); + EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event, bool serve_when_force_input_enabled); void forward_spatial_draw_over_viewport(Control *p_overlay); void forward_spatial_force_draw_over_viewport(Control *p_overlay); void add_plugin(EditorPlugin *p_plugin); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 41b5664f9..da6ceffd6 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -621,12 +621,13 @@ int EditorPlugin::update_overlays() const { } } -bool EditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { +EditorPlugin::AfterGUIInput EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) { - return get_script_instance()->call("forward_spatial_gui_input", p_index, p_camera, p_event); + int success = get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event); + return static_cast(success); } - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) { @@ -895,7 +896,7 @@ void EditorPlugin::_bind_methods() { ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name")); @@ -943,6 +944,10 @@ void EditorPlugin::_bind_methods() { BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UR); BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BR); BIND_ENUM_CONSTANT(DOCK_SLOT_MAX); + + BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_PASS); + BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_STOP); + BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_DESELECT); } EditorPlugin::EditorPlugin() : diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 7de484d2d..40958cf9f 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -40,16 +40,16 @@ #include "core/dictionary.h" #include "core/error_list.h" #include "core/error_macros.h" +#include "core/io/config_file.h" #include "core/list.h" #include "core/method_bind.h" #include "core/object.h" #include "core/os/memory.h" #include "core/reference.h" +#include "core/undo_redo.h" #include "core/ustring.h" #include "core/variant.h" #include "core/vector.h" -#include "core/io/config_file.h" -#include "core/undo_redo.h" class EditorNode; class Spatial; @@ -191,6 +191,12 @@ public: DOCK_SLOT_MAX }; + enum AfterGUIInput { + AFTER_GUI_INPUT_PASS, + AFTER_GUI_INPUT_STOP, + AFTER_GUI_INPUT_DESELECT + }; + //TODO: send a resource for editing to the editor node? void add_control_to_container(CustomControlContainer p_location, Control *p_control); @@ -219,7 +225,7 @@ public: virtual void forward_canvas_draw_over_viewport(Control *p_overlay); virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay); - virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event); + virtual AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event); virtual void forward_spatial_draw_over_viewport(Control *p_overlay); virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay); @@ -282,6 +288,7 @@ public: VARIANT_ENUM_CAST(EditorPlugin::CustomControlContainer); VARIANT_ENUM_CAST(EditorPlugin::DockSlot); +VARIANT_ENUM_CAST(EditorPlugin::AfterGUIInput); typedef EditorPlugin *(*EditorPluginCreateFunc)(EditorNode *); diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 558126c27..c64c4b3da 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -128,9 +128,9 @@ void Polygon3DEditor::_wip_close() { undo_redo->commit_action(); } -bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { +EditorPlugin::AfterGUIInput Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { if (!node) { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } Transform gt = node->get_global_transform(); @@ -149,7 +149,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref 1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x, wip[0].y, depth))).distance_to(gpoint) < grab_threshold) { //wip closed _wip_close(); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } else { wip.push_back(cpoint); edited_point = wip.size(); snap_ignore = false; _polygon_draw(); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } } } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) { @@ -209,7 +209,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Refadd_do_method(this, "_polygon_draw"); undo_redo->add_undo_method(this, "_polygon_draw"); undo_redo->commit_action(); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } //search edges @@ -244,7 +244,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Refcreate_action(TTR("Edit Poly")); undo_redo->add_do_method(node, "set_polygon", poly); @@ -288,7 +288,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Refcommit_action(); edited_point = -1; - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } } } @@ -315,7 +315,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Refadd_do_method(this, "_polygon_draw"); undo_redo->add_undo_method(this, "_polygon_draw"); undo_redo->commit_action(); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } } @@ -335,7 +335,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref &p_event); + virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event); void edit(Node *p_collision_polygon); Polygon3DEditor(EditorNode *p_editor); ~Polygon3DEditor(); @@ -116,7 +116,7 @@ class Polygon3DEditorPlugin : public EditorPlugin { EditorNode *editor; public: - virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); } + virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); } virtual String get_name() const { return "Polygon3DEditor"; } bool has_main_screen() const { return false; } diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index e3d3cedeb..75e65b92d 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -311,13 +311,13 @@ PathSpatialGizmo::PathSpatialGizmo(Path *p_path) { set_spatial_node(p_path); } -bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { +EditorPlugin::AfterGUIInput PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { if (!path) { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } Ref c = path->get_curve(); if (c.is_null()) { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } Transform gt = path->get_global_transform(); Transform it = gt.affine_inverse(); @@ -346,14 +346,14 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, PoolVector::Read r = v3a.read(); if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist) { - return false; //nope, existing + return EditorPlugin::AFTER_GUI_INPUT_PASS; //nope, existing } for (int i = 0; i < c->get_point_count() - 1; i++) { //find the offset and point index of the place to break up int j = idx; if (p_camera->unproject_position(gt.xform(c->get_point_position(i + 1))).distance_to(mbpos) < click_dist) { - return false; //nope, existing + return EditorPlugin::AFTER_GUI_INPUT_PASS; //nope, existing } while (j < rc && c->get_point_position(i + 1) != r[j]) { @@ -403,7 +403,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, ur->add_do_method(c.ptr(), "add_point", closest_seg_point, Vector3(), Vector3(), closest_seg + 1); ur->add_undo_method(c.ptr(), "remove_point", closest_seg + 1); ur->commit_action(); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } else { Vector3 org; @@ -422,7 +422,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, ur->add_do_method(c.ptr(), "add_point", it.xform(inters), Vector3(), Vector3(), -1); ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count()); ur->commit_action(); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } //add new at pos @@ -442,27 +442,27 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, ur->add_do_method(c.ptr(), "remove_point", i); ur->add_undo_method(c.ptr(), "add_point", c->get_point_position(i), c->get_point_in(i), c->get_point_out(i), i); ur->commit_action(); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } else if (dist_to_p_out < click_dist) { UndoRedo *ur = editor->get_undo_redo(); ur->create_action(TTR("Remove Out-Control Point")); ur->add_do_method(c.ptr(), "set_point_out", i, Vector3()); ur->add_undo_method(c.ptr(), "set_point_out", i, c->get_point_out(i)); ur->commit_action(); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } else if (dist_to_p_in < click_dist) { UndoRedo *ur = editor->get_undo_redo(); ur->create_action(TTR("Remove In-Control Point")); ur->add_do_method(c.ptr(), "set_point_in", i, Vector3()); ur->add_undo_method(c.ptr(), "set_point_in", i, c->get_point_in(i)); ur->commit_action(); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } } } } - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } void PathEditorPlugin::edit(Object *p_object) { diff --git a/editor/plugins/path_editor_plugin.h b/editor/plugins/path_editor_plugin.h index 5764fd579..350d62217 100644 --- a/editor/plugins/path_editor_plugin.h +++ b/editor/plugins/path_editor_plugin.h @@ -114,7 +114,7 @@ public: Path *get_edited_path() { return path; } static PathEditorPlugin *singleton; - virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event); + virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event); //virtual bool forward_gui_input(const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); } //virtual Ref create_spatial_gizmo(Spatial *p_spatial); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 4b66ec63a..fb8a5b9d1 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -1365,7 +1365,7 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) { EditorNode *en = editor; EditorPluginList *force_input_forwarding_list = en->get_editor_plugins_force_input_forwarding(); if (!force_input_forwarding_list->empty()) { - bool discard = force_input_forwarding_list->forward_spatial_gui_input(index, camera, p_event, true); + bool discard = force_input_forwarding_list->forward_spatial_gui_input(camera, p_event, true); if (discard) { return; } @@ -1375,7 +1375,7 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) { EditorNode *en = editor; EditorPluginList *over_plugin_list = en->get_editor_plugins_over(); if (!over_plugin_list->empty()) { - bool discard = over_plugin_list->forward_spatial_gui_input(index, camera, p_event, false); + bool discard = over_plugin_list->forward_spatial_gui_input(camera, p_event, false); if (discard) { return; } diff --git a/modules/mesh_data_resource/editor/mdi_ed_plugin.cpp b/modules/mesh_data_resource/editor/mdi_ed_plugin.cpp index 6f729620f..46e20c5d0 100644 --- a/modules/mesh_data_resource/editor/mdi_ed_plugin.cpp +++ b/modules/mesh_data_resource/editor/mdi_ed_plugin.cpp @@ -131,19 +131,19 @@ Ref MDIEdPlugin::get_mdr() { return Ref(); } -bool MDIEdPlugin::forward_spatial_gui_input(int index, Camera *camera, const Ref &p_event) { +EditorPlugin::AfterGUIInput MDIEdPlugin::forward_spatial_gui_input(Camera *camera, const Ref &p_event) { if (!ObjectDB::instance_validate(current_mesh_data_instance)) { current_mesh_data_instance = nullptr; } if (current_mesh_data_instance) { Ref g = get_gizmo_from(current_mesh_data_instance); - if (g.is_valid() && g->forward_spatial_gui_input(index, camera, p_event)) { - return true; + if (g.is_valid()) { + return g->forward_spatial_gui_input(camera, p_event); } } - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } void MDIEdPlugin::add_box() { diff --git a/modules/mesh_data_resource/editor/mdi_ed_plugin.h b/modules/mesh_data_resource/editor/mdi_ed_plugin.h index ad6b87d09..c2685a15a 100644 --- a/modules/mesh_data_resource/editor/mdi_ed_plugin.h +++ b/modules/mesh_data_resource/editor/mdi_ed_plugin.h @@ -61,7 +61,7 @@ public: Ref get_mdr(); - bool forward_spatial_gui_input(int index, Camera *camera, const Ref &p_event); + EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *camera, const Ref &p_event); void add_box(); void add_triangle(); diff --git a/modules/mesh_data_resource/editor/mdi_gizmo.cpp b/modules/mesh_data_resource/editor/mdi_gizmo.cpp index babc67c96..0d9a242db 100644 --- a/modules/mesh_data_resource/editor/mdi_gizmo.cpp +++ b/modules/mesh_data_resource/editor/mdi_gizmo.cpp @@ -228,13 +228,13 @@ void MDIGizmo::select_all() { redraw(); } -bool MDIGizmo::selection_click(int index, Camera *camera, const Ref &event) { +bool MDIGizmo::selection_click(Camera *camera, const Ref &event) { if (handle_selection_type == HANDLE_SELECTION_TYPE_FRONT) { - return selection_click_select_front_or_back(index, camera, event); + return selection_click_select_front_or_back(camera, event); } else if (handle_selection_type == HANDLE_SELECTION_TYPE_BACK) { - return selection_click_select_front_or_back(index, camera, event); + return selection_click_select_front_or_back(camera, event); } else { - return selection_click_select_through(index, camera, event); + return selection_click_select_through(camera, event); } return false; @@ -271,7 +271,7 @@ bool MDIGizmo::is_point_visible(const Vector3 &point_orig, const Vector3 &camera return true; } -bool MDIGizmo::selection_click_select_front_or_back(int index, Camera *camera, const Ref &event) { +bool MDIGizmo::selection_click_select_front_or_back(Camera *camera, const Ref &event) { Transform gt = get_spatial_node()->get_global_transform(); Vector3 ray_from = camera->get_global_transform().origin; Vector2 gpoint = event->get_position(); @@ -349,7 +349,7 @@ bool MDIGizmo::selection_click_select_front_or_back(int index, Camera *camera, c return false; } -bool MDIGizmo::selection_click_select_through(int index, Camera *camera, const Ref &event) { +bool MDIGizmo::selection_click_select_through(Camera *camera, const Ref &event) { Transform gt = get_spatial_node()->get_global_transform(); Vector3 ray_from = camera->get_global_transform().origin; Vector2 gpoint = event->get_position(); @@ -415,16 +415,16 @@ bool MDIGizmo::selection_click_select_through(int index, Camera *camera, const R return false; } -void MDIGizmo::selection_drag(int index, Camera *camera, const Ref &event) { +void MDIGizmo::selection_drag(Camera *camera, const Ref &event) { if (handle_selection_type == HANDLE_SELECTION_TYPE_FRONT) { - selection_drag_rect_select_front_back(index, camera, event); + selection_drag_rect_select_front_back(camera, event); } else if (handle_selection_type == HANDLE_SELECTION_TYPE_BACK) { - selection_drag_rect_select_front_back(index, camera, event); + selection_drag_rect_select_front_back(camera, event); } else { - selection_drag_rect_select_through(index, camera, event); + selection_drag_rect_select_through(camera, event); } } -void MDIGizmo::selection_drag_rect_select_front_back(int index, Camera *camera, const Ref &event) { +void MDIGizmo::selection_drag_rect_select_front_back(Camera *camera, const Ref &event) { Transform gt = get_spatial_node()->get_global_transform(); Vector3 ray_from = camera->get_global_transform().origin; @@ -512,7 +512,7 @@ void MDIGizmo::selection_drag_rect_select_front_back(int index, Camera *camera, redraw(); } -void MDIGizmo::selection_drag_rect_select_through(int index, Camera *camera, const Ref &event) { +void MDIGizmo::selection_drag_rect_select_through(Camera *camera, const Ref &event) { Transform gt = get_spatial_node()->get_global_transform(); Vector2 mouse_pos = event->get_position(); @@ -578,7 +578,7 @@ void MDIGizmo::selection_drag_rect_select_through(int index, Camera *camera, con redraw(); } -bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref &event) { +EditorPlugin::AfterGUIInput MDIGizmo::forward_spatial_gui_input(Camera *camera, const Ref &event) { _last_known_camera_facing = camera->get_transform().basis.xform(Vector3(0, 0, -1)); Ref event_button = event; @@ -606,7 +606,7 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Refis_pressed()) { @@ -622,11 +622,16 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref &event); + bool selection_click(Camera *camera, const Ref &event); bool is_point_visible(const Vector3 &point_orig, const Vector3 &camera_pos, const Transform >); - bool selection_click_select_front_or_back(int index, Camera *camera, const Ref &event); - bool selection_click_select_through(int index, Camera *camera, const Ref &event); - void selection_drag(int index, Camera *camera, const Ref &event); - void selection_drag_rect_select_front_back(int index, Camera *camera, const Ref &event); - void selection_drag_rect_select_through(int index, Camera *camera, const Ref &event); - bool forward_spatial_gui_input(int index, Camera *camera, const Ref &event); + bool selection_click_select_front_or_back(Camera *camera, const Ref &event); + bool selection_click_select_through(Camera *camera, const Ref &event); + void selection_drag(Camera *camera, const Ref &event); + void selection_drag_rect_select_front_back(Camera *camera, const Ref &event); + void selection_drag_rect_select_through(Camera *camera, const Ref &event); + EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *camera, const Ref &event); void add_to_all_selected(const Vector3 &ofs); void mul_all_selected_with_basis(const Basis &b); diff --git a/modules/skeleton_editor/skeleton_editor_plugin.cpp b/modules/skeleton_editor/skeleton_editor_plugin.cpp index 28695d540..b7b2a99d7 100644 --- a/modules/skeleton_editor/skeleton_editor_plugin.cpp +++ b/modules/skeleton_editor/skeleton_editor_plugin.cpp @@ -1151,13 +1151,17 @@ void ModuleSkeletonEditor::_draw_handles() { am->surface_set_material(0, handle_material); } -bool ModuleSkeletonEditor::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { +EditorPlugin::AfterGUIInput ModuleSkeletonEditor::forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { if (!skeleton || tool_mode == TOOL_MODE_BONE_NONE) { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } + return EditorPlugin::AFTER_GUI_INPUT_PASS; + +//TODO +/* SpatialEditor *se = SpatialEditor::get_singleton(); - SpatialEditorViewport *sev = se->get_editor_viewport(p_index); + SpatialEditorViewport *sev = se->get_editor_viewport(); Ref mb = p_event; if (mb.is_valid()) { @@ -1504,6 +1508,7 @@ bool ModuleSkeletonEditor::forward_spatial_gui_input(int p_index, Camera *p_came } return false; + */ } void ModuleSkeletonEditor::add_bone() { diff --git a/modules/skeleton_editor/skeleton_editor_plugin.h b/modules/skeleton_editor/skeleton_editor_plugin.h index 0729c974a..cad475b53 100644 --- a/modules/skeleton_editor/skeleton_editor_plugin.h +++ b/modules/skeleton_editor/skeleton_editor_plugin.h @@ -236,7 +236,7 @@ protected: static void _bind_methods(); public: - virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event); + virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event); void move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx); // Transform can be keyed, whether or not to show the button @@ -287,7 +287,7 @@ protected: static void _bind_methods(); public: - virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { return skel_editor->forward_spatial_gui_input(p_index, p_camera, p_event); } + virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { return skel_editor->forward_spatial_gui_input(p_camera, p_event); } virtual bool can_handle(Object *p_object); virtual void parse_begin(Object *p_object); UndoRedo *get_undo_redo() { return undo_redo; } @@ -300,11 +300,11 @@ class ModuleSkeletonEditorPlugin : public EditorPlugin { EditorNode *editor; public: - virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { + virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { if (SpatialEditor::get_singleton()->get_tool_mode() != SpatialEditor::TOOL_MODE_EXTERNAL) { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } - return skeleton_plugin->forward_spatial_gui_input(p_index, p_camera, p_event); + return skeleton_plugin->forward_spatial_gui_input(p_camera, p_event); } bool has_main_screen() const { return false; } virtual bool handles(Object *p_object) const; diff --git a/modules/terraman/world/terrain_world_editor.cpp b/modules/terraman/world/terrain_world_editor.cpp index 1136d3079..1005fa948 100644 --- a/modules/terraman/world/terrain_world_editor.cpp +++ b/modules/terraman/world/terrain_world_editor.cpp @@ -44,9 +44,9 @@ SOFTWARE. #include "scene/gui/slider.h" #include "scene/gui/scroll_container.h" -bool TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { +EditorPlugin::AfterGUIInput TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { if (!_world || !_world->get_editable()) { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } Ref mb = p_event; @@ -56,24 +56,24 @@ bool TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref Ref lib = _world->get_library(); if (!lib.is_valid()) - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; if (mb->get_button_index() == BUTTON_LEFT) { return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); } else { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } //return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); } } - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } -bool TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { +EditorPlugin::AfterGUIInput TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { if (!spatial_editor || !_world || !_world->is_inside_world()) - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; Camera *camera = p_camera; Vector3 from = camera->project_ray_origin(p_point); @@ -94,7 +94,7 @@ bool TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point channel = _channel_type; if (channel == -1) - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; int isolevel = _current_isolevel; bool mode_add = false; @@ -110,10 +110,10 @@ bool TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point _world->set_voxel_with_tool(mode_add, res.position, res.normal, selected_voxel, isolevel); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } void TerrainWorldEditor::edit(TerrainWorld *p_world) { diff --git a/modules/terraman/world/terrain_world_editor.h b/modules/terraman/world/terrain_world_editor.h index a07aa6b8e..908fa78d7 100644 --- a/modules/terraman/world/terrain_world_editor.h +++ b/modules/terraman/world/terrain_world_editor.h @@ -39,10 +39,10 @@ public: }; public: - bool forward_spatial_input_event(Camera *p_camera, const Ref &p_event); + EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref &p_event); void edit(TerrainWorld *p_world); - bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); + EditorPlugin::AfterGUIInput do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); TerrainWorldEditor(); TerrainWorldEditor(EditorNode *p_editor); @@ -90,7 +90,7 @@ protected: public: bool forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } - virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } + virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } virtual String get_name() const { return "TerrainWorldEditor"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); diff --git a/modules/terraman_2d/world/terrain_2d_world_editor.cpp b/modules/terraman_2d/world/terrain_2d_world_editor.cpp index bc4ecdcdb..44b599a4d 100644 --- a/modules/terraman_2d/world/terrain_2d_world_editor.cpp +++ b/modules/terraman_2d/world/terrain_2d_world_editor.cpp @@ -43,9 +43,9 @@ SOFTWARE. #include "scene/gui/scroll_container.h" #include "scene/gui/slider.h" -bool Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { +EditorPlugin::AfterGUIInput Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { if (!_world || !_world->get_editable()) { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } Ref mb = p_event; @@ -55,22 +55,22 @@ bool Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const R Ref lib = _world->get_library(); if (!lib.is_valid()) - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; if (mb->get_button_index() == BUTTON_LEFT) { return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); } else { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } //return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); } } - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } -bool Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { +EditorPlugin::AfterGUIInput Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { /* if (!spatial_editor || !_world || !_world->is_inside_world()) return false; @@ -113,7 +113,7 @@ bool Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_poi return true; } */ - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } void Terrain2DWorldEditor::edit(Terrain2DWorld *p_world) { diff --git a/modules/terraman_2d/world/terrain_2d_world_editor.h b/modules/terraman_2d/world/terrain_2d_world_editor.h index bf5ad21bc..66de727ff 100644 --- a/modules/terraman_2d/world/terrain_2d_world_editor.h +++ b/modules/terraman_2d/world/terrain_2d_world_editor.h @@ -41,10 +41,10 @@ public: }; public: - bool forward_spatial_input_event(Camera *p_camera, const Ref &p_event); + EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref &p_event); void edit(Terrain2DWorld *p_world); - bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); + EditorPlugin::AfterGUIInput do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); Terrain2DWorldEditor(); Terrain2DWorldEditor(EditorNode *p_editor); @@ -92,7 +92,7 @@ protected: public: bool forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } - virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } + virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } virtual String get_name() const { return "Terrain2DWorldEditor"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); diff --git a/modules/voxelman/world/voxel_world_editor.cpp b/modules/voxelman/world/voxel_world_editor.cpp index da0d75bf8..88ff04cb5 100644 --- a/modules/voxelman/world/voxel_world_editor.cpp +++ b/modules/voxelman/world/voxel_world_editor.cpp @@ -44,9 +44,9 @@ SOFTWARE. #include "scene/gui/slider.h" #include "scene/gui/scroll_container.h" -bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { +EditorPlugin::AfterGUIInput VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { if (!_world || !_world->get_editable()) { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } Ref mb = p_event; @@ -56,24 +56,24 @@ bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref lib = _world->get_library(); if (!lib.is_valid()) - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; if (mb->get_button_index() == BUTTON_LEFT) { return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); } else { - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } //return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); } } - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } -bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { +EditorPlugin::AfterGUIInput VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { if (!spatial_editor || !_world || !_world->is_inside_world()) - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; Camera *camera = p_camera; Vector3 from = camera->project_ray_origin(p_point); @@ -94,7 +94,7 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, channel = _channel_type; if (channel == -1) - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; int isolevel = _current_isolevel; bool mode_add = false; @@ -110,10 +110,10 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, _world->set_voxel_with_tool(mode_add, res.position, res.normal, selected_voxel, isolevel); - return true; + return EditorPlugin::AFTER_GUI_INPUT_STOP; } - return false; + return EditorPlugin::AFTER_GUI_INPUT_PASS; } void VoxelWorldEditor::edit(VoxelWorld *p_world) { diff --git a/modules/voxelman/world/voxel_world_editor.h b/modules/voxelman/world/voxel_world_editor.h index f56ac07f6..062781f11 100644 --- a/modules/voxelman/world/voxel_world_editor.h +++ b/modules/voxelman/world/voxel_world_editor.h @@ -41,10 +41,10 @@ public: }; public: - bool forward_spatial_input_event(Camera *p_camera, const Ref &p_event); + EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref &p_event); void edit(VoxelWorld *p_world); - bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); + EditorPlugin::AfterGUIInput do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); VoxelWorldEditor(); VoxelWorldEditor(EditorNode *p_editor); @@ -92,7 +92,7 @@ protected: public: bool forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } - virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } + virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } virtual String get_name() const { return "VoxelWorldEditor"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object);