From d0475046014470543dbd23edf82b9e5f36d050f2 Mon Sep 17 00:00:00 2001 From: jmb462 Date: Sun, 13 Feb 2022 14:16:12 +0100 Subject: Prevent docks to be reset to first tab when switching dock visibility --- editor/editor_node.cpp | 12 +++++++----- editor/editor_node.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 0b96900053..3ec8ff192d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4639,7 +4639,7 @@ void EditorNode::_load_docks() { editor_data.set_plugin_window_layout(config); } -void EditorNode::_update_dock_slots_visibility() { +void EditorNode::_update_dock_slots_visibility(bool p_keep_selected_tabs) { if (!docks_visible) { for (int i = 0; i < DOCK_SLOT_MAX; i++) { dock_slot[i]->hide(); @@ -4674,9 +4674,11 @@ void EditorNode::_update_dock_slots_visibility() { } } - for (int i = 0; i < DOCK_SLOT_MAX; i++) { - if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) { - dock_slot[i]->set_current_tab(0); + if (!p_keep_selected_tabs) { + for (int i = 0; i < DOCK_SLOT_MAX; i++) { + if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) { + dock_slot[i]->set_current_tab(0); + } } } @@ -5303,7 +5305,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { void EditorNode::set_docks_visible(bool p_show) { docks_visible = p_show; - _update_dock_slots_visibility(); + _update_dock_slots_visibility(true); } bool EditorNode::get_docks_visible() const { diff --git a/editor/editor_node.h b/editor/editor_node.h index 9cd96050e3..845248eddf 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -633,7 +633,7 @@ private: void _load_docks(); void _save_docks_to_config(Ref p_layout, const String &p_section); void _load_docks_from_config(Ref p_layout, const String &p_section); - void _update_dock_slots_visibility(); + void _update_dock_slots_visibility(bool p_keep_selected_tabs = false); void _dock_tab_changed(int p_tab); void _save_open_scenes_to_config(Ref p_layout, const String &p_section); -- cgit v1.2.3