Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6012,9 +6012,6 @@ void EditorNode::_load_editor_layout() {
void EditorNode::_save_central_editor_layout_to_config(Ref<ConfigFile> 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);
Comment thread
DexterFstone marked this conversation as resolved.

// Debugger tab.
Expand All @@ -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);
Comment thread
DexterFstone marked this conversation as resolved.

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")) {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@ class EditorNode : public Node {
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;

Expand All @@ -743,6 +745,7 @@ class EditorNode : public Node {

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; }

Expand Down
41 changes: 40 additions & 1 deletion editor/gui/editor_bottom_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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<SplitContainer>(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);
Expand All @@ -91,16 +111,28 @@ void EditorBottomPanel::_repaint() {

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());

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) {
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");

if (stored_current_tab >= 0 && stored_current_tab < get_tab_bar()->get_tab_count()) {
// 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;
}
}
Expand Down Expand Up @@ -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<Shortcut> &p_shortcut, bool p_at_front) {
p_item->set_name(p_text);
add_child(p_item);
Expand Down
5 changes: 5 additions & 0 deletions editor/gui/editor_bottom_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class EditorBottomPanel : public TabContainer {
bool lock_panel_switching = false;
LocalVector<Control *> bottom_docks;
LocalVector<Ref<Shortcut>> dock_shortcuts;
HashMap<String, int> dock_offsets;

LocalVector<Button *> legacy_buttons;
void _on_button_visibility_changed(Button *p_button, Control *p_control);
Expand All @@ -56,6 +57,7 @@ class EditorBottomPanel : public TabContainer {
void _on_tab_changed(int p_idx);
void _pin_button_toggled(bool p_pressed);
void _expand_button_toggled(bool p_pressed);
void _update_center_split_offset();

protected:
void _notification(int p_what);
Expand All @@ -75,6 +77,9 @@ class EditorBottomPanel : public TabContainer {
void set_expanded(bool p_expanded);
void _theme_changed();

void set_bottom_panel_offset(int p_offset);
int get_bottom_panel_offset();

EditorBottomPanel();
~EditorBottomPanel();
};