Merge pull request #94053 from Hilderin/fix-toggle-last-opened-bottom-panel-after-restoring-to-side

Fix Toggle Last Opened Bottom Panel not working after restoring FileSystem Dock to the side
This commit is contained in:
Rémi Verschelde 2024-07-17 11:42:55 +02:00
commit efae318304
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 12 additions and 1 deletions

View File

@ -188,10 +188,11 @@ Button *EditorBottomPanel::add_item(String p_text, Control *p_item, const Ref<Sh
}
void EditorBottomPanel::remove_item(Control *p_item) {
bool was_visible = false;
for (int i = 0; i < items.size(); i++) {
if (items[i].control == p_item) {
if (p_item->is_visible_in_tree()) {
_switch_to_item(false, i);
was_visible = true;
}
item_vbox->remove_child(items[i].control);
button_hbox->remove_child(items[i].button);
@ -200,6 +201,16 @@ void EditorBottomPanel::remove_item(Control *p_item) {
break;
}
}
if (was_visible) {
// Open the first panel to ensure that if the removed dock was visible, the bottom
// panel will not collapse.
_switch_to_item(true, 0);
} else if (last_opened_control == p_item) {
// When a dock is removed by plugins, it might not have been visible, and it
// might have been the last_opened_control. We need to make sure to reset the last opened control.
last_opened_control = items[0].control;
}
}
void EditorBottomPanel::make_item_visible(Control *p_item, bool p_visible) {