summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/editor_node.cpp12
-rw-r--r--editor/editor_node.h5
-rw-r--r--editor/editor_plugin.cpp8
-rw-r--r--editor/editor_plugin.h5
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp13
5 files changed, 38 insertions, 5 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 3a0825be9b..56b62cdf6e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -6142,6 +6142,7 @@ EditorNode::EditorNode() {
editor_plugin_screen = NULL;
editor_plugins_over = memnew(EditorPluginList);
+ editor_plugins_force_input_forwarding = memnew(EditorPluginList);
//force_top_viewport(true);
_edit_current();
@@ -6290,6 +6291,7 @@ EditorNode::~EditorNode() {
memdelete(EditorHelp::get_doc_data());
memdelete(editor_selection);
memdelete(editor_plugins_over);
+ memdelete(editor_plugins_force_input_forwarding);
memdelete(file_server);
EditorSettings::destroy();
}
@@ -6325,10 +6327,14 @@ bool EditorPluginList::forward_gui_input(const Transform2D &p_canvas_xform, cons
return discard;
}
-bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
+bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
bool discard = false;
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_camera, p_event)) {
discard = true;
}
@@ -6344,6 +6350,10 @@ void EditorPluginList::forward_draw_over_canvas(const Transform2D &p_canvas_xfor
}
}
+void EditorPluginList::add_plugin(EditorPlugin *p_plugin) {
+ plugins_list.push_back(p_plugin);
+}
+
bool EditorPluginList::empty() {
return plugins_list.empty();
}
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 0f4561572a..3870edb7c6 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -398,6 +398,7 @@ private:
Vector<EditorPlugin *> editor_plugins;
EditorPlugin *editor_plugin_screen;
EditorPluginList *editor_plugins_over;
+ EditorPluginList *editor_plugins_force_input_forwarding;
EditorHistory editor_history;
EditorData editor_data;
@@ -647,6 +648,7 @@ public:
EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
+ EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; }
PropertyEditor *get_property_editor() { return property_editor; }
VBoxContainer *get_property_editor_vb() { return prop_editor_vb; }
@@ -823,8 +825,9 @@ public:
void make_visible(bool p_visible);
void edit(Object *p_object);
bool forward_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event);
- bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
+ bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
void forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas);
+ void add_plugin(EditorPlugin *p_plugin);
void clear();
bool empty();
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 6fcea98e32..75ab1e8a44 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -147,6 +147,12 @@ void EditorPlugin::remove_tool_menu_item(const String &p_name) {
//EditorNode::get_singleton()->remove_tool_menu_item(p_name);
}
+void EditorPlugin::set_input_event_forwarding_always_enabled() {
+ input_event_forwarding_always_enabled = true;
+ EditorPluginList *always_input_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_input_forwarding();
+ always_input_forwarding_list->add_plugin(this);
+}
+
Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
//??
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
@@ -372,6 +378,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("edit_resource"), &EditorPlugin::edit_resource);
ClassDB::bind_method(D_METHOD("add_import_plugin"), &EditorPlugin::add_import_plugin);
ClassDB::bind_method(D_METHOD("remove_import_plugin"), &EditorPlugin::remove_import_plugin);
+ ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas:Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
@@ -414,6 +421,7 @@ void EditorPlugin::_bind_methods() {
EditorPlugin::EditorPlugin() {
undo_redo = NULL;
+ input_event_forwarding_always_enabled = false;
}
EditorPlugin::~EditorPlugin() {
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index c607846ec9..57a22a8b2f 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -61,6 +61,8 @@ class EditorPlugin : public Node {
UndoRedo *_get_undo_redo() { return undo_redo; }
+ bool input_event_forwarding_always_enabled;
+
protected:
static void _bind_methods();
UndoRedo &get_undo_redo() { return *undo_redo; }
@@ -106,6 +108,9 @@ public:
void add_tool_submenu_item(const String &p_name, Object *p_submenu);
void remove_tool_menu_item(const String &p_name);
+ void set_input_event_forwarding_always_enabled();
+ bool is_input_event_forwarding_always_enabled() { return input_event_forwarding_always_enabled; }
+
virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);
virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event);
virtual void forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas);
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 5da242ffaa..2d27e218ec 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -696,12 +696,19 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
return; //do NONE
{
-
+ 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(camera, p_event, true);
+ if (discard)
+ return;
+ }
+ }
+ {
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(camera, p_event);
+ bool discard = over_plugin_list->forward_spatial_gui_input(camera, p_event, false);
if (discard)
return;
}