summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/editor/editor_data.cpp10
-rw-r--r--tools/editor/editor_data.h1
-rw-r--r--tools/editor/editor_node.cpp116
-rw-r--r--tools/editor/editor_node.h36
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp6
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp10
-rw-r--r--tools/editor/scene_tree_dock.cpp3
7 files changed, 145 insertions, 37 deletions
diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp
index f78ab93c30..8bb2d60cab 100644
--- a/tools/editor/editor_data.cpp
+++ b/tools/editor/editor_data.cpp
@@ -260,6 +260,16 @@ EditorPlugin* EditorData::get_subeditor(Object *p_object) {
return NULL;
}
+Vector<EditorPlugin*> EditorData::get_subeditors(Object* p_object) {
+ Vector<EditorPlugin*> sub_plugins;
+ for (int i = 0; i < editor_plugins.size(); i++) {
+ if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) {
+ sub_plugins.push_back(editor_plugins[i]);
+ }
+ }
+ return sub_plugins;
+}
+
EditorPlugin* EditorData::get_editor(String p_name) {
for(int i=0;i<editor_plugins.size();i++) {
diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h
index 5814ae8f5c..79843c4df5 100644
--- a/tools/editor/editor_data.h
+++ b/tools/editor/editor_data.h
@@ -150,6 +150,7 @@ public:
EditorPlugin* get_editor(Object *p_object);
EditorPlugin* get_subeditor(Object *p_object);
+ Vector<EditorPlugin*> get_subeditors(Object *p_object);
EditorPlugin* get_editor(String p_name);
void copy_object_params(Object *p_object);
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 6d033a5c25..aa47e97622 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -1571,15 +1571,27 @@ void EditorNode::_imported(Node *p_node) {
}
+void EditorNode::_hide_top_editors() {
+ _display_top_editors(false);
-void EditorNode::_hide_top_editors() {
+ editor_plugins_over->clear();
+}
+
+void EditorNode::_display_top_editors(bool p_display) {
+ editor_plugins_over->make_visible(p_display);
+}
+
+void EditorNode::_set_top_editors(Vector<EditorPlugin*> p_editor_plugins_over) {
+ editor_plugins_over->set_plugins_list(p_editor_plugins_over);
+}
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
- editor_plugin_over=NULL;
+void EditorNode::_set_editing_top_editors(Object* p_current_object) {
+ editor_plugins_over->edit(p_current_object);
}
+
+
void EditorNode::_edit_current() {
uint32_t current = editor_history.get_current();
@@ -1598,8 +1610,7 @@ void EditorNode::_edit_current() {
property_editor->edit( NULL );
object_menu->set_disabled(true);
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
+ _display_top_editors(false);
return;
}
@@ -1679,20 +1690,18 @@ void EditorNode::_edit_current() {
}
- EditorPlugin *sub_plugin = editor_data.get_subeditor(current_obj);
-
- if (sub_plugin) {
+ Vector<EditorPlugin*> sub_plugins = editor_data.get_subeditors(current_obj);
+ if (!sub_plugins.empty()) {
+ _display_top_editors(false);
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
- editor_plugin_over=sub_plugin;
- editor_plugin_over->edit(current_obj);
- editor_plugin_over->make_visible(true);
- } else if (editor_plugin_over) {
+ _set_top_editors(sub_plugins);
+ _set_editing_top_editors(current_obj);
+ _display_top_editors(true);
+
+ } else if (!editor_plugins_over->get_plugins_list().empty()) {
- editor_plugin_over->make_visible(false);
- editor_plugin_over=NULL;
+ _hide_top_editors();
}
/*
@@ -2583,10 +2592,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
editor_data.get_undo_redo().clear_history();
- if (editor_plugin_over) { //reload editor plugin
- editor_plugin_over->edit(NULL);
- editor_plugin_over->edit(current);
- }
+
+ _set_editing_top_editors(NULL);
+ _set_editing_top_editors(current);
} break;
case OBJECT_CALL_METHOD: {
@@ -6138,7 +6146,7 @@ EditorNode::EditorNode() {
_rebuild_import_menu();
editor_plugin_screen=NULL;
- editor_plugin_over=NULL;
+ editor_plugins_over = memnew(EditorPluginList);
// force_top_viewport(true);
_edit_current();
@@ -6270,12 +6278,72 @@ EditorNode::EditorNode() {
EditorNode::~EditorNode() {
-
-
+
memdelete( EditorHelp::get_doc_data() );
memdelete(editor_selection);
+ memdelete(editor_plugins_over);
memdelete(file_server);
EditorSettings::destroy();
}
+/*
+ * EDITOR PLUGIN LIST
+ */
+
+
+void EditorPluginList::make_visible(bool p_visible) {
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ plugins_list[i]->make_visible(p_visible);
+ }
+ }
+}
+
+void EditorPluginList::edit(Object* p_object) {
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ plugins_list[i]->edit(p_object);
+ }
+ }
+}
+
+bool EditorPluginList::forward_input_event(const InputEvent& p_event) {
+ bool discard = false;
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ if (plugins_list[i]->forward_input_event(p_event)) {
+ discard = true;
+ }
+ }
+ }
+ return discard;
+}
+
+bool EditorPluginList::forward_spatial_input_event(Camera* p_camera, const InputEvent& p_event) {
+ bool discard = false;
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ if (plugins_list[i]->forward_spatial_input_event(p_camera, p_event)) {
+ discard = true;
+ }
+ }
+ }
+ return discard;
+}
+
+bool EditorPluginList::empty() {
+ return plugins_list.empty();
+}
+
+void EditorPluginList::clear() {
+ plugins_list.clear();
+}
+
+EditorPluginList::EditorPluginList() {
+}
+
+EditorPluginList::~EditorPluginList() {
+}
+
+
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index b8fabb4c55..e4939afd34 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -95,7 +95,7 @@
typedef void (*EditorNodeInitCallback)();
-
+class EditorPluginList;
class EditorNode : public Node {
@@ -372,7 +372,7 @@ private:
Vector<EditorPlugin*> editor_plugins;
EditorPlugin *editor_plugin_screen;
- EditorPlugin *editor_plugin_over;
+ EditorPluginList *editor_plugins_over;
EditorHistory editor_history;
EditorData editor_data;
@@ -449,6 +449,10 @@ private:
void _transform_keyed(Object *sp,const String& p_sub,const Transform& p_key);
void _hide_top_editors();
+ void _display_top_editors(bool p_display);
+ void _set_top_editors(Vector<EditorPlugin*> p_editor_plugins_over);
+ void _set_editing_top_editors(Object * p_current_object);
+
void _quick_opened();
void _quick_run();
@@ -575,7 +579,7 @@ public:
EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
- EditorPlugin *get_editor_plugin_over() { return editor_plugin_over; }
+ EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
PropertyEditor *get_property_editor() { return property_editor; }
static void add_editor_plugin(EditorPlugin *p_editor);
@@ -710,6 +714,32 @@ struct EditorProgress {
~EditorProgress() { EditorNode::progress_end_task(task); }
};
+class EditorPluginList : public Object {
+private:
+ Vector<EditorPlugin*> plugins_list;
+
+public:
+
+ void set_plugins_list(Vector<EditorPlugin*> p_plugins_list) {
+ plugins_list = p_plugins_list;
+ }
+
+ Vector<EditorPlugin*> get_plugins_list() {
+ return plugins_list;
+ }
+
+ void make_visible(bool p_visible);
+ void edit(Object *p_object);
+ bool forward_input_event(const InputEvent& p_event);
+ bool forward_spatial_input_event(Camera* p_camera, const InputEvent& p_event);
+ void clear();
+ bool empty();
+
+ EditorPluginList();
+ ~EditorPluginList();
+
+} ;
+
struct EditorProgressBG {
String task;
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index 6eb26542be..b5059e5299 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1037,10 +1037,10 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
{
EditorNode *en = editor;
- EditorPlugin *over_plugin = en->get_editor_plugin_over();
+ EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
- if (over_plugin) {
- bool discard = over_plugin->forward_input_event(p_event);
+ if (!over_plugin_list->empty()) {
+ bool discard = over_plugin_list->forward_input_event(p_event);
if (discard) {
accept_event();
return;
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index c78b3086ea..9ab7aafeb2 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -834,10 +834,10 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
{
EditorNode *en = editor;
- EditorPlugin *over_plugin = en->get_editor_plugin_over();
+ EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
- if (over_plugin) {
- bool discard = over_plugin->forward_spatial_input_event(camera,p_event);
+ if (!over_plugin_list->empty()) {
+ bool discard = over_plugin_list->forward_spatial_input_event(camera,p_event);
if (discard)
return;
}
@@ -3576,9 +3576,9 @@ void SpatialEditor::_unhandled_key_input(InputEvent p_event) {
{
EditorNode *en = editor;
- EditorPlugin *over_plugin = en->get_editor_plugin_over();
+ EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
- if (over_plugin && over_plugin->forward_input_event(p_event)) {
+ if (!over_plugin_list->empty() && over_plugin_list->forward_input_event(p_event)) {
return; //ate the over input event
}
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index 5877ce1a43..6b2961ea72 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -1098,8 +1098,7 @@ void SceneTreeDock::_delete_confirm() {
return;
- if (editor->get_editor_plugin_over())
- editor->get_editor_plugin_over()->make_visible(false);
+ editor->get_editor_plugins_over()->make_visible(false);
editor_data->get_undo_redo().create_action("Remove Node(s)");