From d8ac5cff579bb454b945eaf6c47f4240fb431570 Mon Sep 17 00:00:00 2001 From: Zher Huei Lee Date: Sun, 28 Feb 2016 19:58:17 +0000 Subject: Adds EditorPlugin::remove_control_from_bottom_panel() Also renames `add_control_to_bottom_dock` to `add_control_to_bottom_panel` so that it would be clear that the removal functions are different too. --- tools/editor/editor_node.cpp | 22 ++++++++++++++++++++++ tools/editor/editor_node.h | 1 + tools/editor/editor_plugin.cpp | 12 ++++++++++-- tools/editor/editor_plugin.h | 3 ++- 4 files changed, 35 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 4666a49655..c10f1e97fb 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -4810,6 +4810,28 @@ void EditorNode::raise_bottom_panel_item(Control *p_item) { } +void EditorNode::remove_bottom_panel_item(Control *p_item) { + + for(int i=0;iis_visible()) { + _bottom_panel_switch(false,0); + } + bottom_panel_vb->remove_child(bottom_panel_items[i].control); + bottom_panel_hb->remove_child(bottom_panel_items[i].button); + memdelete( bottom_panel_items[i].button ); + bottom_panel_items.remove(i); + break; + } + } + + for(int i=0;idisconnect("toggled",this,"_bottom_panel_switch"); + bottom_panel_items[i].button->connect("toggled",this,"_bottom_panel_switch",varray(i)); + } +} + void EditorNode::_bottom_panel_switch(bool p_enable,int p_idx) { ERR_FAIL_INDEX(p_idx,bottom_panel_items.size()); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index b5d3e536db..9fd8d07aef 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -691,6 +691,7 @@ public: void make_bottom_panel_item_visible(Control *p_item); void raise_bottom_panel_item(Control *p_item); void hide_bottom_panel(); + void remove_bottom_panel_item(Control *p_item); EditorNode(); ~EditorNode(); diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp index 89b9c59287..dc46361251 100644 --- a/tools/editor/editor_plugin.cpp +++ b/tools/editor/editor_plugin.cpp @@ -43,7 +43,7 @@ void EditorPlugin::remove_custom_type(const String& p_type){ } -void EditorPlugin::add_control_to_bottom_dock(Control *p_control, const String &p_title) { +void EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) { EditorNode::get_singleton()->add_bottom_panel_item(p_title,p_control); } @@ -62,6 +62,13 @@ void EditorPlugin::remove_control_from_docks(Control *p_control) { } +void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) { + + ERR_FAIL_NULL(p_control); + EditorNode::get_singleton()->remove_bottom_panel_item(p_control); + +} + void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Control *p_control) { switch(p_location) { @@ -270,9 +277,10 @@ Control *EditorPlugin::get_base_control() { void EditorPlugin::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container); - ObjectTypeDB::bind_method(_MD("add_control_to_bottom_dock","control:Control","title"),&EditorPlugin::add_control_to_bottom_dock); + ObjectTypeDB::bind_method(_MD("add_control_to_bottom_panel","control:Control","title"),&EditorPlugin::add_control_to_bottom_panel); ObjectTypeDB::bind_method(_MD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock); ObjectTypeDB::bind_method(_MD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks); + ObjectTypeDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel); ObjectTypeDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type); ObjectTypeDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type); diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h index 75a3b3b26f..a7460d7fde 100644 --- a/tools/editor/editor_plugin.h +++ b/tools/editor/editor_plugin.h @@ -91,9 +91,10 @@ public: //TODO: send a resoucre for editing to the editor node? void add_control_to_container(CustomControlContainer p_location, Control *p_control); - void add_control_to_bottom_dock(Control *p_control, const String &p_title); + void add_control_to_bottom_panel(Control *p_control, const String &p_title); void add_control_to_dock(DockSlot p_slot,Control *p_control); void remove_control_from_docks(Control *p_control); + void remove_control_from_bottom_panel(Control *p_control); virtual Ref create_spatial_gizmo(Spatial* p_spatial); virtual bool forward_input_event(const InputEvent& p_event); -- cgit v1.2.3