diff --git a/editor/audio/editor_audio_buses.cpp b/editor/audio/editor_audio_buses.cpp index fe8fb3b33bc..da1d34141c3 100644 --- a/editor/audio/editor_audio_buses.cpp +++ b/editor/audio/editor_audio_buses.cpp @@ -1074,6 +1074,11 @@ void EditorAudioBusDrop::_bind_methods() { ADD_SIGNAL(MethodInfo("dropped")); } +void EditorAudioBuses::_update_file_label_size() { + int label_min_width = file->get_minimum_size().x + file->get_character_bounds(0).size.x; + file->set_custom_minimum_size(Size2(label_min_width, 0)); +} + void EditorAudioBuses::_rebuild_buses() { for (int i = bus_hb->get_child_count() - 1; i >= 0; i--) { EditorAudioBus *audio_bus = Object::cast_to(bus_hb->get_child(i)); @@ -1111,6 +1116,7 @@ void EditorAudioBuses::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { bus_scroll->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree"))); + _update_file_label_size(); } break; case NOTIFICATION_READY: { @@ -1143,6 +1149,23 @@ void EditorAudioBuses::_notification(int p_what) { save_timer->start(); } } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible()) { + break; + } + + _update_file_label_size(); + + // Setting `the split_offset` value once to the minimum value required to display the entire contents of the `EditorAudioBuses`. + // This is used instead of setting a custom_minimum_size or similar, as this may cause the panel to be outside the window (see GH-26835). + // If `EditorAudioBuses` is selected when starting the editor, this code will be executed first and then the saved layout will load. + if (use_default_editor_size) { + use_default_editor_size = false; + int offset = EditorNode::get_bottom_panel()->get_combined_minimum_size().y + get_combined_minimum_size().y; + offset += Object::cast_to(bus_hb->get_child(0))->get_combined_minimum_size().y; // Master audio bus always exists. + EditorNode::get_singleton()->set_center_split_offset(-offset); + } + } break; } } @@ -1315,9 +1338,16 @@ EditorAudioBuses::EditorAudioBuses() { edited_path = ResourceUID::ensure_path(GLOBAL_GET("audio/buses/default_bus_layout")); + Label *layout_label = memnew(Label(TTRC("Layout:"))); + top_hb->add_child(layout_label); + file = memnew(Label); - file->set_text(vformat("%s %s", TTR("Layout:"), edited_path.get_file())); - file->set_clip_text(true); + const String _file_name = edited_path.get_file(); + file->set_text(_file_name); + file->set_tooltip_text(_file_name); + file->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); + file->set_mouse_filter(MOUSE_FILTER_PASS); + file->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS); file->set_h_size_flags(SIZE_EXPAND_FILL); top_hb->add_child(file); @@ -1356,7 +1386,7 @@ EditorAudioBuses::EditorAudioBuses() { bus_scroll = memnew(ScrollContainer); bus_scroll->set_v_size_flags(SIZE_EXPAND_FILL); - bus_scroll->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); + bus_scroll->set_custom_minimum_size(Size2(0, 40 * EDSCALE)); add_child(bus_scroll); bus_hb = memnew(HBoxContainer); bus_hb->set_v_size_flags(SIZE_EXPAND_FILL); @@ -1401,7 +1431,11 @@ void EditorAudioBuses::open_layout(const String &p_path) { } edited_path = path; - file->set_text(vformat("%s %s", TTR("Layout:"), path.get_file())); + const String _file_name = edited_path.get_file(); + file->set_text(_file_name); + file->set_tooltip_text(_file_name); + _update_file_label_size(); + AudioServer::get_singleton()->set_bus_layout(state); _rebuild_buses(); EditorUndoRedoManager::get_singleton()->clear_history(EditorUndoRedoManager::GLOBAL_HISTORY); diff --git a/editor/audio/editor_audio_buses.h b/editor/audio/editor_audio_buses.h index 457c393119c..1fe70ddb3f5 100644 --- a/editor/audio/editor_audio_buses.h +++ b/editor/audio/editor_audio_buses.h @@ -168,6 +168,8 @@ class EditorAudioBuses : public VBoxContainer { Timer *save_timer = nullptr; String edited_path; + void _update_file_label_size(); + void _rebuild_buses(); void _update_bus(int p_index); void _update_sends(); @@ -191,6 +193,8 @@ class EditorAudioBuses : public VBoxContainer { EditorFileDialog *file_dialog = nullptr; bool new_layout = false; + bool use_default_editor_size = true; + void _file_dialog_callback(const String &p_string); protected: diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 2c5deb72b7c..11883b58720 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6294,6 +6294,10 @@ bool EditorNode::is_distraction_free_mode_enabled() const { return distraction_free->is_pressed(); } +void EditorNode::set_center_split_offset(int p_offset) { + center_split->set_split_offset(p_offset); +} + Dictionary EditorNode::drag_resource(const Ref &p_res, Control *p_from) { Control *drag_control = memnew(Control); TextureRect *drag_preview = memnew(TextureRect); diff --git a/editor/editor_node.h b/editor/editor_node.h index b893f45faa2..dcbe9ab0733 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -793,6 +793,8 @@ public: void set_distraction_free_mode(bool p_enter); bool is_distraction_free_mode_enabled() const; + void set_center_split_offset(int p_offset); + void set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed = false); bool is_addon_plugin_enabled(const String &p_addon) const;