diff --git a/programs/src/music/main.cpp b/programs/src/music/main.cpp index 0acea16..7ea799e 100644 --- a/programs/src/music/main.cpp +++ b/programs/src/music/main.cpp @@ -1554,6 +1554,23 @@ extern "C" void _start() { // Scan for audio files scan_directory(); + // Auto-size window width so the longest track name fits without truncation. + // Layout per row: 24px left pad + name + 8px gap + tag ("MP3"/"WAV") + 12px + // right pad, plus ~10px for the scrollbar gutter. + { + int max_name_w = 0; + for (int i = 0; i < g.file_count; i++) { + int w = text_w(g.files[i].name, FONT_SIZE_SM); + if (w > max_name_w) max_name_w = w; + } + int tag_w = text_w("MP3", FONT_SIZE_SM); + int wav_w = text_w("WAV", FONT_SIZE_SM); + if (wav_w > tag_w) tag_w = wav_w; + int needed_w = 24 + max_name_w + 8 + tag_w + 12 + 10; + if (needed_w > g.win_w) g.win_w = needed_w; + if (g.win_w > 900) g.win_w = 900; + } + // If a specific file was requested, find it and auto-play int auto_play_idx = -1; if (arg_file[0]) {