From cd943d18b2ae48e5395e38879f364c6c2565d216 Mon Sep 17 00:00:00 2001 From: DexterFstone Date: Fri, 10 Oct 2025 22:12:01 -0700 Subject: [PATCH] Keep the bottom panel size separate. --- editor/editor_node.cpp | 13 ++++------ editor/editor_node.h | 3 +++ editor/gui/editor_bottom_panel.cpp | 41 +++++++++++++++++++++++++++++- editor/gui/editor_bottom_panel.h | 5 ++++ 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 3967975ccc0..77b9e62684f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6012,9 +6012,6 @@ void EditorNode::_load_editor_layout() { void EditorNode::_save_central_editor_layout_to_config(Ref p_config_file) { // Bottom panel. - int center_split_offset = center_split->get_split_offset(); - p_config_file->set_value(EDITOR_NODE_CONFIG_SECTION, "center_split_offset", center_split_offset); - bottom_panel->save_layout_to_config(p_config_file, EDITOR_NODE_CONFIG_SECTION); // Debugger tab. @@ -6032,11 +6029,6 @@ void EditorNode::_load_central_editor_layout_from_config(Ref p_confi bottom_panel->load_layout_from_config(p_config_file, EDITOR_NODE_CONFIG_SECTION); - if (p_config_file->has_section_key(EDITOR_NODE_CONFIG_SECTION, "center_split_offset")) { - int center_split_offset = p_config_file->get_value(EDITOR_NODE_CONFIG_SECTION, "center_split_offset"); - center_split->set_split_offset(center_split_offset); - } - // Debugger tab. if (p_config_file->has_section_key(EDITOR_NODE_CONFIG_SECTION, "selected_default_debugger_tab_idx")) { @@ -7722,6 +7714,10 @@ void EditorNode::_add_to_main_menu(const String &p_name, PopupMenu *p_menu) { } } +void EditorNode::_bottom_panel_resized() { + bottom_panel->set_bottom_panel_offset(center_split->get_split_offset()); +} + #ifdef ANDROID_ENABLED void EditorNode::_touch_actions_panel_mode_changed() { int panel_mode = EDITOR_GET("interface/touchscreen/touch_actions_panel"); @@ -8171,6 +8167,7 @@ EditorNode::EditorNode() { center_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); center_split->set_collapsed(true); center_vb->add_child(center_split); + center_split->connect("drag_ended", callable_mp(this, &EditorNode::_bottom_panel_resized)); right_hsplit = memnew(DockSplitContainer); right_hsplit->set_name("DockHSplitRight"); diff --git a/editor/editor_node.h b/editor/editor_node.h index a5b011293b7..3c4676c764f 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -718,6 +718,8 @@ private: void _update_main_menu_type(); void _add_to_main_menu(const String &p_name, PopupMenu *p_menu); + void _bottom_panel_resized(); + protected: friend class FileSystemDock; @@ -743,6 +745,7 @@ public: static EditorTitleBar *get_title_bar() { return singleton->title_bar; } static VSplitContainer *get_top_split() { return singleton->top_split; } + static DockSplitContainer *get_center_split() { return singleton->center_split; } static EditorBottomPanel *get_bottom_panel() { return singleton->bottom_panel; } static EditorMainScreen *get_editor_main_screen() { return singleton->editor_main_screen; } diff --git a/editor/gui/editor_bottom_panel.cpp b/editor/gui/editor_bottom_panel.cpp index 7d3ff53e336..34cf31a30b8 100644 --- a/editor/gui/editor_bottom_panel.cpp +++ b/editor/gui/editor_bottom_panel.cpp @@ -52,6 +52,7 @@ void EditorBottomPanel::_notification(int p_what) { } void EditorBottomPanel::_on_tab_changed(int p_idx) { + callable_mp(this, &EditorBottomPanel::_update_center_split_offset).call_deferred(); callable_mp(this, &EditorBottomPanel::_repaint).call_deferred(); } @@ -68,13 +69,32 @@ void EditorBottomPanel::_theme_changed() { } } +void EditorBottomPanel::set_bottom_panel_offset(int p_offset) { + Control *current_tab = get_current_tab_control(); + if (current_tab) { + String name = current_tab->get_name(); + String key = name.to_snake_case(); + dock_offsets[key] = p_offset; + } +} + +int EditorBottomPanel::get_bottom_panel_offset() { + Control *current_tab = get_current_tab_control(); + if (current_tab) { + String name = current_tab->get_name(); + String key = name.to_snake_case(); + return dock_offsets[key]; + } + return 0; +} + void EditorBottomPanel::_repaint() { bool panel_collapsed = get_current_tab() == -1; if (panel_collapsed == (get_previous_tab() == -1)) { return; } - SplitContainer *center_split = Object::cast_to(get_parent()); + DockSplitContainer *center_split = EditorNode::get_center_split(); ERR_FAIL_NULL(center_split); center_split->set_dragger_visibility(panel_collapsed ? SplitContainer::DRAGGER_HIDDEN : SplitContainer::DRAGGER_VISIBLE); @@ -91,9 +111,19 @@ void EditorBottomPanel::_repaint() { void EditorBottomPanel::save_layout_to_config(Ref p_config_file, const String &p_section) const { p_config_file->set_value(p_section, "selected_bottom_panel_item", get_current_tab() != -1 ? Variant(get_current_tab()) : Variant()); + + for (const KeyValue &E : dock_offsets) { + p_config_file->set_value(p_section, "dock_" + E.key + "_offset", E.value); + } } void EditorBottomPanel::load_layout_from_config(Ref p_config_file, const String &p_section) { + for (const Control *dock : bottom_docks) { + String name = dock->get_name(); + String key = name.to_snake_case(); + dock_offsets[key] = p_config_file->get_value(p_section, "dock_" + key + "_offset", 0); + } + if (p_config_file->has_section_key(p_section, "selected_bottom_panel_item")) { int stored_current_tab = p_config_file->get_value(p_section, "selected_bottom_panel_item"); @@ -101,6 +131,8 @@ void EditorBottomPanel::load_layout_from_config(Ref p_config_file, c // Make sure we don't try to open contextual editors which are not enabled in the current context. if (!get_tab_bar()->is_tab_hidden(stored_current_tab)) { set_current_tab(stored_current_tab); + + callable_mp(this, &EditorBottomPanel::_update_center_split_offset).call_deferred(); return; } } @@ -156,6 +188,13 @@ void EditorBottomPanel::_expand_button_toggled(bool p_pressed) { EditorNode::get_top_split()->set_visible(!p_pressed); } +void EditorBottomPanel::_update_center_split_offset() { + DockSplitContainer *center_split = EditorNode::get_center_split(); + ERR_FAIL_NULL(center_split); + + center_split->set_split_offset(get_bottom_panel_offset()); +} + Button *EditorBottomPanel::add_item(String p_text, Control *p_item, const Ref &p_shortcut, bool p_at_front) { p_item->set_name(p_text); add_child(p_item); diff --git a/editor/gui/editor_bottom_panel.h b/editor/gui/editor_bottom_panel.h index d40236c8cd2..12afc61bf4a 100644 --- a/editor/gui/editor_bottom_panel.h +++ b/editor/gui/editor_bottom_panel.h @@ -48,6 +48,7 @@ class EditorBottomPanel : public TabContainer { bool lock_panel_switching = false; LocalVector bottom_docks; LocalVector> dock_shortcuts; + HashMap dock_offsets; LocalVector