Enables the possibility of editing on multiple plugins at same time on same object type.

This commit is contained in:
hodes 2016-03-29 20:02:53 -03:00
parent 15d1fca061
commit 7a1d7af332
7 changed files with 146 additions and 38 deletions

View File

@ -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++) {

View File

@ -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);

View File

@ -1571,15 +1571,27 @@ void EditorNode::_imported(Node *p_node) {
}
void EditorNode::_hide_top_editors() {
if (editor_plugin_over)
editor_plugin_over->make_visible(false);
editor_plugin_over=NULL;
_display_top_editors(false);
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);
}
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);
Vector<EditorPlugin*> sub_plugins = editor_data.get_subeditors(current_obj);
if (sub_plugin) {
if (!sub_plugins.empty()) {
_display_top_editors(false);
_set_top_editors(sub_plugins);
_set_editing_top_editors(current_obj);
_display_top_editors(true);
} else if (!editor_plugins_over->get_plugins_list().empty()) {
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) {
editor_plugin_over->make_visible(false);
editor_plugin_over=NULL;
_hide_top_editors();
}
/*
@ -2579,10 +2588,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: {
@ -6134,7 +6142,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();
@ -6266,12 +6274,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() {
}

View File

@ -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;

View File

@ -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;

View File

@ -810,10 +810,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;
}
@ -3553,9 +3553,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
}

View File

@ -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)");