1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-02 16:48:55 +00:00

Merge pull request #111499 from DexterFstone/Keep-the-bottom-panel-size-separate

Keep the bottom panel size separate.
This commit is contained in:
Thaddeus Crews
2025-11-12 11:24:13 -06:00
4 changed files with 53 additions and 9 deletions

View File

@@ -6012,9 +6012,6 @@ void EditorNode::_load_editor_layout() {
void EditorNode::_save_central_editor_layout_to_config(Ref<ConfigFile> p_config_file) { void EditorNode::_save_central_editor_layout_to_config(Ref<ConfigFile> p_config_file) {
// Bottom panel. // 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); bottom_panel->save_layout_to_config(p_config_file, EDITOR_NODE_CONFIG_SECTION);
// Debugger tab. // Debugger tab.
@@ -6032,11 +6029,6 @@ void EditorNode::_load_central_editor_layout_from_config(Ref<ConfigFile> p_confi
bottom_panel->load_layout_from_config(p_config_file, EDITOR_NODE_CONFIG_SECTION); 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. // Debugger tab.
if (p_config_file->has_section_key(EDITOR_NODE_CONFIG_SECTION, "selected_default_debugger_tab_idx")) { 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 #ifdef ANDROID_ENABLED
void EditorNode::_touch_actions_panel_mode_changed() { void EditorNode::_touch_actions_panel_mode_changed() {
int panel_mode = EDITOR_GET("interface/touchscreen/touch_actions_panel"); 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_v_size_flags(Control::SIZE_EXPAND_FILL);
center_split->set_collapsed(true); center_split->set_collapsed(true);
center_vb->add_child(center_split); center_vb->add_child(center_split);
center_split->connect("drag_ended", callable_mp(this, &EditorNode::_bottom_panel_resized));
right_hsplit = memnew(DockSplitContainer); right_hsplit = memnew(DockSplitContainer);
right_hsplit->set_name("DockHSplitRight"); right_hsplit->set_name("DockHSplitRight");

View File

@@ -718,6 +718,8 @@ private:
void _update_main_menu_type(); void _update_main_menu_type();
void _add_to_main_menu(const String &p_name, PopupMenu *p_menu); void _add_to_main_menu(const String &p_name, PopupMenu *p_menu);
void _bottom_panel_resized();
protected: protected:
friend class FileSystemDock; friend class FileSystemDock;
@@ -743,6 +745,7 @@ public:
static EditorTitleBar *get_title_bar() { return singleton->title_bar; } static EditorTitleBar *get_title_bar() { return singleton->title_bar; }
static VSplitContainer *get_top_split() { return singleton->top_split; } 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 EditorBottomPanel *get_bottom_panel() { return singleton->bottom_panel; }
static EditorMainScreen *get_editor_main_screen() { return singleton->editor_main_screen; } static EditorMainScreen *get_editor_main_screen() { return singleton->editor_main_screen; }

View File

@@ -52,6 +52,7 @@ void EditorBottomPanel::_notification(int p_what) {
} }
void EditorBottomPanel::_on_tab_changed(int p_idx) { 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(); 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() { void EditorBottomPanel::_repaint() {
bool panel_collapsed = get_current_tab() == -1; bool panel_collapsed = get_current_tab() == -1;
if (panel_collapsed == (get_previous_tab() == -1)) { if (panel_collapsed == (get_previous_tab() == -1)) {
return; return;
} }
SplitContainer *center_split = Object::cast_to<SplitContainer>(get_parent()); DockSplitContainer *center_split = EditorNode::get_center_split();
ERR_FAIL_NULL(center_split); ERR_FAIL_NULL(center_split);
center_split->set_dragger_visibility(panel_collapsed ? SplitContainer::DRAGGER_HIDDEN : SplitContainer::DRAGGER_VISIBLE); 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<ConfigFile> p_config_file, const String &p_section) const { void EditorBottomPanel::save_layout_to_config(Ref<ConfigFile> 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()); p_config_file->set_value(p_section, "selected_bottom_panel_item", get_current_tab() != -1 ? Variant(get_current_tab()) : Variant());
for (const KeyValue<String, int> &E : dock_offsets) {
p_config_file->set_value(p_section, "dock_" + E.key + "_offset", E.value);
}
} }
void EditorBottomPanel::load_layout_from_config(Ref<ConfigFile> p_config_file, const String &p_section) { void EditorBottomPanel::load_layout_from_config(Ref<ConfigFile> 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")) { 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"); 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<ConfigFile> p_config_file, c
// Make sure we don't try to open contextual editors which are not enabled in the current context. // 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)) { if (!get_tab_bar()->is_tab_hidden(stored_current_tab)) {
set_current_tab(stored_current_tab); set_current_tab(stored_current_tab);
callable_mp(this, &EditorBottomPanel::_update_center_split_offset).call_deferred();
return; return;
} }
} }
@@ -156,6 +188,13 @@ void EditorBottomPanel::_expand_button_toggled(bool p_pressed) {
EditorNode::get_top_split()->set_visible(!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<Shortcut> &p_shortcut, bool p_at_front) { Button *EditorBottomPanel::add_item(String p_text, Control *p_item, const Ref<Shortcut> &p_shortcut, bool p_at_front) {
p_item->set_name(p_text); p_item->set_name(p_text);
add_child(p_item); add_child(p_item);

View File

@@ -48,6 +48,7 @@ class EditorBottomPanel : public TabContainer {
bool lock_panel_switching = false; bool lock_panel_switching = false;
LocalVector<Control *> bottom_docks; LocalVector<Control *> bottom_docks;
LocalVector<Ref<Shortcut>> dock_shortcuts; LocalVector<Ref<Shortcut>> dock_shortcuts;
HashMap<String, int> dock_offsets;
LocalVector<Button *> legacy_buttons; LocalVector<Button *> legacy_buttons;
void _on_button_visibility_changed(Button *p_button, Control *p_control); void _on_button_visibility_changed(Button *p_button, Control *p_control);
@@ -56,6 +57,7 @@ class EditorBottomPanel : public TabContainer {
void _on_tab_changed(int p_idx); void _on_tab_changed(int p_idx);
void _pin_button_toggled(bool p_pressed); void _pin_button_toggled(bool p_pressed);
void _expand_button_toggled(bool p_pressed); void _expand_button_toggled(bool p_pressed);
void _update_center_split_offset();
protected: protected:
void _notification(int p_what); void _notification(int p_what);
@@ -75,6 +77,9 @@ public:
void set_expanded(bool p_expanded); void set_expanded(bool p_expanded);
void _theme_changed(); void _theme_changed();
void set_bottom_panel_offset(int p_offset);
int get_bottom_panel_offset();
EditorBottomPanel(); EditorBottomPanel();
~EditorBottomPanel(); ~EditorBottomPanel();
}; };