1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Fix Audio bottom panel going under the taskbar on small displays

This commit is contained in:
arkology
2025-08-23 22:22:48 +03:00
parent 825ef2387f
commit ea17bf712a
4 changed files with 48 additions and 4 deletions

View File

@@ -1074,6 +1074,11 @@ void EditorAudioBusDrop::_bind_methods() {
ADD_SIGNAL(MethodInfo("dropped")); 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() { void EditorAudioBuses::_rebuild_buses() {
for (int i = bus_hb->get_child_count() - 1; i >= 0; i--) { for (int i = bus_hb->get_child_count() - 1; i >= 0; i--) {
EditorAudioBus *audio_bus = Object::cast_to<EditorAudioBus>(bus_hb->get_child(i)); EditorAudioBus *audio_bus = Object::cast_to<EditorAudioBus>(bus_hb->get_child(i));
@@ -1111,6 +1116,7 @@ void EditorAudioBuses::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {
bus_scroll->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree"))); bus_scroll->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
_update_file_label_size();
} break; } break;
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
@@ -1143,6 +1149,23 @@ void EditorAudioBuses::_notification(int p_what) {
save_timer->start(); save_timer->start();
} }
} break; } 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<Control>(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")); 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 = memnew(Label);
file->set_text(vformat("%s %s", TTR("Layout:"), edited_path.get_file())); const String _file_name = edited_path.get_file();
file->set_clip_text(true); 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); file->set_h_size_flags(SIZE_EXPAND_FILL);
top_hb->add_child(file); top_hb->add_child(file);
@@ -1356,7 +1386,7 @@ EditorAudioBuses::EditorAudioBuses() {
bus_scroll = memnew(ScrollContainer); bus_scroll = memnew(ScrollContainer);
bus_scroll->set_v_size_flags(SIZE_EXPAND_FILL); 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); add_child(bus_scroll);
bus_hb = memnew(HBoxContainer); bus_hb = memnew(HBoxContainer);
bus_hb->set_v_size_flags(SIZE_EXPAND_FILL); bus_hb->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -1401,7 +1431,11 @@ void EditorAudioBuses::open_layout(const String &p_path) {
} }
edited_path = 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); AudioServer::get_singleton()->set_bus_layout(state);
_rebuild_buses(); _rebuild_buses();
EditorUndoRedoManager::get_singleton()->clear_history(EditorUndoRedoManager::GLOBAL_HISTORY); EditorUndoRedoManager::get_singleton()->clear_history(EditorUndoRedoManager::GLOBAL_HISTORY);

View File

@@ -168,6 +168,8 @@ class EditorAudioBuses : public VBoxContainer {
Timer *save_timer = nullptr; Timer *save_timer = nullptr;
String edited_path; String edited_path;
void _update_file_label_size();
void _rebuild_buses(); void _rebuild_buses();
void _update_bus(int p_index); void _update_bus(int p_index);
void _update_sends(); void _update_sends();
@@ -191,6 +193,8 @@ class EditorAudioBuses : public VBoxContainer {
EditorFileDialog *file_dialog = nullptr; EditorFileDialog *file_dialog = nullptr;
bool new_layout = false; bool new_layout = false;
bool use_default_editor_size = true;
void _file_dialog_callback(const String &p_string); void _file_dialog_callback(const String &p_string);
protected: protected:

View File

@@ -6294,6 +6294,10 @@ bool EditorNode::is_distraction_free_mode_enabled() const {
return distraction_free->is_pressed(); 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<Resource> &p_res, Control *p_from) { Dictionary EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) {
Control *drag_control = memnew(Control); Control *drag_control = memnew(Control);
TextureRect *drag_preview = memnew(TextureRect); TextureRect *drag_preview = memnew(TextureRect);

View File

@@ -793,6 +793,8 @@ public:
void set_distraction_free_mode(bool p_enter); void set_distraction_free_mode(bool p_enter);
bool is_distraction_free_mode_enabled() const; 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); 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; bool is_addon_plugin_enabled(const String &p_addon) const;