From 139288ca1e86177044a32c34d3506cc551f85aef Mon Sep 17 00:00:00 2001 From: Hilderin <81109165+Hilderin@users.noreply.github.com> Date: Sun, 7 Jul 2024 12:11:37 -0400 Subject: [PATCH] Fix first time of Toggle Last Opened Bottom Panel opens Output panel --- editor/editor_dock_manager.cpp | 18 ++++++++++++------ editor/editor_dock_manager.h | 2 +- editor/gui/editor_bottom_panel.cpp | 6 +++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/editor/editor_dock_manager.cpp b/editor/editor_dock_manager.cpp index ccb47220dbb..75135532aac 100644 --- a/editor/editor_dock_manager.cpp +++ b/editor/editor_dock_manager.cpp @@ -277,7 +277,7 @@ void EditorDockManager::_restore_dock_to_saved_window(Control *p_dock, const Dic p_window_dump.get("window_screen_rect", Rect2i())); } -void EditorDockManager::_dock_move_to_bottom(Control *p_dock) { +void EditorDockManager::_dock_move_to_bottom(Control *p_dock, bool p_visible) { _move_dock(p_dock, nullptr); all_docks[p_dock].at_bottom = true; @@ -288,7 +288,7 @@ void EditorDockManager::_dock_move_to_bottom(Control *p_dock) { // Force docks moved to the bottom to appear first in the list, and give them their associated shortcut to toggle their bottom panel. Button *bottom_button = EditorNode::get_bottom_panel()->add_item(all_docks[p_dock].title, p_dock, all_docks[p_dock].shortcut, true); bottom_button->connect(SceneStringName(gui_input), callable_mp(this, &EditorDockManager::_bottom_dock_button_gui_input).bind(bottom_button).bind(p_dock)); - EditorNode::get_bottom_panel()->make_item_visible(p_dock); + EditorNode::get_bottom_panel()->make_item_visible(p_dock, p_visible); } void EditorDockManager::_dock_remove_from_bottom(Control *p_dock) { @@ -548,11 +548,13 @@ void EditorDockManager::load_docks_from_config(Ref p_layout, const S // Don't open disabled docks. continue; } + bool at_bottom = false; if (restore_window_on_load && floating_docks_dump.has(name)) { all_docks[dock].previous_at_bottom = dock_bottom.has(name); _restore_dock_to_saved_window(dock, floating_docks_dump[name]); } else if (dock_bottom.has(name)) { - _dock_move_to_bottom(dock); + _dock_move_to_bottom(dock, false); + at_bottom = true; } else if (i >= 0) { _move_dock(dock, dock_slot[i], 0); } @@ -564,7 +566,11 @@ void EditorDockManager::load_docks_from_config(Ref p_layout, const S } else { // Make sure it is open. all_docks[dock].open = true; - dock->show(); + // It's important to not update the visibility of bottom panels. + // Visibility of bottom panels are managed in EditorBottomPanel. + if (!at_bottom) { + dock->show(); + } } all_docks[dock].dock_slot_index = i; @@ -668,7 +674,7 @@ void EditorDockManager::open_dock(Control *p_dock, bool p_set_current) { // Open dock to its previous location. if (all_docks[p_dock].previous_at_bottom) { - _dock_move_to_bottom(p_dock); + _dock_move_to_bottom(p_dock, true); } else if (all_docks[p_dock].dock_slot_index != DOCK_SLOT_NONE) { TabContainer *slot = dock_slot[all_docks[p_dock].dock_slot_index]; int tab_index = all_docks[p_dock].previous_tab_index; @@ -899,7 +905,7 @@ void DockContextPopup::_float_dock() { void DockContextPopup::_move_dock_to_bottom() { hide(); - dock_manager->_dock_move_to_bottom(context_dock); + dock_manager->_dock_move_to_bottom(context_dock, true); dock_manager->_update_layout(); } diff --git a/editor/editor_dock_manager.h b/editor/editor_dock_manager.h index 226222c55a7..1e6b413d146 100644 --- a/editor/editor_dock_manager.h +++ b/editor/editor_dock_manager.h @@ -121,7 +121,7 @@ private: void _open_dock_in_window(Control *p_dock, bool p_show_window = true, bool p_reset_size = false); void _restore_dock_to_saved_window(Control *p_dock, const Dictionary &p_window_dump); - void _dock_move_to_bottom(Control *p_dock); + void _dock_move_to_bottom(Control *p_dock, bool p_visible); void _dock_remove_from_bottom(Control *p_dock); bool _is_dock_at_bottom(Control *p_dock); diff --git a/editor/gui/editor_bottom_panel.cpp b/editor/gui/editor_bottom_panel.cpp index f2c4a13e057..3e74a3c94e5 100644 --- a/editor/gui/editor_bottom_panel.cpp +++ b/editor/gui/editor_bottom_panel.cpp @@ -178,7 +178,11 @@ Button *EditorBottomPanel::add_item(String p_text, Control *p_item, const Ref