You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-04 17:04:49 +00:00
Keep the bottom panel size separate.
This commit is contained in:
@@ -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<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);
|
||||
@@ -91,9 +111,19 @@ 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");
|
||||
|
||||
@@ -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.
|
||||
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<Shortcut> &p_shortcut, bool p_at_front) {
|
||||
p_item->set_name(p_text);
|
||||
add_child(p_item);
|
||||
|
||||
Reference in New Issue
Block a user