From 7089dc7a8f5b864dca1601e66b900d0f81a37f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 27 Aug 2026 13:42:17 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20redesign(app):=20subtitles=20liv?= =?UTF-8?q?e=20in=20the=20Text=20tab,=20not=20a=20stray=20dock=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moves the subtitle palette out of its unconditional spot under the source list and into the library's Text tab, styled like the other media rows (round dot, same ink/type scale, same hover fill and selection ring) instead of its own visual dialect. Text.holds() now answers the same extension-only question Media/Audio's own arms do instead of a hardcoded false, and the empty state is one word. --- crates/app/src/importing.rs | 16 +- crates/app/src/tests/layout.rs | 15 +- crates/app/src/ui/dock_stance.rs | 256 ++++++++++++++++--------------- 3 files changed, 155 insertions(+), 132 deletions(-) diff --git a/crates/app/src/importing.rs b/crates/app/src/importing.rs index b6ccbd2..50ef105 100644 --- a/crates/app/src/importing.rs +++ b/crates/app/src/importing.rs @@ -24,14 +24,20 @@ impl LibraryTab { } } - /// Whether a source belongs on this tab. Subtitles are not sources at all - /// -- they are the [`Player::subtitle_section`] under the list -- so the - /// Text tab holds no rows of its own and says so. + /// Whether a source belongs on this tab. Text mirrors Media/Audio's own + /// rule -- an extension-only kind check, [`is_subtitle`] -- rather than + /// the `false` it used to hardcode: a standalone `.srt`/`.vtt`/`.ass` is + /// a Text source in the same sense an `.mp3` is an Audio one. A track + /// *inside* a container (a Matroska's embedded track) never reaches this + /// check at all -- the Text tab's rows are built from + /// [`crate::subs::subtitle_rows`] grouped by source, not filtered off + /// [`crate::library_meta::library_rows`] the way Media/Audio's are -- so + /// this only ever gates a standalone subtitle file. pub(crate) fn holds(self, path: &Path) -> bool { match self { LibraryTab::Media => !engine::is_audio(path), LibraryTab::Audio => engine::is_audio(path), - LibraryTab::Text => false, + LibraryTab::Text => is_subtitle(path), } } @@ -40,7 +46,7 @@ impl LibraryTab { match self { LibraryTab::Media => "No video", LibraryTab::Audio => "No sound", - LibraryTab::Text => "No subtitles", + LibraryTab::Text => "empty", } } } diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 5c6f52a..fd166c9 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -1249,18 +1249,19 @@ fn the_text_tab_carries_the_add_subtitles_door() { ); // ...and the empty tab stays a noun, not a sentence pointing at the // button (DESIGN §8, 2026-08-27: no instructional copy). - assert_eq!(crate::LibraryTab::Text.empty(), "No subtitles"); + assert_eq!(crate::LibraryTab::Text.empty(), "empty"); } -/// The Darkroom keeps imported subtitle tracks in the Sources dock, where a -/// row can be selected, folded with its source, removed, and dragged to the +/// The Darkroom keeps imported subtitle tracks in the Text tab itself (moved +/// off the unconditional spot under the Sources list, user 2026-08-27), where +/// a row can be selected, folded with its source, removed, and dragged to the /// bench's existing subtitle-lane target. #[test] fn the_darkroom_subtitle_palette_drags_tracks_to_subtitle_lanes() { let dock = src_text("ui/dock_stance.rs"); let palette = &dock[dock - .find("fn subtitle_palette") - .expect("no Darkroom subtitle palette")..]; + .find("fn subtitle_tab_rows") + .expect("no Darkroom subtitle rows")..]; for required in [ "subtitle_rows", "dock-subtitle-group", @@ -1283,8 +1284,8 @@ fn the_darkroom_subtitle_palette_drags_tracks_to_subtitle_lanes() { ); } -/// A subtitle group's header in the dock must not vanish on a short -/// window: `subtitle_palette` draws one per group unconditionally -- there +/// A subtitle group's header in the Text tab must not vanish on a short +/// window: `subtitle_tab_rows` draws one per group unconditionally -- there /// is no viewport-height gate on it at all any more, so the list under it /// is what would scroll instead, never the header itself. And it has to be /// a real fold, not the click-cycling pattern this codebase has already diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index a16e053..652f8af 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -616,13 +616,20 @@ fn source_row( }) } -/// Imported subtitle tracks, grouped by their source. A row selects and drags -/// its track; its header folds that source's rows without becoming a cycle. -fn subtitle_palette(player: &Player, cx: &mut Context) -> Option { - let groups = subtitle_rows(player.session.as_ref()?.subtitles()); - if groups.is_empty() { - return None; - } +/// Imported subtitle tracks, grouped by their source -- the Text tab's own +/// rows (DESIGN.md's "text section ... not serving to anything", user +/// 2026-08-27: relocated off the unconditional spot under the source list +/// and into the tab that names them). A row selects and drags its track; its +/// header folds that source's rows without becoming a cycle. Styled off +/// [`source_row`] -- same dot, same name/detail ink and type scale, same +/// hover fill and selection ring -- so Text stops reading as a second +/// dialect from Media/Audio. Hands back the track count for the tab header's +/// own count line, same as `rows.len()` does for the other two tabs. +fn subtitle_tab_rows(player: &Player, cx: &mut Context) -> (usize, Vec) { + let groups = match player.session.as_ref() { + Some(session) => subtitle_rows(session.subtitles()), + None => Vec::new(), + }; let count: usize = groups.iter().map(|group| group.rows.len()).sum(); let rows: Vec<_> = groups .into_iter() @@ -654,11 +661,11 @@ fn subtitle_palette(player: &Player, cx: &mut Context) -> Option) -> Option) -> Option) -> Option) -> Option) -> Option) -> Option) -> Option) -> Option) -> impl IntoElement { let focused = player.focus_dock.is_focused(window); - let sources = player - .session - .as_ref() - .map_or(&[][..], PlaybackSession::sources); - let all_rows: Vec = library_rows( - sources, - &player.streams, - &player.decoders, - player.timeline_audio(), - |path| { - player - .session - .as_ref() - .map_or(0, |session| session.file_frames(path)) - }, - ); - let filter = player.dock_filter.to_lowercase(); - let mut rows: Vec<(Row, usize)> = all_rows - .into_iter() - .filter(|row| player.library_tab.holds(&row.path)) - .map(|row| { - let placed = player.row_ctx(&row.path, row.stream).placed; - (row, placed) - }) - .filter(|(row, placed)| { - filter.is_empty() - || row.name.to_lowercase().contains(&filter) - || row.detail.to_lowercase().contains(&filter) - || ("unused".contains(&filter) && *placed == 0) - }) - .collect(); - let unused_count = rows.iter().filter(|(_, placed)| *placed == 0).count(); - match player.dock_sort { - DockSort::Recent => {} - DockSort::Name => { - rows.sort_by(|(a, _), (b, _)| a.name.to_lowercase().cmp(&b.name.to_lowercase())) + let text_tab = player.library_tab == LibraryTab::Text; + // Text has no per-stream `Row` to fill -- its rows are subtitle tracks + // grouped by source ([`subtitle_tab_rows`]), not `library_rows`' files -- + // so it takes its own branch instead of a `Row` shape that would not fit + // it. `dock_filter`/`dock_sort` stay Media/Audio's own: a subtitle track + // has no "unused" count and its own row order is the file's own order, + // the same reason the old palette never carried either control. + let (total, unused_count, row_elements): (usize, usize, Vec) = if text_tab { + let (count, elements) = subtitle_tab_rows(player, cx); + (count, 0, elements) + } else { + let sources = player + .session + .as_ref() + .map_or(&[][..], PlaybackSession::sources); + let all_rows: Vec = library_rows( + sources, + &player.streams, + &player.decoders, + player.timeline_audio(), + |path| { + player + .session + .as_ref() + .map_or(0, |session| session.file_frames(path)) + }, + ); + let filter = player.dock_filter.to_lowercase(); + let mut rows: Vec<(Row, usize)> = all_rows + .into_iter() + .filter(|row| player.library_tab.holds(&row.path)) + .map(|row| { + let placed = player.row_ctx(&row.path, row.stream).placed; + (row, placed) + }) + .filter(|(row, placed)| { + filter.is_empty() + || row.name.to_lowercase().contains(&filter) + || row.detail.to_lowercase().contains(&filter) + || ("unused".contains(&filter) && *placed == 0) + }) + .collect(); + let unused_count = rows.iter().filter(|(_, placed)| *placed == 0).count(); + match player.dock_sort { + DockSort::Recent => {} + DockSort::Name => { + rows.sort_by(|(a, _), (b, _)| a.name.to_lowercase().cmp(&b.name.to_lowercase())) + } + DockSort::Usage => rows.sort_by(|(_, a), (_, b)| b.cmp(a)), + DockSort::Unused => rows.sort_by_key(|(_, placed)| *placed > 0), } - DockSort::Usage => rows.sort_by(|(_, a), (_, b)| b.cmp(a)), - DockSort::Unused => rows.sort_by_key(|(_, placed)| *placed > 0), - } - let total = rows.len(); + let total = rows.len(); + let elements: Vec = rows + .iter() + .enumerate() + .map(|(i, (row, placed))| { + let picked = player + .selected_asset + .as_ref() + .is_some_and(|p| *p == (row.path.clone(), row.stream)); + source_row(player, i, row, *placed, picked, cx).into_any_element() + }) + .collect(); + (total, unused_count, elements) + }; let filter_text: SharedString = player.dock_filter.clone().into(); div() .id("dock-sources") @@ -894,7 +916,11 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context) - .overflow_y_scroll() .child({ let style = head(); - let hint: SharedString = format!("{total} total · {unused_count} unused").into(); + let hint: SharedString = match text_tab { + true => format!("{total} total"), + false => format!("{total} total · {unused_count} unused"), + } + .into(); div() .id("dock-header") .flex_none() @@ -963,34 +989,38 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context) - .child(tab.label()) })), ) - .child({ - let current = player.dock_sort; - let style = label(type_scale::FLOOR_PX, FontWeight::MEDIUM); - div() - .id("dock-sort-cycle") - .flex_none() - .px(px(6.)) - .py(px(2.)) - .rounded(px(3.)) - .font(style.font) - .text_size(style.size) - .text_color(rgb(INK2())) - .cursor_pointer() - .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { - this.dock_sort = this.dock_sort.next(); - cx.notify(); - })) - .children(hitmap::dynamic( - move || { - ( - "dock.sort.cycle".to_string(), - format!("Sort: {} — click to cycle", current.label()), - ) - }, - true, - )) - .child(format!("↕ {}", current.label())) + // The sort cycle is Media/Audio's own: a subtitle track's order is + // its file's own order, not a pick among Recent/Name/Usage/Unused. + .when(!text_tab, |d| { + d.child({ + let current = player.dock_sort; + let style = label(type_scale::FLOOR_PX, FontWeight::MEDIUM); + div() + .id("dock-sort-cycle") + .flex_none() + .px(px(6.)) + .py(px(2.)) + .rounded(px(3.)) + .font(style.font) + .text_size(style.size) + .text_color(rgb(INK2())) + .cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { + this.dock_sort = this.dock_sort.next(); + cx.notify(); + })) + .children(hitmap::dynamic( + move || { + ( + "dock.sort.cycle".to_string(), + format!("Sort: {} — click to cycle", current.label()), + ) + }, + true, + )) + .child(format!("↕ {}", current.label())) + }) }) .child( div() @@ -1001,35 +1031,21 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context) - .flex_col() .gap(px(2.)) .overflow_y_scroll() - .when(rows.is_empty(), |d| { + .when(row_elements.is_empty(), |d| { let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); d.child( div() .font(style.font) .text_size(style.size) .text_color(rgb(INK3())) - .child(match player.dock_filter.is_empty() { + .child(match text_tab || player.dock_filter.is_empty() { true => player.library_tab.empty().to_string(), false => "nothing matches the filter".to_string(), }), ) }) - .children({ - let elements: Vec<_> = rows - .iter() - .enumerate() - .map(|(i, (row, placed))| { - let picked = player - .selected_asset - .as_ref() - .is_some_and(|p| *p == (row.path.clone(), row.stream)); - source_row(player, i, row, *placed, picked, cx).into_any_element() - }) - .collect(); - elements - }), + .children(row_elements), ) - .children(subtitle_palette(player, cx)) .child(section_head("IMPORT")) .child( div()