diff --git a/DESIGN.md b/DESIGN.md index 9deb535..3afcead 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -78,6 +78,8 @@ Two faces, fixed roles (bundled, no runtime deps): Scale: 18px hero timecode (700, colons in `ink3`) · 15px labels/rows (500) · 13–14px chords and metadata (500) · 12px section heads (Archivo 700, uppercase, +0.14em letter-spacing, `ink3`). +Room/column heads (Settings) are 15px Archivo 700 `ink1`; in-list section heads stay 12px `ink3` +(2026-09-10 -- the settings columns read as body text and a person could not find them). Nothing below 10px. Every size is a whole pixel (no half-pixel sizes -- they put glyph baselines off the pixel grid and blurred cosmic-text's AA). No italics. Tabular figures wherever digits align. diff --git a/crates/app/src/library_meta.rs b/crates/app/src/library_meta.rs index 6be957d..ddbe126 100644 --- a/crates/app/src/library_meta.rs +++ b/crates/app/src/library_meta.rs @@ -125,9 +125,56 @@ pub(crate) fn library_rows( }); } } + disambiguate(&mut rows); rows } +/// Two files whose rows read the same word ("2026-09-09 18-05-50" twice, user +/// 2026-09-10 -- two screen recordings) are told apart on the metadata line +/// rather than left as a pair of identical rows: the folder they came out of +/// when that differs, and a `#n` in arrival order when even the folder is +/// shared. Compared on the stem, because the stem is what the row draws. +fn disambiguate(rows: &mut [Row]) { + let named: Vec<(String, PathBuf)> = rows + .iter() + .map(|row| (crate::files::stem(&row.path), row.path.clone())) + .collect(); + for i in 0..rows.len() { + let mut twins: Vec<&PathBuf> = Vec::new(); + for (name, path) in &named { + if *name == named[i].0 && !twins.contains(&path) { + twins.push(path); + } + } + if twins.len() < 2 { + continue; + } + let folder = rows[i] + .path + .parent() + .and_then(Path::file_name) + .map(|f| f.to_string_lossy().to_string()) + .unwrap_or_default(); + let alone_in_it = twins + .iter() + .filter(|p| p.parent() == rows[i].path.parent()) + .count() + == 1; + let mark = match alone_in_it && !folder.is_empty() { + true => folder, + false => format!( + "#{}", + twins + .iter() + .position(|p| **p == rows[i].path) + .expect("a row finds itself") + + 1 + ), + }; + rows[i].detail = join_detail(&rows[i].detail, &mark); + } +} + /// The row's second line: what the stream is and then either how long it is or /// why it cannot be used, with the separator only where both halves exist (a /// single-stream file says nothing about its stream). diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 2612718..e0a32d8 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -1292,6 +1292,97 @@ fn the_darkroom_subtitle_palette_drags_tracks_to_subtitle_lanes() { ); } +/// A file's subtitle tracks are that file's subset and are listed as one: +/// directly under the row that names it, never after every unrelated file +/// (user 2026-09-10, screenshot -- two screen recordings sat between a film +/// and its own subtitle group). A `.srt` nobody carries stays top-level, in +/// arrival order, at the end. +#[test] +fn a_file_subtitle_group_follows_its_own_row() { + use crate::ui::dock_stance::{Slot, source_list_order}; + let film = PathBuf::from("/films/a.mkv"); + let other = PathBuf::from("/rec/b.mp4"); + let loose = PathBuf::from("/subs/late.srt"); + assert_eq!( + source_list_order( + &[film.clone(), other.clone()], + &[film.clone(), loose.clone()] + ), + [Slot::Media(0), Slot::Subs(0), Slot::Media(1), Slot::Subs(1)], + "the film's own tracks must sit between it and the next file" + ); + // A file with several audio streams has several rows; the tracks follow + // the last of them, so the file's own rows stay together. + assert_eq!( + source_list_order( + &[film.clone(), other.clone(), film.clone()], + &[film.clone()] + ), + [Slot::Media(0), Slot::Media(1), Slot::Media(2), Slot::Subs(0)], + ); + // Nobody's `.srt`: still a top-level row, still last. + assert_eq!( + source_list_order(&[other], &[loose]), + [Slot::Media(0), Slot::Subs(0)], + ); +} + +/// ...and the Sources list is *built* through that ordering rather than by +/// appending the subtitle groups after the media rows, which is what put a +/// film's own tracks at the end of the list. +#[test] +fn the_sources_list_is_built_through_the_ordering() { + let dock = src_text("ui/dock_stance.rs"); + let tab = &dock[dock.find("fn sources_tab").expect("no sources tab")..]; + assert!( + tab.contains("source_list_order(&media, &subs)"), + "the Sources list no longer goes through source_list_order" + ); + assert!( + !tab.contains("row_elements.extend(subtitles)"), + "the subtitle groups are appended after every source again" + ); + // A parent already in the list gets the tracks bare, under it. + let palette = &dock[dock.find("fn subtitle_tab_rows").expect("no subtitle rows")..]; + assert!( + palette.contains("let nested = parents.contains(&group.path)") + && palette.contains("let has_header = !nested || track_count > 3"), + "a group under its own parent still draws a group row" + ); +} + +/// Two files whose rows read the same word are told apart on the metadata +/// line -- the folder, or `#n` when the folder is shared too. +#[test] +fn same_named_files_are_told_apart_on_the_metadata_line() { + let three: Vec = ["/a/rec.mp4", "/b/rec.mp4", "/a/solo.mp4"] + .into_iter() + .map(|path| Source { + path: PathBuf::from(path), + audio_stream: 0, + }) + .collect(); + let rows = library_rows(&three, &HashMap::new(), &HashMap::new(), None, |_| 90); + assert_eq!( + rows.iter().map(|row| row.detail.as_str()).collect::>(), + ["a", "b", ""], + "twins say which folder they came out of" + ); + let twins: Vec = ["/a/rec.mp4", "/a/rec.mkv"] + .into_iter() + .map(|path| Source { + path: PathBuf::from(path), + audio_stream: 0, + }) + .collect(); + let rows = library_rows(&twins, &HashMap::new(), &HashMap::new(), None, |_| 90); + assert_eq!( + rows.iter().map(|row| row.detail.as_str()).collect::>(), + ["#1", "#2"], + "one folder, one stem: arrival order tells them apart" + ); +} + /// 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 @@ -3904,6 +3995,70 @@ fn no_region_root_wears_a_focus_ring() { } +/// The user could not find the three columns (2026-09-10: "I couldn't realize +/// them when I look at"), because their heads were 12px `ink3` -- the room's +/// quietest type -- with a prose tail running on after each one. DESIGN §3's +/// new line: a room/column head is 15px Archivo 700 `ink1`, and the prose is a +/// hover plate (DESIGN §8), never ambient text on the head itself. +#[test] +fn the_settings_columns_wear_room_heads_not_section_heads() { + let source = src_text("ui/settings_stance.rs"); + let start = source.find("fn room_head(").expect("the room head"); + let body = &source[start..source[start..].find("\n}\n").unwrap() + start]; + for needle in [ + "type_scale::LABEL_ROW_PX", + "FontWeight::BOLD", + "rgb(INK1())", + ".tooltip(", + ".pb(px(12.))", + ] { + assert!(body.contains(needle), "a room head lost {needle}"); + } + assert!( + !body.contains("INK3()") && !body.contains("type_scale::head()"), + "the room heads fell back to the 12px in-list section head" + ); + // Each column head is one word, and its prose lives on the plate. + for head in ["\"PROJECT\"", "\"EDITOR\"", "\"EXPORT\""] { + assert!(source.contains(head), "the settings room lost its {head} head"); + } + for run_on in ["PROJECT \u{b7}", "EDITOR \u{b7}", "EXPORT \u{b7}"] { + assert!( + !source.contains(run_on), + "a settings head grew its prose tail back: {run_on}" + ); + } +} + +/// The Picture row said every refused format's reason after its value +/// (`H.264 no picture -- an mp4 would \u{b7} AV1 no picture -- ...`; the user +/// called it "funny"). A row says its own pick: one value, and a refusal only +/// when *that* pick is the refused one. +#[test] +fn the_picture_row_tail_is_the_current_format_alone() { + let source = src_text("ui/settings_stance.rs"); + let start = source.find("fn export_section(").expect("the export section"); + let body = &source[start..]; + let body = &body[..body.find("\n/// The page itself").expect("the page's render fn")]; + assert!( + !body.contains("PICTURE_CYCLE"), + "the Picture row walks the whole cycle to build its tail again" + ); + assert!( + !body.contains(".join("), + "an EXPORT row concatenates a list into one row's tail again" + ); + assert!( + body.contains("format_refusal(session, format)"), + "the Picture row's refusal is no longer asked about the current format" + ); + // Six words at most, and the value greys with the refusal it carries. + assert!( + body.contains("short_reason(&why)") && body.contains("picture_ink"), + "the Picture row lost its short reason or its greyed value" + ); +} + /// The monitoring level's home. Cleanse round 2 took the mute button, the /// `- +` pair and the slider off the time band on the promise that the level /// "lives in Settings" (DESIGN 5) -- a promise nothing kept until this row, diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index d012db6..161e43f 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -521,6 +521,47 @@ fn source_row( }) } +/// One entry of the Sources list, planned before anything is drawn: either a +/// media row or the subtitle group of some file. Plain data so the *order* -- +/// the branchy part -- can be tested without a window. +#[derive(Debug, PartialEq)] +pub(crate) enum Slot { + /// Index into the media rows. + Media(usize), + /// Index into the subtitle groups. + Subs(usize), +} + +/// Where each subtitle group belongs in the one Sources list: directly under +/// the source that carries it, never at the end of the list (user 2026-09-10, +/// "you put a video related subtitle to the end") -- a track that belongs to a +/// file is that file's subset and reads as one, so it follows the *last* row +/// naming that file, the way `library_rows` keeps a file's audio streams +/// together. A standalone `.srt` belongs to nobody and stays a top-level row +/// in arrival order, after the sources. +pub(crate) fn source_list_order(media: &[PathBuf], subs: &[PathBuf]) -> Vec { + let mut slots = Vec::new(); + for (i, path) in media.iter().enumerate() { + slots.push(Slot::Media(i)); + if media[i + 1..].contains(path) { + continue; // a later row still names this file; its subs go under that one + } + slots.extend( + subs.iter() + .enumerate() + .filter(|(_, sub)| *sub == path) + .map(|(j, _)| Slot::Subs(j)), + ); + } + slots.extend( + subs.iter() + .enumerate() + .filter(|(_, sub)| !media.contains(sub)) + .map(|(j, _)| Slot::Subs(j)), + ); + slots +} + /// 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 @@ -530,7 +571,11 @@ fn source_row( /// 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) { +fn subtitle_tab_rows( + player: &Player, + parents: &[PathBuf], + cx: &mut Context, +) -> (usize, Vec<(PathBuf, usize, AnyElement)>) { let mut groups = match player.session.as_ref() { Some(session) => subtitle_rows(session.subtitles()), None => Vec::new(), @@ -574,7 +619,13 @@ fn subtitle_tab_rows(player: &Player, cx: &mut Context) -> (usize, Vec) -> (usize, Vec 3; + let folded = has_header && (nested != player.sub_folded.contains(&group_path)); + let header = div() .id(("dock-subtitle-group", group_ord)) .flex_none() .flex() .items_center() .gap(px(6.)) .px(px(8.)) + // Stepped in under its parent when it has one, the + // same outline the track rows below it read as. + .when(nested, |d| d.pl(px(22.))) .py(px(4.)) .rounded(px(3.)) .cursor_pointer() @@ -791,10 +841,19 @@ fn subtitle_tab_rows(player: &Player, cx: &mut Context) -> (usize, Vec = all_rows + let mut rows: Vec<(Row, usize)> = all_rows .into_iter() .map(|row| { let placed = player.row_ctx(&row.path, row.stream).placed; @@ -865,23 +924,49 @@ fn sources_tab( || ("unused".contains(&filter) && *placed == 0) }) .collect(); - let mut row_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(); // The subtitle tracks join the same list rather than hiding behind a tab // of their own: a standalone `.srt` is a source in the sense that matters // here -- something that came in and can go on a lane -- and the tracks - // inside a container stay grouped under the file that carries them. - let (_, subtitles) = subtitle_tab_rows(player, cx); - row_elements.extend(subtitles); + // inside a container are drawn *under* that file's own row + // ([`source_list_order`]), not after every other source. + let media: Vec = rows.iter().map(|(row, _)| row.path.clone()).collect(); + let (_, subtitles) = subtitle_tab_rows(player, &media, cx); + let subs: Vec = subtitles.iter().map(|(path, ..)| path.clone()).collect(); + // Past three tracks the group under a parent arrives shut, so the count + // goes on the parent's own metadata line -- the number stays readable + // while the rows it counts are folded away. + for (i, (row, _)) in rows.iter_mut().enumerate() { + if media[i + 1..].contains(&row.path) { + continue; + } + if let Some((_, n, _)) = subtitles + .iter() + .find(|(path, n, _)| *path == row.path && *n > 3) + { + row.detail = join_detail(&row.detail, &format!("{n} subs")); + } + } + let mut subtitles: Vec> = + subtitles.into_iter().map(|(.., el)| Some(el)).collect(); + let mut row_elements: Vec = Vec::new(); + for slot in source_list_order(&media, &subs) { + match slot { + Slot::Media(i) => { + let (row, placed) = &rows[i]; + let picked = player + .selected_asset + .as_ref() + .is_some_and(|p| *p == (row.path.clone(), row.stream)); + row_elements + .push(source_row(player, i, row, *placed, picked, cx).into_any_element()); + } + Slot::Subs(j) => { + if let Some(el) = subtitles[j].take() { + row_elements.push(el); + } + } + } + } let filter_text: SharedString = player.dock_filter.clone().into(); div() .id("dock-sources") diff --git a/crates/app/src/ui/settings_stance.rs b/crates/app/src/ui/settings_stance.rs index a871388..24e41d8 100644 --- a/crates/app/src/ui/settings_stance.rs +++ b/crates/app/src/ui/settings_stance.rs @@ -37,18 +37,27 @@ use crate::ui::type_scale; use crate::*; use engine::colorspace::ContentLight; -/// A 9px uppercase Archivo section head, `ink3` -- [`dock_stance::section_head`]'s -/// exact shape, repeated rather than imported across a `pub(crate)` seam for -/// one nine-line function. -fn section_head(text: impl Into) -> impl IntoElement { - let style = type_scale::head(); +/// The room's three anchors (user 2026-09-10: "I couldn't realize them when I +/// look at"): 15px Archivo 700 `ink1`, uppercase, with a row's own height of +/// air below (+12px past a row's gap) so a head reads as the start of a +/// column and not as one more line in it. The prose that used to trail each +/// head (`· stored in the .edith file`) is a hover plate on the head now, +/// ≤6 words -- DESIGN §8: a distinction that matters is a plate, not ambient +/// text. In-list section heads (the dock's own KEYS head) stay 12px +/// `ink3`. +fn room_head(id: &'static str, text: &'static str, tail: &'static str) -> impl IntoElement { + let style = type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::BOLD); + let tail: SharedString = tail.into(); div() + .id(id) .flex_none() .pt(px(4.)) + .pb(px(12.)) .font(style.font) .text_size(style.size) - .text_color(rgb(INK3())) - .child(text.into()) + .text_color(rgb(INK1())) + .tooltip(move |_, cx| cx.new(|_| Tip(tail.clone())).into()) + .child(text) } /// One row: a ≤16-char label, its current value in mono (units carried, @@ -318,7 +327,11 @@ fn project_section(player: &Player, cx: &mut Context) -> impl IntoElemen .flex() .flex_col() .gap(px(2.)) - .child(section_head("PROJECT · stored in the .edith file")) + .child(room_head( + "settings-head-project", + "PROJECT", + "stored in the .edith file", + )) .child(row_ink( "settings-resolution", "Resolution", @@ -405,7 +418,11 @@ fn editor_section(player: &Player, cx: &mut Context) -> impl IntoElement .flex() .flex_col() .gap(px(2.)) - .child(section_head("EDITOR · this machine, this window")) + .child(room_head( + "settings-head-editor", + "EDITOR", + "this machine, this window", + )) // The monitoring level, which lost its slider when the time band was // cleansed (DESIGN §5 -- "the level lives in Settings"). A readout and // not a widget: the number is spent rarely, so the wheel over the row @@ -567,8 +584,9 @@ pub(crate) fn picture_label(format: Format) -> String { /// The next file in [`PICTURE_CYCLE`] this machine can actually write. /// `refused` is the same door [`Player::set_format`] asks, so the stroke never -/// stops on a codec the setter would only refuse back -- the refused ones are -/// still *said*, on the row's own greyed tail (DESIGN §8: never hidden). +/// stops on a codec the setter would only refuse back -- a refusal is said on +/// the row only when the *current* pick is the refused one (DESIGN §8: never +/// hidden, never a list of the reasons for formats nobody picked). /// `current` where every other stop is refused, so `c` cannot cycle to /// nothing. pub(crate) fn next_picture(current: Format, refused: impl Fn(Format) -> bool) -> Format { @@ -625,20 +643,18 @@ pub(crate) fn short_reason(why: &str) -> String { /// the budget; the codec, the sound, the encoder and the range are here. fn export_section(player: &Player, cx: &mut Context) -> impl IntoElement { let format = player.format; - let refusals: Vec = PICTURE_CYCLE - .into_iter() - .filter_map(|f| { - player - .session - .as_ref() - .and_then(|session| format_refusal(session, f)) - .map(|why| format!("{} {}", format_label(f), short_reason(&why))) - }) - .collect(); - // Never hidden (DESIGN §8): a codec this machine has no encoder for stays - // on the row, greyed, with the reason beside it -- the export card's own - // refusal rows, in the one place a codec is picked now. - let refused_tail = (!refusals.is_empty()).then(|| (refusals.join(" \u{b7} ").into(), INK4())); + // The row says *this* pick, and a refusal only where this pick is the one + // refused (user 2026-09-10: every other format's reason ran on after the + // value -- "funny"). Never hidden (DESIGN §8): when the current format is + // one this machine cannot write, the value greys and the reason stands + // beside it in six words; the formats a person is not on say nothing, + // because `c` never stops on them anyway ([`next_picture`]). + let refused_now: Option<(SharedString, u32)> = player + .session + .as_ref() + .and_then(|session| format_refusal(session, format)) + .map(|why| (short_reason(&why).into(), INK4())); + let picture_ink = if refused_now.is_some() { INK4() } else { INK1() }; let (codec, rated) = sound_codec(format); let seat = player.encoder_seat(); let av1_gpu = seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4); @@ -655,19 +671,24 @@ fn export_section(player: &Player, cx: &mut Context) -> impl IntoElement .flex() .flex_col() .gap(px(2.)) - .child(section_head("EXPORT \u{b7} what a delivery is written as")) - .child(row_chord( + .child(room_head( + "settings-head-export", + "EXPORT", + "what a delivery is written as", + )) + .child(row_full( "settings-export-picture", "Picture", picture_label(format), "the codec the picture is written with and the box it lands in; the export moment asks only for the file and the budget", - "c", - refused_tail, + Some("c".into()), + refused_now, player, cx.listener(|this, _: &ClickEvent, _, cx| { this.cycle_export_picture(); cx.notify(); }), + picture_ink, )) .children(rated.then(|| { row_chord(