diff options
author | Zher Huei Lee <lee.zh.92@gmail.com> | 2016-02-28 19:58:17 +0000 |
---|---|---|
committer | Zher Huei Lee <lee.zh.92@gmail.com> | 2016-02-28 19:58:17 +0000 |
commit | d8ac5cff579bb454b945eaf6c47f4240fb431570 (patch) | |
tree | 10460139f3d9121011bbda26eba7f697b7076008 /tools | |
parent | 6fc1c3a4d1cf0c865f7dfdb1221ef07a5d25f305 (diff) |
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.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/editor_node.cpp | 22 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 1 | ||||
-rw-r--r-- | tools/editor/editor_plugin.cpp | 12 | ||||
-rw-r--r-- | tools/editor/editor_plugin.h | 3 |
4 files changed, 35 insertions, 3 deletions
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;i<bottom_panel_items.size();i++) { + + if (bottom_panel_items[i].control==p_item) { + if (p_item->is_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;i<bottom_panel_items.size();i++) { + bottom_panel_items[i].button->disconnect("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<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial); virtual bool forward_input_event(const InputEvent& p_event); |