summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-07-07 21:58:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-07-07 21:58:58 +0200
commit56df419874a3af9bbfb4ba22816ce05cca6e4850 (patch)
tree04a3edcac8c07cb5e5853f3383b528ccaceb3e65
parent307b4e30919ae9762ed12fafbe9b04c90bd105ab (diff)
parent139288ca1e86177044a32c34d3506cc551f85aef (diff)
downloadredot-engine-56df419874a3af9bbfb4ba22816ce05cca6e4850.tar.gz
Merge pull request #94040 from Hilderin/fix-first-time-toggle-bottom-panel
Fix first time of Toggle Last Opened Bottom Panel opens Output panel
-rw-r--r--editor/editor_dock_manager.cpp18
-rw-r--r--editor/editor_dock_manager.h2
-rw-r--r--editor/gui/editor_bottom_panel.cpp6
3 files changed, 18 insertions, 8 deletions
diff --git a/editor/editor_dock_manager.cpp b/editor/editor_dock_manager.cpp
index ccb47220db..75135532aa 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<ConfigFile> 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<ConfigFile> 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 226222c55a..1e6b413d14 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 f2c4a13e05..3e74a3c94e 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<Sh
bpi.button = tb;
bpi.control = p_item;
bpi.name = p_text;
- items.push_back(bpi);
+ if (p_at_front) {
+ items.insert(0, bpi);
+ } else {
+ items.push_back(bpi);
+ }
return tb;
}