Make bottom panel only try to hide editors when they're visible

This commit is contained in:
Michael Alexsander Silva Dias 2019-03-16 03:39:49 -03:00
parent 019908e5f0
commit ebabb0ea65
1 changed files with 14 additions and 7 deletions

View File

@ -4232,7 +4232,13 @@ bool EditorNode::are_bottom_panels_hidden() const {
void EditorNode::hide_bottom_panel() { void EditorNode::hide_bottom_panel() {
_bottom_panel_switch(false, 0); for (int i = 0; i < bottom_panel_items.size(); i++) {
if (bottom_panel_items[i].control->is_visible()) {
_bottom_panel_switch(false, i);
break;
}
}
} }
void EditorNode::make_bottom_panel_item_visible(Control *p_item) { void EditorNode::make_bottom_panel_item_visible(Control *p_item) {
@ -4269,7 +4275,7 @@ void EditorNode::remove_bottom_panel_item(Control *p_item) {
if (bottom_panel_items[i].control == p_item) { if (bottom_panel_items[i].control == p_item) {
if (p_item->is_visible_in_tree()) { if (p_item->is_visible_in_tree()) {
_bottom_panel_switch(false, 0); _bottom_panel_switch(false, i);
} }
bottom_panel_vb->remove_child(bottom_panel_items[i].control); bottom_panel_vb->remove_child(bottom_panel_items[i].control);
bottom_panel_hb_editors->remove_child(bottom_panel_items[i].button); bottom_panel_hb_editors->remove_child(bottom_panel_items[i].button);
@ -4289,6 +4295,10 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
ERR_FAIL_INDEX(p_idx, bottom_panel_items.size()); ERR_FAIL_INDEX(p_idx, bottom_panel_items.size());
if (bottom_panel_items[p_idx].control->is_visible() == p_enable) {
return;
}
if (p_enable) { if (p_enable) {
for (int i = 0; i < bottom_panel_items.size(); i++) { for (int i = 0; i < bottom_panel_items.size(); i++) {
@ -4309,11 +4319,8 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
} else { } else {
bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
for (int i = 0; i < bottom_panel_items.size(); i++) { bottom_panel_items[p_idx].button->set_pressed(false);
bottom_panel_items[p_idx].control->set_visible(false);
bottom_panel_items[i].button->set_pressed(false);
bottom_panel_items[i].control->set_visible(false);
}
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
center_split->set_collapsed(true); center_split->set_collapsed(true);
bottom_panel_raise->hide(); bottom_panel_raise->hide();