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.
This commit is contained in:
Zher Huei Lee 2016-02-28 19:58:17 +00:00
parent 6fc1c3a4d1
commit d8ac5cff57
4 changed files with 35 additions and 3 deletions

View file

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

View file

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

View file

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

View file

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