From 622904e9655c1a4e34332a1fc656dbd1c5ab0856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 20 Aug 2026 15:04:45 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(ui):=20the=20room=20becomes=20?= =?UTF-8?q?the=20one=20in=20the=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Beside the mock, the shipped room was nowhere near it. The dock was the legacy library verbatim — pill tabs, a Media/Audio/Text row, a filled Import button, an amber accent no chrome may carry, and a source name clipped and dimmed past reading. It is now the dock the mock draws: a count line, a chrome-less filter, ghost sort chips, two-line rows whose names are mono and legible and ellipsize at the end, an import section, and the hint that names the four gestures. The spine groups its commands under heads and stacks each glyph over its chord. The time band leads with the timecode, carries the transport as ghosts, reads the cut out loud, and ends in the room's one bordered chip — which now actually exports: the stance had been suppressing the action and never mounted the card, so the control was wired to nothing. The bench grows real thumbnails and waveforms in the source's ink, with the name plate inside the clip where the mock puts it. The fonts the language always named are bundled at last: Archivo and Spline Sans Mono, cut to static weights because this text backend cannot read a variable axis and would have drawn every weight the same. The darkroom is the room you get now; OLD_GUI=1 opens the old one. --- crates/app/src/importing.rs | 15 + crates/app/src/main.rs | 32 +- crates/app/src/player/export.rs | 39 +++ crates/app/src/player/library.rs | 26 ++ crates/app/src/render.rs | 30 +- crates/app/src/tests/layout.rs | 5 +- crates/app/src/ui/bench_stance.rs | 100 +++++-- crates/app/src/ui/dock_stance.rs | 422 +++++++++++++++++++++++++-- crates/app/src/ui/mod.rs | 3 + crates/app/src/ui/spine_stance.rs | 167 +++++++++++ crates/app/src/ui/stance.rs | 152 +++------- crates/app/src/ui/timeband_stance.rs | 342 ++++++++++++++++++++++ crates/app/src/ui/type_scale.rs | 221 ++++++++++++++ crates/app/src/ui/widgets.rs | 10 +- 14 files changed, 1400 insertions(+), 164 deletions(-) create mode 100644 crates/app/src/ui/spine_stance.rs create mode 100644 crates/app/src/ui/timeband_stance.rs create mode 100644 crates/app/src/ui/type_scale.rs diff --git a/crates/app/src/importing.rs b/crates/app/src/importing.rs index a87639b..bcbf5c0 100644 --- a/crates/app/src/importing.rs +++ b/crates/app/src/importing.rs @@ -62,6 +62,21 @@ pub(crate) enum Wave { Peaks(Arc>), } +/// The bench's own version of [`Wave`] for the picture instead of the sound: one +/// representative decoded frame per file, kept and reused across every clip cut +/// from it (DESIGN.md §5's "real thumbnails across video clips", §12 step 5 -- +/// this is the frame, not the ink; the ink comes from [`crate::source_tint`] +/// until real extraction lands). Audio-only files never enter this map (see +/// `cache_media`'s filter), so `Silent` has no counterpart here. +#[derive(Clone)] +pub(crate) enum Thumb { + /// Asked for; the decode is running on a background thread. + Loading, + /// The decode failed or the file turned out to carry no picture after all. + Failed, + Ready(Arc), +} + /// What a source's stand-in is up to ([`engine::proxy`]). Kept per file and /// filled like every other library fact -- presence means "asked", so a repaint /// mid-encode cannot start a second one. diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index ca95803..2feb555 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -223,11 +223,24 @@ struct Player { /// (`ui::dock_stance::load`/`save`) so "a room reopens exactly as left" /// survives a quit and relaunch, not just this window. pub(crate) dock_src_active: bool, + /// The Sources tab's own filter text (darkroom dock, MOCK-SPEC "Dock" §2) + /// and whether it is the thing typed strokes go to right now -- the same + /// capture-flag shape `keys_search`/`keys_open` already use, so a letter + /// filters the list instead of firing a spine action while the box is + /// focused, and does nothing to the keymap once it is not. + pub(crate) dock_filter: String, + pub(crate) dock_filter_edit: bool, + /// Which of the four sort chips is showing (MOCK-SPEC "Dock" §3). + pub(crate) dock_sort: ui::dock_stance::DockSort, /// What is known about each source's audio, taken once and kept. Keyed on /// the path *and stream* -- two streams of one file are two envelopes -- and /// the key is inserted the moment the decode is *started*: presence means /// "asked", so a repaint mid-decode cannot ask again. waves: HashMap<(PathBuf, usize), Wave>, + /// The bench's poster frame per file ([`Thumb`]), filled like `waves` -- + /// presence means "asked" -- one per file rather than one per clip, since + /// every clip cut from a file shares its picture. + thumbs: HashMap, /// What each source's stand-in is up to ([`engine::proxy`]), filled like /// `waves`: presence means "asked", so the encode is started once per file /// however many times the library is drawn. The switch that decides whether @@ -765,7 +778,16 @@ fn main() { // DESIGN.md §1: "the room is the film's" -- darkroom mode owns the // palette outright, so the saved pick above is overridden the moment the // flag is read, once, before the first paint. - let darkroom = std::env::var("EDITH_DARKROOM").is_ok(); + // + // Darkroom is the default room now (user order: "make darkroom default + // no need to pass environment"). `OLD_GUI=1` (any case) is the one door + // back into the legacy four-region tree -- `EDITH_DARKROOM` opted IN to + // the new room; this opts OUT of it, which is why the sense of the read + // below is inverted rather than the flag renamed in place. + let old_gui = std::env::vars() + .find(|(k, _)| k.eq_ignore_ascii_case("OLD_GUI")) + .is_some_and(|(_, v)| v.eq_ignore_ascii_case("1")); + let darkroom = !old_gui; if darkroom { ui::theme::set(ui::theme::PaletteId::Darkroom); } @@ -794,6 +816,10 @@ fn main() { .map_or_else(|| NO_FILE.into(), |arg| file_name(arg).into()); Application::new().run(move |cx: &mut App| { + // Bundled Archivo / Spline Sans Mono, before the first paint -- + // DESIGN §3's two faces, embedded so no build depends on the host + // having them installed (see `ui::type_scale`'s doc comment). + ui::type_scale::register(cx); // 720p: the picture's own size is not known yet -- knowing it is the // twelve seconds this window exists to be up during -- and a window // that resized itself under a hand already dragging it would be worse @@ -871,7 +897,11 @@ fn main() { selected_asset: None, library_tab: LibraryTab::Media, dock_src_active: ui::dock_stance::load(), + dock_filter: String::new(), + dock_filter_edit: false, + dock_sort: ui::dock_stance::DockSort::Recent, waves: HashMap::new(), + thumbs: HashMap::new(), proxies: HashMap::new(), streams: HashMap::new(), bitrates: HashMap::new(), diff --git a/crates/app/src/player/export.rs b/crates/app/src/player/export.rs index 299cb13..ec319c7 100644 --- a/crates/app/src/player/export.rs +++ b/crates/app/src/player/export.rs @@ -89,6 +89,45 @@ impl Player { }) .detach(); } + // The bench's poster frame per file (`Thumb`, DESIGN §5's "real + // thumbnails across video clips"): one representative frame, decoded + // off the render thread like the peaks above through the same + // single-frame door `engine::decode::DecodeSession::open_range` + // already opens for a poster frame -- no second decode path invented. + // Filtered to files with a picture at all: an audio-only source has + // no frame to ask for, so it never enters this map (mirroring `Wave`'s + // own `Silent`, but as an absence rather than a state). + for path in unseen_paths(session.sources(), &self.thumbs) + .into_iter() + .filter(|p| !engine::is_audio(p)) + { + self.thumbs.insert(path.clone(), Thumb::Loading); + let decoded = cx.background_executor().spawn({ + let path = path.clone(); + async move { + let (_, rx, _cancel) = + engine::decode::DecodeSession::open_range(&path, 0, 1).ok()?; + let frame = rx.recv().ok()?; + let buf = image::RgbaImage::from_raw(frame.width, frame.height, frame.bgra)?; + Some(std::sync::Arc::new(RenderImage::new(vec![image::Frame::new(buf)]))) + } + }); + cx.spawn(async move |this, cx| { + let decoded = decoded.await; + this.update(cx, |this, cx| { + this.thumbs.insert( + path, + match decoded { + Some(image) => Thumb::Ready(image), + None => Thumb::Failed, + }, + ); + cx.notify(); + }) + .ok(); + }) + .detach(); + } // Which decoder each file will run on, for the row that says so before // a frame of it plays. Off the render thread like the streams above: a // stream the plugin takes costs one VA-API init (~90 ms) to answer. diff --git a/crates/app/src/player/library.rs b/crates/app/src/player/library.rs index 4cd54d0..eca5388 100644 --- a/crates/app/src/player/library.rs +++ b/crates/app/src/player/library.rs @@ -172,6 +172,7 @@ impl Player { self.speed_open = None; self.close_silence(); self.waves.clear(); + self.thumbs.clear(); self.streams.clear(); self.bitrates.clear(); self.sizes.clear(); @@ -1037,6 +1038,31 @@ impl Player { .detach(); } + /// The dock's "Paste path" verb (MOCK-SPEC "Dock" IMPORT section): reads + /// whatever text sits on the OS clipboard and imports it the same way a + /// drop or the Import button would, if it names a file that exists. + /// `gpui::App::read_from_clipboard` already covers this -- no new + /// dependency for what is otherwise a clipboard read and the existing + /// [`Player::import`] door. + pub(crate) fn paste_file_path(&mut self, cx: &mut Context) { + if self.exporting().is_some() { + return; + } + let Some(text) = cx.read_from_clipboard().and_then(|item| item.text()) else { + self.notify_user("PASTE PATH — nothing on the clipboard".into()); + cx.notify(); + return; + }; + let text = text.trim().trim_matches(['"', '\'']); + let path = std::path::PathBuf::from(text); + if !path.is_file() { + self.notify_user(format!("PASTE PATH — not a file: {text}").into()); + cx.notify(); + return; + } + self.import(&path, cx); + } + /// The `+ S` button and its key: asks the desktop for a file and takes the /// subtitle tracks out of it -- a standalone `.srt`/`.vtt`/`.ass` is one of /// them, a Matroska however many are inside. Only the subtitles: the file diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index 86e67de..d145343 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -245,7 +245,8 @@ impl Render for Player { self.panned = false; } - // DESIGN.md §12 step 2: the stance skeleton behind `EDITH_DARKROOM`. + // DESIGN.md §12 step 2: the stance skeleton, on by default now + // (`OLD_GUI=1` opts back into the tree below). // `.into_any_element()` on both arms is the one thing this branch // costs the legacy tree below -- an `impl IntoElement` return can // only be one concrete type, and the two trees are not the same one. @@ -353,6 +354,33 @@ impl Render for Player { cx.notify(); return; } + // The dock's Sources filter (MOCK-SPEC "Dock" §2): owns the + // keyboard only while it was clicked into, exactly the + // `keys_search` shape above -- a letter typed anywhere else in + // the room still means what the spine says it means. + if this.dock_filter_edit { + if key == "escape" || key == "enter" { + this.dock_filter_edit = false; + } else if key == "backspace" { + this.dock_filter.pop(); + } else if let Some(c) = typed(key) { + this.dock_filter.push(c); + } + cx.notify(); + return; + } + // `↵` adds the picked source at the playhead (MOCK-SPEC "Dock" + // hint paragraph, gesture 2) -- the keyboard door beside the + // legacy "Add at playhead" button's pointer one, live only + // where a row is actually picked so a bare enter elsewhere + // keeps meaning whatever it already means below. + if key == "enter" && this.dock_src_active && this.selected_asset.is_some() && this.exporting().is_none() { + if let Some((path, stream)) = this.selected_asset.clone() { + this.insert_source(&path, stream, None, None, cx); + } + cx.notify(); + return; + } // The export card owns it the same way, and for the same // reason. Escape closes it -- nothing has been written yet, so // there is nothing here to cancel -- and the card's own letters diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 70f1442..0f86704 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -1795,11 +1795,12 @@ fn the_stance_renders_its_six_regions_in_the_documented_order() { ); // The flag has to reach it, or the skeleton is dead code behind a door - // nobody opens. + // nobody opens. Darkroom is the default room now (`OLD_GUI=1` is the + // opt-out) -- `Player::darkroom` is still the field render.rs reads. let render_rs = src_text("render.rs"); assert!( render_rs.contains("if self.darkroom") && render_rs.contains("ui::stance::render("), - "EDITH_DARKROOM never reaches ui::stance::render" + "Player::darkroom never reaches ui::stance::render" ); } diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index 4df47b0..1e20ee7 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -28,7 +28,6 @@ //! answer for. use crate::*; -use crate::ui::widgets::waveform; /// The pinned ruler's own height, above the lane stack. const RULER_H: f32 = 10.; @@ -62,6 +61,26 @@ enum Tier { Sliver, } +/// `MM:SS` for a clip's own readout -- the bench talks in the film's units, +/// not in seconds with a decimal point. +fn mmss(secs: f64) -> String { + let s = secs.max(0.).round() as u64; + format!("{}:{:02}", s / 60, s % 60) +} + +/// A clip's thumbnail, filling its box. `Cover` rather than `Contain`: a clip +/// is a strip of film, so it crops rather than letterboxing inside a lane. +fn cover_image(image: std::sync::Arc) -> impl IntoElement { + canvas( + |_, _, _| (), + move |bounds, _, window, _| { + let fitted = gpui::ObjectFit::Cover.get_bounds(bounds, image.size(0)); + let _ = window.paint_image(fitted, Corners::default(), image, 0, false); + }, + ) + .size_full() +} + fn tier(span: f32) -> Tier { match span { s if s >= 120. => Tier::Full, @@ -103,12 +122,17 @@ fn clip_box( let left = scale.px_at(start); let on = marked((lane, idx), clip.link, picks, pick_links); let t = tier(span); - let label = player.sources().get(clip.source).map(|s| file_name(&s.path)); + let source = player.sources().get(clip.source); + let label = source.map(|s| file_name(&s.path)); let audio = lane.kind == LaneKind::Audio; - let wave = player - .sources() - .get(clip.source) - .and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream))) + let wave = source.and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream))).cloned(); + // hook: §12 step 5 -- per-source film ink attaches here, replacing + // `source_tint` (library_meta.rs's own placeholder wheel, index-keyed and + // already different per source) with the source's own quantized hue. + let ink = source_tint(clip.source); + let thumb = (!audio) + .then(|| source.and_then(|s| player.thumbs.get(&s.path))) + .flatten() .cloned(); let has_trace = t != Tier::Sliver; let has_spine = t != Tier::Sliver; @@ -116,6 +140,21 @@ fn clip_box( let has_chip = t == Tier::Full && !clip.speed.is_normal(); let (in_frame, out_frame) = (f64::from(clip.in_frame) / player.fps, f64::from(clip.out_frame) / player.fps); let speed = clip.speed; + // Right-aligned readout: the trim delta off the source's full length when + // this clip is shorter than the file it was cut from, else the plain + // duration (DESIGN §5). corner-cut: reads only against the *source's* full + // length, not the subject cut's own out/in marks the time band's readout + // means (§12's cut object has no per-edge history at this layer) -- + // ceiling is wiring this to the same cut state once the time band exposes + // it, rather than a second reading of "trim" here. + let full_frames = source.map(|s| player.session.as_ref().map_or(0, |sess| sess.file_frames(&s.path))); + let readout = match full_frames { + Some(full) if full > clip.frames() => { + let delta = f64::from(full - clip.frames()) / player.fps; + format!("−{}", mmss(delta)) + } + _ => format!("{len:.1}s"), + }; div() .id(("bench-clip", lane.ord * 1000 + lane.kind as usize * 100 + idx)) .absolute() @@ -138,7 +177,7 @@ fn clip_box( this.pick((lane, idx), event.modifiers.control, cx); }), ) - // Ink spine: 3px left edge, the placeholder ink until §12 step 5. + // Ink spine: 3px left edge, the source's own ink (hook above). .when(has_spine, |d| { d.child( div() @@ -147,11 +186,12 @@ fn clip_box( .top_0() .h_full() .w(px(3.)) - .bg(rgb(INK2())), + .bg(rgb(ink)), ) }) - // Trace: real waveform for audio, a flat placeholder body for video - // (thumbnails are §12 step 5's, same hook). + // Trace: real waveform for audio, a real decoded thumbnail for video + // (falling back to a flat placeholder body while it loads or if the + // file never yields one). .when(has_trace && audio, |d| { d.children(wave.and_then(|w| match w { Wave::Peaks(peaks) => Some( @@ -161,7 +201,7 @@ fn clip_box( .right_0() .top_0() .bottom_0() - .child(waveform(peaks, in_frame, out_frame)), + .child(waveform_ink(peaks, in_frame, out_frame, ink)), ), _ => None, })) @@ -174,32 +214,50 @@ fn clip_box( .right_0() .top(px(2.)) .bottom(px(2.)) - .bg(rgb(INK4())), + .overflow_hidden() + .bg(rgb(INK4())) + .when_some(thumb, |d, thumb| match thumb { + Thumb::Ready(image) => d.child(cover_image(image)), + _ => d, + }), ) }) - // Name plate: DESIGN §4's plate (canvas-on-panel), mono label. - .when_some(label.filter(|_| has_label), |d, label| { + // Name plate + trim/duration readout: one strip, DESIGN §4's plate + // (canvas-on-panel), sat at the clip's top-left/top-right per the mock + // rather than the name alone hanging below the box. + .when(has_label, |d| { d.child( div() .absolute() .left(px(3.)) .right_0() - .bottom_0() + .top_0() .h(px(13.)) .px(px(3.)) + .flex() + .items_center() + .justify_between() + .gap(px(4.)) .bg(rgba(DARK_SEAM())) - .truncate() - .text_size(px(9.5)) - .text_color(rgb(INK1())) - .child(label), + .when_some(label, |d, label| { + d.child(div().min_w(px(0.)).truncate().text_size(px(9.5)).text_color(rgb(INK1())).child(label)) + }) + .child( + div() + .flex_none() + .text_size(px(9.)) + .text_color(rgb(INK3())) + .child(readout), + ), ) }) - // Speed chip: dropped first in the ladder. + // Speed chip: dropped first in the ladder, tucked in the bottom-right + // corner so it never fights the name/readout strip above. .when(has_chip, |d| { d.child( div() .absolute() - .top_0() + .bottom_0() .right_0() .px(px(3.)) .bg(rgb(DARK_RAISED())) diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index e9124b2..5df31f9 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -1,6 +1,15 @@ //! The dock's own content: the Sources/Clip tab pair and what each shows //! (DESIGN.md §5, §12 step 4). `stance.rs::dock()` owns the panel's frame //! (width, surfaces, border); this module owns what fills it. +//! +//! The Sources tab used to be `Player::library` verbatim -- the legacy +//! panel's pill tabs, Media/Audio/Text row, filled Import button and amber +//! accent, wearing the darkroom surfaces only because its tokens happened to +//! alias into them. The user named that: "this place is not fitting design +//! language. it's same as our original." This module now builds the tab +//! fresh, off MOCK-SPEC.md's "Dock" section -- `library.rs`/`library_meta.rs` +//! still supply the row facts ([`library_rows`], [`source_tint`], +//! [`clip_middle`]...), only the anatomy around them is new. use crate::*; @@ -33,6 +42,30 @@ fn save(src_active: bool) { let _ = std::fs::write(path, if src_active { "Src\n" } else { "Clip\n" }); } +/// The Sources tab's four sort chips (MOCK-SPEC "Dock" §3). `Recent` is the +/// library's own arrival order -- the only order this editor tracks without +/// a fourth field to keep it in. +#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] +pub(crate) enum DockSort { + #[default] + Recent, + Name, + Usage, + Unused, +} + +impl DockSort { + const ALL: [DockSort; 4] = [DockSort::Recent, DockSort::Name, DockSort::Usage, DockSort::Unused]; + fn label(self) -> &'static str { + match self { + DockSort::Recent => "Recent", + DockSort::Name => "Name", + DockSort::Usage => "Usage", + DockSort::Unused => "Unused", + } + } +} + /// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in /// `ink3` beside it, read live off the keymap so it can never drift from the /// key that does the same thing. Hover is one fill step and an ink brighten; @@ -83,39 +116,378 @@ fn ghost_verb( ) } -/// One tab glyph of the Src/Clip pair: a plate (2px radius per §4), `ink1` + -/// `raised` fill when it is the showing tab, `ink2` at rest. -fn dock_tab(id: &'static str, label: &'static str, active: bool, cx: &mut Context) -> impl IntoElement { +/// A row in the IMPORT section: a ghost verb that has no [`ActionId`] of its +/// own to read a chord off. `Add files`/`Paste path` have no keymap binding +/// -- nearly every ctrl+letter in this editor's table is already spoken for +/// (`git grep '", true)'` in `keymap.rs` turns up every letter but a handful), +/// and giving either one a fresh global chord is a keymap-wide decision -- +/// which strokes move, which don't -- outside one dock diff. The verb still +/// works by click; the chord badge is honest about there being none rather +/// than inventing one MOCK-SPEC's `^o`/`^v` never actually bind to. +/// +/// corner-cut: no chord. Ceiling: a keymap diff that clears two ctrl slots +/// (or two bare ones -- neither Import nor "paste a path" has ever had a key +/// in this editor) and threads `ActionId`s for both through `oracle::enable` +/// and `Player::act`, at which point this calls [`ghost_verb`] instead. +fn import_verb( + id: &'static str, + label: &'static str, + hint: &'static str, + on: bool, + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, +) -> impl IntoElement { + div() + .id(id) + .flex_none() + .flex() + .items_center() + .justify_between() + .h(px(CONTROL_H)) + .px(px(8.)) + .rounded(px(3.)) + .text_color(rgb(INK2())) + .tooltip(move |_, cx| cx.new(|_| Tip(hint.into())).into()) + .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) + .when(on, |d| { + d.cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) + .on_click(on_click) + }) + .child(label) + .child(div().flex_none().text_size(px(9.5)).text_color(rgb(INK3())).child("—")) +} + +/// One tab of the Src/Clip pair (MOCK-SPEC "Dock": no pill, no fill, no +/// rounded button -- a 1px `ink1` top rule and `ink1` text mark the showing +/// tab; the resting one is `ink3`). `chord` is decorative, not bound: tab +/// switching has no gesture named in the charter's four, so it is drawn but +/// not wired to a global key, exactly `import_verb`'s reasoning above. +fn dock_tab(id: &'static str, label: &'static str, chord: &'static str, active: bool, cx: &mut Context) -> impl IntoElement { div() .id(id) .flex_1() .flex() .items_center() .justify_center() - .rounded(px(2.)) - .py(px(6.)) + .gap(px(4.)) + .pt(px(6.)) + .pb(px(6.)) + .when(active, |d| d.border_t_1().border_color(rgb(INK1()))) .text_size(px(10.5)) - .text_color(rgb(if active { INK1() } else { INK2() })) - .when(active, |d| d.bg(rgb(DARK_RAISED()))) + .text_color(rgb(if active { INK1() } else { INK3() })) .cursor_pointer() - .hover(|s| s.bg(rgb(DARK_RAISED()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { - this.dock_src_active = label == "Src"; + this.dock_src_active = label == "SOURCES"; save(this.dock_src_active); cx.notify(); })) - .child(label) + .child( + div() + .text_size(px(10.5)) + .text_color(rgb(if active { INK1() } else { INK3() })) + .child(label), + ) + .child(div().text_color(rgb(INK3())).child(chord)) +} + +/// A 9px uppercase Archivo section head, `ink3` (DESIGN §3). +fn section_head(text: impl Into) -> impl IntoElement { + div() + .flex_none() + .text_size(px(9.)) + .text_color(rgb(INK3())) + .child(text.into()) +} + +/// Every lane a source plays on right now, as its own `V1`/`A1` labels +/// (MOCK-SPEC "Dock" §4's usage line), plus how many clips altogether -- +/// [`Player::row_ctx`]'s `placed` count, the same number the library card's +/// Remove refusal reads. +fn usage_line(player: &Player, source_idx: usize, placed: usize) -> String { + if placed == 0 { + return "unused".to_string(); + } + let lanes: Vec = player.session.as_ref().map_or_else(Vec::new, |session| { + session + .lanes() + .into_iter() + .filter(|lane| session.lane_clips(*lane).iter().any(|c| c.source == source_idx)) + .map(Lane::label) + .collect() + }); + format!("{} · {placed} use{}", lanes.join(" "), if placed == 1 { "" } else { "s" }) +} + +/// One source row, two lines (MOCK-SPEC "Dock" §4): an ink dot, the name in +/// mono `ink1` -- readable, complete, ellipsized at the end rather than +/// clipped mid-glyph or faded -- and right-aligned usage; under it, the +/// codec/length/decoder line in mono `ink3`. Drag (gesture 1), `↵` (gesture +/// 2, wired in `render.rs`'s key handler since a row takes no keyboard focus +/// of its own), double-click (gesture 3) and right-click the dot (gesture 4) +/// all live here. +fn source_row(player: &Player, i: usize, row: &Row, placed: usize, picked: bool, cx: &mut Context) -> impl IntoElement { + let usable = row.unusable.is_none(); + let name: SharedString = row.name.clone().into(); + let under: String = match &row.unusable { + Some(why) => why.clone(), + None => join_detail(&row.detail, &timecode(f64::from(row.frames) / player.fps, player.fps)), + }; + let usage = usage_line(player, row.tint, placed); + let (path, stream) = (row.path.clone(), row.stream); + let dragged = (path.clone(), stream); + let dot_path = path.clone(); + let ghost = name.clone(); + div() + .id(("dock-source", i)) + .flex_none() + .flex() + .flex_col() + .gap(px(2.)) + .px(px(8.)) + .py(px(4.)) + .rounded(px(3.)) + .when(!usable, |d| d.opacity(0.5)) + .when(picked, |d| d.bg(rgb(DARK_RAISED()))) + .when(usable, |d| { + d.cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED()))) + .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| { + this.selected_asset = Some((path.clone(), stream)); + // Gesture 3: a second click in the same spot plays the + // source in the screen, the way `library.rs`'s preview + // triangle already does -- `open_preview` is the one + // door either takes. + if event.click_count() >= 2 { + this.open_preview(&path, stream, cx); + } + cx.notify(); + })) + // Gesture 1: the row is a drag source exactly as + // `library.rs`'s row is -- same payload, same ghost tip -- + // and the bench's `AssetDrag` drop target already accepts it + // (`ui/bench_stance.rs`'s bed). The bug the user hit ("can't + // drag media in timeline") was the dock showing the *legacy* + // panel, which the darkroom bench was never wired against; + // this row is the darkroom's own half of that pairing. + .on_drag(AssetDrag(dragged.0, dragged.1), move |_, _, _, cx| { + cx.new(|_| Tip(ghost.clone())) + }) + }) + .child( + div() + .flex() + .items_center() + .gap(px(6.)) + .child( + div() + .id(("dock-source-dot", i)) + .flex_none() + .w(px(8.)) + .h(px(8.)) + .rounded(px(4.)) + .bg(rgb(source_tint(row.tint))) + .when(usable, |d| { + d.on_mouse_down( + MouseButton::Right, + cx.listener(move |this, event: &MouseDownEvent, _, cx| { + // Gesture 4, and DESIGN §2's demotion rule at + // once: re-inking lives nowhere but here. + // The library's own right-click menu is the + // affordance this opens -- DESIGN §12 step 5 + // allows a stub where extraction-by-hue isn't + // built yet, as long as the menu appears; it + // does, over the same file this dot names. + cx.stop_propagation(); + this.selected_asset = Some((dot_path.clone(), stream)); + this.library_menu = Some(LibraryMenu { + path: dot_path.clone(), + stream, + at: event.position, + details: false, + }); + cx.notify(); + }), + ) + }), + ) + .child( + div() + .flex_1() + .min_w(px(0.)) + .truncate() + .text_size(px(10.5)) + .text_color(rgb(INK1())) + .child(name), + ) + .child( + div() + .flex_none() + .text_size(px(9.5)) + .text_color(rgb(INK3())) + .child(usage), + ), + ) + .child( + div() + .pl(px(14.)) + .truncate() + .text_size(px(9.5)) + .text_color(rgb(INK3())) + .child(under), + ) } -/// The Sources tab: [`Player::library`] verbatim -- filter tabs, usage -/// (proxy/preview) chips, Import, drag, Add at playhead -- restyled for free, -/// because its rows already paint through the theme tokens `library.rs` -/// shares with this stance (`BG_PANEL` etc. alias to the Darkroom substrate -/// under `PaletteId::Darkroom`). No ink/re-inking control lives in it (DESIGN -/// §2's demotion rule): `library.rs` never put one on a row to begin with, so -/// there is nothing here to strip. -fn sources_tab(player: &Player, width: f32, cx: &mut Context) -> impl IntoElement { - player.library(width, cx) +/// The Sources tab, built off MOCK-SPEC.md's "Dock" section: count line, +/// filter, sort chips, rows, IMPORT, hint -- none of it the legacy +/// Media/Audio/Text panel `library.rs` draws. That panel's row facts +/// ([`library_rows`]) are still what every row here is built from. +fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { + let sources = player.session.as_ref().map_or(&[][..], PlaybackSession::sources); + let meta = player.session.as_ref().map(PlaybackSession::meta); + 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 _ = meta; + let unused_count = all_rows + .iter() + .filter(|row| player.row_ctx(&row.path, row.stream).placed == 0) + .count(); + let filter = player.dock_filter.to_lowercase(); + let mut rows: Vec<(Row, usize)> = all_rows + .into_iter() + .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(); + 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), + } + let total = rows.len(); + let filter_text: SharedString = player.dock_filter.clone().into(); + div() + .id("dock-sources") + .flex_1() + .min_h(px(0.)) + .flex() + .flex_col() + .gap(px(6.)) + .p(px(8.)) + .overflow_y_scroll() + .child(section_head(format!("SOURCES · {total} · {unused_count} UNUSED"))) + .child( + div() + .id("dock-filter") + .flex_none() + .cursor_text() + .text_size(px(10.)) + .text_color(rgb(if player.dock_filter_edit { INK1() } else { INK3() })) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { + this.dock_filter_edit = true; + cx.notify(); + })) + .child(match player.dock_filter.is_empty() { + true => "⌕ type to filter — name, codec, unused…".to_string(), + false => format!("⌕ {filter_text}"), + }), + ) + .child( + div() + .flex_none() + .flex() + .gap(px(4.)) + .children(DockSort::ALL.map(|sort| { + let on = sort == player.dock_sort; + div() + .id(("dock-sort", sort as usize)) + .flex_none() + .px(px(6.)) + .py(px(2.)) + .rounded(px(3.)) + .text_size(px(9.5)) + .when(on, |d| d.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) + .when(!on, |d| d.text_color(rgb(INK3()))) + .cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED()))) + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + this.dock_sort = sort; + cx.notify(); + })) + .child(sort.label()) + })), + ) + .child( + div() + .id("dock-source-rows") + .flex_1() + .min_h(px(0.)) + .flex() + .flex_col() + .gap(px(2.)) + .overflow_y_scroll() + .when(rows.is_empty(), |d| { + d.child( + div() + .text_size(px(10.5)) + .text_color(rgb(INK3())) + .child(match player.dock_filter.is_empty() { + true => "No sources yet — Add files, or drop one on the window".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 + }), + ) + .child(section_head("IMPORT")) + .child( + div() + .flex_none() + .flex() + .flex_col() + .child(import_verb( + "dock-import-files", + "Add files", + "adds a file to this list — or drop one on the window", + player.exporting().is_none(), + cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)), + )) + .child(import_verb( + "dock-paste-path", + "Paste path", + "imports the file named on the clipboard", + player.exporting().is_none(), + cx.listener(|this, _: &ClickEvent, _, cx| this.paste_file_path(cx)), + )), + ) + .child( + div() + .flex_none() + .text_size(px(9.)) + .text_color(rgb(INK3())) + .child( + "drag a row to a lane · ↵ add at playhead · double-click plays in screen · \ + right-click the dot to re-ink a source (rare — lives out of the way)", + ), + ) } /// The Clip tab: the four verbs DESIGN §5 names, as ghosts, over whichever @@ -219,8 +591,8 @@ fn clip_tab(player: &Player, width: f32, window_h: Pixels, cx: &mut Context) -> impl IntoElement { let src_active = player.dock_src_active; div() @@ -235,14 +607,14 @@ pub(crate) fn render(player: &Player, width: f32, window_h: Pixels, cx: &mut Con .flex_none() .flex() .gap(px(4.)) - .p(px(8.)) + .px(px(8.)) .border_b_1() .border_color(rgb(DARK_HAIRLINE())) - .child(dock_tab("dock-tab-src", "Src", src_active, cx)) - .child(dock_tab("dock-tab-clip", "Clip", !src_active, cx)), + .child(dock_tab("dock-tab-src", "SOURCES", "L", src_active, cx)) + .child(dock_tab("dock-tab-clip", "CLIP", "I", !src_active, cx)), ) .child(match src_active { - true => sources_tab(player, width, cx).into_any_element(), + true => sources_tab(player, cx).into_any_element(), false => clip_tab(player, width, window_h, cx).into_any_element(), }) } diff --git a/crates/app/src/ui/mod.rs b/crates/app/src/ui/mod.rs index 8a22bca..3c824ca 100644 --- a/crates/app/src/ui/mod.rs +++ b/crates/app/src/ui/mod.rs @@ -10,8 +10,11 @@ pub mod inspector; pub mod library; pub mod overlays; pub mod preview; +pub mod spine_stance; pub mod stance; pub mod theme; +pub mod timeband_stance; pub mod timeline; pub mod toolbar; +pub mod type_scale; pub mod widgets; diff --git a/crates/app/src/ui/spine_stance.rs b/crates/app/src/ui/spine_stance.rs new file mode 100644 index 0000000..72dcbc1 --- /dev/null +++ b/crates/app/src/ui/spine_stance.rs @@ -0,0 +1,167 @@ +//! The spine's own content (DESIGN.md §5, MOCK-SPEC.md "Spine"): grouped +//! task-frequency clusters, each row a glyph stacked over its own chord -- +//! not the flat ungrouped list of glyph-beside-chord rows the shipped room +//! drew. `stance.rs::spine()` keeps the panel frame (width, surface, +//! border); this module owns the rows inside it. +//! +//! corner-cut: sizes below are plain `px()` literals matching DESIGN §3's +//! scale (13px glyph, 9.5px chord, 9px head) rather than calls into a +//! `ui::type_scale` API -- that module had not landed in this tree at the +//! time this was written. Ceiling: swap these three constants for its +//! tokens once it lands; nothing else here would change. + +use crate::*; + +const GLYPH_SIZE: f32 = 13.; +const CHORD_SIZE: f32 = 9.5; +const HEAD_SIZE: f32 = 9.; + +/// A group head: 9px uppercase Archivo 700(-weight token, same as every +/// other section head in the stance) in `ink3`, +0.14em tracking (DESIGN +/// §3) -- reused as its own small fn rather than `stance::section_head` +/// because that one is private to its module and carries a different +/// vertical rhythm (a region label, not a spine group head). +fn group_head(label: &str) -> impl IntoElement { + div() + .flex_none() + .pt(px(6.)) + .text_size(px(HEAD_SIZE)) + .text_color(rgb(INK3())) + .child(label.to_uppercase()) +} + +/// One command: glyph over its chord, centred (MOCK-SPEC.md "Spine" -- +/// "Not glyph-beside-chord on one line"). The chord is read live off +/// [`Keymap::display`], never a literal, so a rebind can never leave the +/// spine showing a stroke that no longer fires it. Ghost grammar (DESIGN +/// §4): borderless, hover is one fill step, active is `ink1` + fill, and a +/// refused verb greys with its reason on hover rather than disappearing +/// (DESIGN §8) -- the same oracle door `dock_stance::ghost_verb` opens. +fn glyph( + id: &'static str, + glyph: &'static str, + action: ActionId, + active: bool, + player: &Player, + cx: &mut Context, +) -> impl IntoElement + use<> { + let enabled = player.enable(action, None); + let key = player.keymap.display(action); + let say: SharedString = match enabled.why() { + Some(why) => format!("{key} — {why}"), + None => format!("{key} — {}", action.label()), + } + .into(); + let on = enabled.yes(); + div() + .id(id) + .flex_none() + .flex() + .flex_col() + .items_center() + .gap(px(2.)) + .px(px(4.)) + .py(px(4.)) + .rounded(px(3.)) + .when(active, |d| d.bg(rgb(DARK_RAISED()))) + .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) + .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) + .when(on, |d| { + d.cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED()))) + .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { + this.act(action, window, cx) + })) + }) + .child( + div() + .text_size(px(GLYPH_SIZE)) + .text_color(rgb(if active { INK1() } else { INK2() })) + .child(glyph), + ) + .child( + div() + .text_size(px(CHORD_SIZE)) + .text_color(rgb(INK3())) + .child(key), + ) +} + +/// Two commands side by side in one row -- the opposite-direction pairs +/// (walk cuts, no-aim trim) that share a row in the mock rather than each +/// eating a full row of the spine's own height. +fn pair(left: impl IntoElement, right: impl IntoElement) -> impl IntoElement { + div() + .flex_none() + .flex() + .items_center() + .justify_center() + .gap(px(10.)) + .child(left) + .child(right) +} + +/// The spine's rows, grouped by task frequency (DESIGN §5, §11 check 1): +/// EDIT (split, delete, undo -- every edit), CUT (walk/trim/loop-trim -- +/// every cut), TRACK (add a lane -- once per project, cheapest land at the +/// bottom of the frequent group). `?` stays on `stance::spine`'s own frame, +/// not duplicated here. +/// +/// Gap, named rather than shipped as a dead control: the mock's LEAN row +/// (`⊡` / `\`, "lean/zen mode") has no [`ActionId`] anywhere in +/// `keymap.rs` -- `Fullscreen` is the nearest existing action but it is a +/// different verb (the platform's own fullscreen, bound to `f11`, not a +/// zen/lean UI mode) so reusing it under the mock's glyph would be exactly +/// the fake-control this task's own instructions forbid. Left out; the +/// group and its bottom anchor do not exist here. +pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElement { + div() + .id("spine-stance-rows") + .flex_1() + .min_h(px(0.)) + .w_full() + .flex() + .flex_col() + .items_center() + .gap(px(10.)) + .overflow_y_scroll() + .child(group_head("edit")) + .child(glyph("spine-split", "||", ActionId::Cut, false, player, cx)) + .child(glyph("spine-delete", "⊂⊃", ActionId::Delete, false, player, cx)) + .child(glyph("spine-undo", "↺", ActionId::Undo, false, player, cx)) + .child(group_head("cut")) + .child(pair( + glyph("spine-cut-prev", "‹", ActionId::WalkCutPrev, false, player, cx), + glyph("spine-cut-next", "›", ActionId::WalkCutNext, false, player, cx), + )) + .child(pair( + glyph( + "spine-trim-in", + "±1", + ActionId::TrimIn, + player.loop_trim.is_some(), + player, + cx, + ), + glyph( + "spine-trim-out", + "±1", + ActionId::TrimOut, + player.loop_trim.is_some(), + player, + cx, + ), + )) + .child(glyph( + "spine-loop-trim", + "↻", + ActionId::LoopTrim, + player.loop_trim.is_some(), + player, + cx, + )) + .child(group_head("track")) + .child(glyph("spine-add-video", "+V", ActionId::AddVideoLane, false, player, cx)) + .child(glyph("spine-add-audio", "+A", ActionId::AddAudioLane, false, player, cx)) + .child(div().flex_1()) +} diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 0af9094..00ce863 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -1,6 +1,7 @@ -//! DESIGN.md §5 -- the stance: fixed geography behind `EDITH_DARKROOM`, drawn -//! whole here rather than folded into the legacy four-region tree so the two -//! can be told apart, and swapped, with a single `if` in `render.rs`. +//! DESIGN.md §5 -- the stance: fixed geography, drawn by default now +//! (`OLD_GUI=1` opts back into the legacy four-region tree), whole here +//! rather than folded into that tree so the two can be told apart, and +//! swapped, with a single `if` in `render.rs`. //! //! This step lays out the six regions and nothing else: correct geometry, //! correct surfaces, a section-head label per region. No content, no @@ -10,6 +11,8 @@ use crate::*; use crate::ui::bench_stance; use crate::ui::dock_stance; +use crate::ui::timeband_stance; +use crate::ui::spine_stance; /// Left rail, full height (DESIGN §5). const SPINE_W: f32 = 56.; @@ -60,33 +63,6 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { ) } -/// A ghost command whose stride-10 sibling is the same command at a -/// different scale (DESIGN §4): one glyph, both chords shown beside each -/// other rather than a second glyph -- the cheap fix VIOLATION 1 asked for, -/// reusing the ghost grammar instead of a new widget. -fn ghost_dual(player: &Player, glyph: &str, action: ActionId, stride: ActionId) -> impl IntoElement { - div() - .flex_none() - .flex() - .flex_col() - .items_center() - .gap(px(2.)) - .py(px(6.)) - .rounded(px(3.)) - .text_size(px(13.)) - .text_color(rgb(INK2())) - .child(glyph.to_string()) - .child( - div() - .flex() - .gap(px(4.)) - .text_size(px(9.5)) - .text_color(rgb(INK3())) - .child(player.keymap.display(action)) - .child(player.keymap.display(stride)), - ) -} - /// The keys overlay (DESIGN §9, §12 step 7): every bound command, sectioned /// by [`keymap::Category`] exactly as the legacy actions card files them /// ([`keys_rows`]) -- reusing that registry-driven order is what makes an @@ -163,11 +139,12 @@ fn keys_overlay(player: &Player) -> impl IntoElement { ) } -/// The spine: 56px, left, full height. Every command as ghost glyph + chord, -/// grouped by task frequency (DESIGN §5) -- transport first (every second), -/// then the cut machinery (DESIGN §6, every cut), then the split and the one -/// boxed exception is left to the time band, which is where Export lives. -fn spine(player: &Player) -> impl IntoElement { +/// The spine: 56px, left, full height. Frame only -- grouped rows, task +/// frequency, glyph-over-chord grammar and every click all live in +/// [`crate::ui::spine_stance`] now (MOCK-SPEC.md "Spine"); this fn keeps +/// the panel's own surface and the `?` row, which stays part of the frame +/// since it opens [`keys_overlay`] right here rather than through `act`. +fn spine(player: &Player, cx: &mut Context) -> impl IntoElement { div() .id("stance-spine") .flex_none() @@ -182,15 +159,7 @@ fn spine(player: &Player) -> impl IntoElement { .py(px(8.)) .gap(px(4.)) .child(section_head("spine")) - .child(ghost(player, "▶", ActionId::Play)) - .child(ghost_dual(player, "‹", ActionId::WalkCutPrev, ActionId::WalkCutPrev10)) - .child(ghost_dual(player, "›", ActionId::WalkCutNext, ActionId::WalkCutNext10)) - .child(ghost(player, "{", ActionId::SelectPrev)) - .child(ghost(player, "}", ActionId::SelectNext)) - .child(ghost(player, "[", ActionId::TrimIn)) - .child(ghost(player, "]", ActionId::TrimOut)) - .child(ghost(player, "↻", ActionId::LoopTrim)) - .child(ghost(player, "✂", ActionId::Cut)) + .child(spine_stance::render(player, cx)) .child(ghost(player, "?", ActionId::ShowActions)) } @@ -225,23 +194,13 @@ fn screen(player: &mut Player, position: f64, window: &mut Window, cx: &mut Cont } /// Fixed-height strip under the screen: timecode leads, ghost transport, cut -/// readout, the contact strip, boxed Export at the end (DESIGN §5). -fn time_band(player: &Player) -> impl IntoElement { +/// readout, the contact strip, boxed Export at the end (DESIGN §5, +/// MOCK-SPEC.md "Time band"). Frame only -- every row and the Export chip's +/// click live in [`crate::ui::timeband_stance`] now, the same split +/// `spine_stance`/`bench_stance`/`dock_stance` already make for their +/// regions. +fn time_band(player: &mut Player, cx: &mut Context) -> impl IntoElement { let position = player.active_session().map_or(0., PlaybackSession::now); - let tc = timecode(position, player.active_fps()); - // The odometer (DESIGN §6): the subject cut's own place among its - // lane's, or an empty readout with nothing marked -- a plate that reads - // blank rather than one that lies about a cut zero. - let readout = player - .selected - .anchor() - .and_then(|(lane, idx)| { - player - .session - .as_ref() - .map(|s| format!("{}/{}", idx + 1, s.lane_clips(lane).len())) - }) - .unwrap_or_else(|| "—/—".to_string()); div() .id("stance-time-band") .flex_none() @@ -250,47 +209,7 @@ fn time_band(player: &Player) -> impl IntoElement { .border_t_1() .border_color(rgba(DARK_SEAM())) .flex() - .items_center() - .gap(px(16.)) - .px(px(12.)) - // The most-read element anchors its region (DESIGN §5): the - // timecode leads, 13px hero, 700, colons in `ink3`. - .child( - div() - .text_size(px(13.)) - .text_color(rgb(INK1())) - .child(tc), - ) - .child(ghost(player, if player.transport().is_playing() { "❚❚" } else { "▶" }, ActionId::Play)) - // The cut readout: a plate, mono, the odometer DESIGN §6 asks for. - .child( - div() - .flex_none() - .px(px(8.)) - .py(px(4.)) - .rounded(px(2.)) - .bg(rgb(DARK_CANVAS())) - .text_size(px(10.5)) - .text_color(rgb(INK1())) - .child(readout), - ) - .child(div().flex_1()) - // Boxed Export: the one bordered control on the surface (DESIGN §4). - .child( - div() - .id("stance-export") - .flex_none() - .px(px(10.)) - .py(px(6.)) - .rounded(px(3.)) - .border_1() - .border_color(rgb(DARK_HAIRLINE())) - .bg(rgb(DARK_RAISED())) - .text_size(px(10.5)) - .text_color(rgb(INK1())) - .cursor_pointer() - .child(format!("Export ({})", player.keymap.display(ActionId::Export))), - ) + .child(timeband_stance::render(player, position, cx)) } /// Lanes, under the time band. `canvas` is the bench background too (DESIGN @@ -429,7 +348,8 @@ pub(crate) fn render( window: &mut Window, cx: &mut Context, ) -> impl IntoElement { - let window_h = window.viewport_size().height; + let window_size = window.viewport_size(); + let window_h = window_size.height; let position = player.playhead(player.drawn_duration()); div() .id("stance-room") @@ -475,14 +395,13 @@ pub(crate) fn render( return; } if let Some(action) = this.keymap.lookup(key, ctrl) { - // hook: §12 step 7 -- the export card (and the notice plates - // that would announce an export's progress) has no stance - // surface yet, so it is suppressed here rather than left to - // open a card nothing on screen can draw. `ShowActions` now - // has one ([`keys_overlay`]) so it is no longer on this list. - if action == ActionId::Export { - return; - } + // `ActionId::Export` used to be suppressed here because the + // darkroom drew no export surface for the card to land on + // (DESIGN §12 step 7's own hook). It has one now + // ([`timeband_stance::export_chip`] opens it, `render` + // below mounts [`Player::export_card`]/`export_progress_card` + // exactly where the legacy tree does), so `^e` dispatches + // like every other action. this.act(action, window, cx); } })) @@ -499,7 +418,7 @@ pub(crate) fn render( .size_full() .flex() .bg(rgb(DARK_CANVAS())) - .child(spine(player)) + .child(spine(player, cx)) .child( div() .id("stance-centre") @@ -509,13 +428,20 @@ pub(crate) fn render( .flex() .flex_col() .child(screen(player, position, window, cx)) - .child(time_band(player)) + .child(time_band(player, cx)) .child(bench(player, cx)) .child(ledger(player, position)) .when_some(player.notices.front().cloned(), |el, n| { el.child(notice_plate(n)) }) - .when(player.keys_open, |el| el.child(keys_overlay(player))), + .when(player.keys_open, |el| el.child(keys_overlay(player))) + // The export card and its running-progress sheet, mounted + // over the whole room exactly as the legacy tree mounts them + // (`render.rs`) -- the fix for the shipped "Export does + // nothing" defect: the chip/chord open `export_open`, this is + // what draws it once open. + .children(player.export_card(window_size, cx)) + .children(player.export_progress_card(cx)), ) .child(dock(player, window_h, cx)) } diff --git a/crates/app/src/ui/timeband_stance.rs b/crates/app/src/ui/timeband_stance.rs new file mode 100644 index 0000000..f6d5560 --- /dev/null +++ b/crates/app/src/ui/timeband_stance.rs @@ -0,0 +1,342 @@ +//! The time band's own content (MOCK-SPEC.md "Time band", DESIGN.md §5): +//! hero timecode, ghost transport, cut readout, the contact strip (whole-film +//! minimap) and the boxed Export chip. `stance.rs::time_band()`'s frame draws +//! the strip; this module owns what fills it, the same split +//! `dock_stance.rs`/`bench_stance.rs` already make for their regions. +//! +//! Type note: DESIGN.md §3 says the hero timecode is 13px; the approved mock +//! (MOCK-SPEC.md) reads closer to ~20px. Kept at 13px here -- the binding +//! contract's own number, already what `stance.rs::time_band()` shipped -- +//! rather than silently picking the mock's, and named here per this task's +//! own instruction to say so when the two disagree. + +use crate::*; + +thread_local! { + // corner-cut: every other drag surface in this codebase (the bench + // scrollbar's `scroll_drag`, the volume slider's `volume_dragging`) keeps + // its anchor and its measured bounds as `Player` fields (`main.rs`). That + // file belongs to a concurrent builder this session, so the contact + // strip's own transient gesture state lives here instead, in the same + // `Rc>>` shape `bounds_probe` already takes. Ceiling: + // fold both into `Player` once `main.rs` is free again. + static STRIP_BOUNDS: Rc>> = Rc::new(Cell::new(Bounds::default())); + static PAN_ANCHOR: Cell> = Cell::new(None); +} + +/// A stacked ghost command (DESIGN §4, MOCK-SPEC "Ghost transport"/"spine"): +/// glyph ~13px `ink2` over its chord ~9.5px `ink3`, read live off the keymap +/// so a rebind can never leave the band showing a stroke that no longer +/// fires it -- the same shape `stance::ghost` draws for the spine, kept local +/// here so this module owns its own region end to end. +fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { + div() + .flex_none() + .flex() + .flex_col() + .items_center() + .gap(px(1.)) + .text_size(px(13.)) + .text_color(rgb(INK2())) + .child(glyph.to_string()) + .child( + div() + .text_size(px(9.)) + .text_color(rgb(INK3())) + .child(player.keymap.display(action)), + ) +} + +/// The hero timecode, digits `ink1` and colons `ink3` (DESIGN §3, MOCK-SPEC +/// "Hero timecode"): the one place in the band the string is split apart +/// rather than painted whole, so the colons can read a shade quieter than +/// the numbers either side of them. +fn hero_timecode(tc: &str) -> impl IntoElement { + div() + .flex_none() + .flex() + .text_size(px(13.)) + .children(tc.chars().map(|c| { + let ink = if c == ':' { INK3() } else { INK1() }; + div().text_color(rgb(ink)).child(c.to_string()) + })) +} + +/// A signed `±M:SS` delta, the shape MOCK-SPEC's cut readout writes trim +/// deltas in (`−02:10`, `+01:04`) -- the sign says which way the edge moved +/// since roll armed, [`clock`] says how far. +fn signed_delta(frames: i64, fps: f64) -> String { + let secs = (frames.unsigned_abs() as f32) / (fps as f32).max(1.); + format!("{}{}", if frames < 0 { "−" } else { "+" }, clock(secs)) +} + +/// The cut readout (MOCK-SPEC "Cut readout"): the odometer (`cut 14/37`), +/// the subject cut's own trim deltas against where roll armed it (only real +/// once [`Player::loop_trim`] has a baseline to measure against), and the +/// roll word itself, on or dim. `·` separators in `ink3`, values in `ink2`. +fn cut_readout(player: &Player) -> impl IntoElement { + let sep = || div().text_color(rgb(INK3())).child(" · "); + let val = |s: String| div().text_color(rgb(INK2())).child(s); + let anchor = player.selected.anchor(); + let odometer = anchor + .and_then(|(lane, idx)| { + player + .session + .as_ref() + .map(|s| format!("cut {}/{}", idx + 1, s.lane_clips(lane).len())) + }) + .unwrap_or_else(|| "cut —/—".to_string()); + // The baseline a roll session captured at arm time (`toggle_loop_trim`) + // doubles as the trim deltas' zero point: the same span it loops is the + // span its own edges are measured from. + let deltas = anchor.and_then(|(lane, idx)| { + let (lo, hi) = player.loop_trim?; + let clip = player.session.as_ref()?.lane_clips(lane).get(idx)?; + let fps = player.active_fps(); + Some(( + signed_delta(i64::from(clip.start) - i64::from(lo), fps), + signed_delta(i64::from(clip.end()) - i64::from(hi), fps), + )) + }); + let roll_on = player.loop_trim.is_some(); + div() + .id("stance-cut-readout") + .flex_none() + .flex() + .items_center() + .px(px(8.)) + .py(px(4.)) + .rounded(px(2.)) + .bg(rgb(DARK_CANVAS())) + .text_size(px(10.5)) + .child(val(odometer)) + .when_some(deltas, |el, (in_d, out_d)| { + el.child(sep()) + .child(val(format!("out {out_d}"))) + .child(sep()) + .child(val(format!("in {in_d}"))) + }) + .child(sep()) + .child( + div() + .text_color(rgb(if roll_on { INK1() } else { INK4() })) + .child("roll"), + ) +} + +/// The contact strip (MOCK-SPEC "Contact strip"): the whole-film minimap +/// filling the band's remaining width, with a 1px viewport bracket marking +/// where the bench's own window sits. Click jumps the playhead; drag pans +/// the bench window. +/// +/// hook: the trace itself is splice positions (real clip boundaries, from +/// [`PlaybackSession::lanes`]/`lane_clips` -- data the app already has), not +/// a motion or audio trace -- that needs a per-frame decode of the whole +/// film this task did not budget for. What would make it real: a cached +/// low-res luma/RMS pass over each source at import, sampled here instead of +/// clip boundaries. +fn contact_strip(player: &Player, cx: &mut Context) -> impl IntoElement { + let duration = player.drawn_duration(); + let view = player.view(); + let (left_frac, width_frac) = if duration > 0. { + ( + (view.scale.start / duration).clamp(0., 1.) as f32, + (view.span() / duration).clamp(0., 1.) as f32, + ) + } else { + (0., 1.) + }; + let fps = player.active_fps(); + let ticks: Vec = player + .session + .as_ref() + .map(|s| { + s.lanes() + .into_iter() + .filter(|l| l.kind == LaneKind::Video) + .flat_map(|l| s.lane_clips(l).iter().map(Clip::end).collect::>()) + .collect::>() + }) + .unwrap_or_default() + .into_iter() + .filter(|_| duration > 0.) + .map(|f| ((f64::from(f) / fps) / duration).clamp(0., 1.) as f32) + .collect(); + let strip_bounds = STRIP_BOUNDS.with(Rc::clone); + div() + .id("stance-contact-strip") + .relative() + .flex_1() + .min_w(px(0.)) + .h(px(28.)) + .cursor_pointer() + .tooltip(|_, cx| { + cx.new(|_| Tip("Contact strip — click jumps, drag pans the bench".into())) + .into() + }) + .on_mouse_down( + MouseButton::Left, + cx.listener({ + let bounds = strip_bounds.clone(); + move |this, event: &MouseDownEvent, _, cx| { + let duration = this.drawn_duration(); + if duration > 0. { + let frac = frac_along(event.position.x, bounds.get()); + this.seek(f64::from(frac) * duration, cx); + } + PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x)))); + } + }), + ) + .on_mouse_move(cx.listener(move |this, event: &MouseMoveEvent, _, cx| { + let Some(last_x) = PAN_ANCHOR.with(Cell::get) else { + return; + }; + match event.pressed_button { + Some(MouseButton::Left) => { + let bounds = STRIP_BOUNDS.with(Rc::clone).get(); + let w = f32::from(bounds.size.width).max(1.); + let dx = f32::from(event.position.x) - last_x; + let duration = this.drawn_duration(); + if duration > 0. { + let delta = f64::from(dx / w) * duration; + let span = this.view().span(); + let max_start = (duration - span).max(0.); + this.scale.start = (this.scale.start + delta).clamp(0., max_start); + } + PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x)))); + cx.notify(); + } + _ => PAN_ANCHOR.with(|a| a.set(None)), + } + })) + .on_mouse_up( + MouseButton::Left, + cx.listener(|_, _, _, _| PAN_ANCHOR.with(|a| a.set(None))), + ) + .child(bounds_probe(strip_bounds)) + // The baseline trace (see the `hook:` above). + .child( + div() + .absolute() + .left_0() + .right_0() + .top(px(13.)) + .h(px(2.)) + .bg(rgb(DARK_HAIRLINE())), + ) + .children(ticks.into_iter().map(|frac| { + div() + .absolute() + .left(relative(frac)) + .top(px(9.)) + .w(px(1.)) + .h(px(10.)) + .bg(rgb(LAMP_WHITE())) + })) + // The viewport bracket: the bench window's own span, with grip + // notches at each edge (MOCK-SPEC: "1px viewport bracket (with grip + // notches)"). + .child( + div() + .absolute() + .left(relative(left_frac)) + .top_0() + .h_full() + .w(relative(width_frac.max(0.01))) + .border_1() + .border_color(rgb(INK1())) + .child( + div() + .absolute() + .left_0() + .top_0() + .w(px(2.)) + .h(px(6.)) + .bg(rgb(INK1())), + ) + .child( + div() + .absolute() + .right_0() + .bottom_0() + .w(px(2.)) + .h(px(6.)) + .bg(rgb(INK1())), + ), + ) +} + +/// The Export chip (MOCK-SPEC "Export chip", DESIGN §4): the room's single +/// bordered control. Opens the export card exactly the way the legacy room's +/// own Export button does ([`Player::open_export`], `ui/toolbar.rs`'s +/// `action_control` click) -- this is the fix for the shipped defect: the +/// darkroom used to suppress `ActionId::Export` outright because it drew no +/// surface for the card to land on; `stance.rs::render` now dispatches it +/// like every other action, and the card itself +/// ([`Player::export_card`]/`export_progress_card`) is mounted over the room +/// by [`super::stance::render`] the same way the keys overlay is. +fn export_chip(player: &Player, cx: &mut Context) -> impl IntoElement { + let exporting = player.exporting().is_some(); + div() + .id("stance-export") + .flex_none() + .px(px(10.)) + .py(px(6.)) + .rounded(px(3.)) + .border_1() + .border_color(rgb(DARK_HAIRLINE())) + .bg(rgb(DARK_RAISED())) + .text_size(px(10.5)) + .text_color(rgb(INK1())) + .cursor_pointer() + .hover(|s| s.bg(rgb(DARK_PANEL()))) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { + if this.exporting().is_some() { + this.cancel_export(); + } else { + this.open_export(cx); + } + cx.notify(); + })) + .child(format!( + "{} {}", + if exporting { "Exporting" } else { "Export" }, + player.keymap.display(ActionId::Export) + )) +} + +/// The whole band, left to right per MOCK-SPEC: hero timecode, ghost +/// transport, cut readout, the contact strip filling the rest, the Export +/// chip at the end. +pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context) -> impl IntoElement { + let tc = timecode(position, player.active_fps()); + div() + .id("stance-time-band") + .flex_none() + .h_full() + .flex() + .items_center() + .gap(px(16.)) + .px(px(12.)) + // The most-read element anchors its region (DESIGN §5): the + // timecode leads. + .child(hero_timecode(&tc)) + .child( + div() + .flex_none() + .flex() + .items_center() + .gap(px(10.)) + .child(ghost(player, "◀◀", ActionId::JumpBack)) + .child(ghost( + player, + if player.transport().is_playing() { "❚❚" } else { "▶" }, + ActionId::Play, + )) + .child(ghost(player, "▶▶", ActionId::JumpForward)), + ) + .child(cut_readout(player)) + .child(contact_strip(player, cx)) + .child(export_chip(player, cx)) +} diff --git a/crates/app/src/ui/type_scale.rs b/crates/app/src/ui/type_scale.rs new file mode 100644 index 0000000..8310b50 --- /dev/null +++ b/crates/app/src/ui/type_scale.rs @@ -0,0 +1,221 @@ +//! DESIGN.md §3 -- the room's two faces, bundled so nothing depends on the +//! machine happening to have them (`fc-list` on the dev box finds neither). +//! +//! Archivo is the room's voice (labels, verbs, section heads); Spline Sans +//! Mono is everything the film says (timecode, chords, readouts, metadata, +//! names, the ledger). Every call site asks this module for a style by +//! *role*, the same discipline `ui::theme` holds for colour -- no element +//! spells a family string or a raw weight number itself. +//! +//! The two TTFs in `assets/fonts/` are Google Fonts variable masters (one +//! file, a `wght` axis). gpui's Linux text backend is `cosmic-text` 0.14, +//! which carries no variable-font axis support (grepped: no `fvar`/variation +//! handling anywhere in its source) -- so embedding the variable master +//! directly would register exactly one face per family and render every +//! requested weight as that face's single baked-in weight. The five +//! `*-Regular.ttf` / `*-Medium.ttf` / `*-Bold.ttf` files beside the masters +//! are static instances pinned with `fonttools varLib.instancer` (already on +//! this box; no new Rust dependency), one per weight DESIGN §3 actually +//! names. They share the master's OFL licence (an instanced subset is a +//! derivative work, which OFL permits) and its typographic family name, so +//! `font_kit::matching::find_best_match` picks the right static face for a +//! requested weight the same way it would pick among any other family's +//! separately-shipped weight files. + +// The four region rebuilds (dock/bench/time band/spine) consume this module's +// `label`/`mono`/`head` in their own concurrent steps; until they land, this +// crate's only caller of the public API is `main.rs`'s `register`. +#![allow(dead_code)] + +use gpui::{App, Font, FontFeatures, FontWeight, Pixels, SharedString, font, px}; +use std::borrow::Cow; + +/// Archivo: labels, verbs, section heads. +pub const ARCHIVO: &str = "Archivo"; +/// Spline Sans Mono: timecode, chords, readouts, metadata, names, the ledger. +pub const SPLINE_SANS_MONO: &str = "Spline Sans Mono"; + +/// DESIGN §3's scale, named so a call site reads the role, not a number. +pub const HERO_TIMECODE_PX: f32 = 13.; +pub const LABEL_ROW_PX: f32 = 10.5; +pub const CHORD_METADATA_MAX_PX: f32 = 10.; +pub const CHORD_METADATA_MIN_PX: f32 = 9.5; +pub const SECTION_HEAD_PX: f32 = 9.; +/// The floor DESIGN §3 sets: nothing in the room reads smaller than this. +pub const FLOOR_PX: f32 = 8.; + +/// A family, weight and size together -- what a call site needs to paint +/// text with `.font(style.font).text_size(style.size)`, and nothing it has +/// to spell out by hand. +#[derive(Clone, Debug)] +pub struct TypeStyle { + pub font: Font, + pub size: Pixels, +} + +/// Tabular figures, wherever digits align (odometers, timecodes, readouts). +/// `tnum` is an arbitrary OpenType feature tag to gpui's `FontFeatures`, so +/// this is the one place that spells it -- every mono call site gets it for +/// free rather than asking for it by hand. +fn tabular_figures() -> FontFeatures { + FontFeatures(std::sync::Arc::new(vec![("tnum".to_string(), 1)])) +} + +fn family_font(family: impl Into, weight: FontWeight, tabular: bool) -> Font { + let mut f = font(family).with_weight(weight); + if tabular { + f.features = tabular_figures(); + } + f +} + +trait WithWeight { + fn with_weight(self, weight: FontWeight) -> Self; +} +impl WithWeight for Font { + fn with_weight(mut self, weight: FontWeight) -> Self { + self.weight = weight; + self + } +} + +/// Archivo, at the given size and weight -- labels, verbs, section heads. +/// No italics anywhere in the room (DESIGN §3), so this never offers one. +pub fn label(size_px: f32, weight: FontWeight) -> TypeStyle { + debug_assert!(size_px >= FLOOR_PX, "below DESIGN §3's 8px floor: {size_px}"); + TypeStyle { + font: family_font(ARCHIVO, weight, false), + size: px(size_px), + } +} + +/// Spline Sans Mono, at the given size and weight, tabular figures on -- +/// everything the film says. +pub fn mono(size_px: f32, weight: FontWeight) -> TypeStyle { + debug_assert!(size_px >= FLOOR_PX, "below DESIGN §3's 8px floor: {size_px}"); + TypeStyle { + font: family_font(SPLINE_SANS_MONO, weight, true), + size: px(size_px), + } +} + +/// A 9px Archivo 700 section head, `ink3`. The caller still has to uppercase +/// its own text (`.to_uppercase()`) and paint `ink3` -- this module only +/// owns type, not colour, and stays out of `ui::theme`'s door. +/// +/// The +0.14em tracking DESIGN §3 asks for has no home: gpui 0.2.2 carries +/// no letter-spacing API at all (grepped `styled.rs`, `style.rs`, +/// `text_system.rs` -- no `letter_spacing` symbol anywhere in the crate), so +/// section heads render at zero tracking until gpui gains one or a caller +/// hand-kerns with inserted thin spaces (not done here: that would change +/// the text content, not just its style). +pub fn head() -> TypeStyle { + label(SECTION_HEAD_PX, FontWeight::BOLD) +} + +/// One face's worth of TTFs to embed, `(bytes, name)` for the doc comment +/// above `register` to explain if a load ever fails. +const EMBEDDED: &[(&[u8], &str)] = &[ + ( + include_bytes!("../../../../assets/fonts/Archivo-Regular.ttf"), + "Archivo-Regular.ttf", + ), + ( + include_bytes!("../../../../assets/fonts/Archivo-Medium.ttf"), + "Archivo-Medium.ttf", + ), + ( + include_bytes!("../../../../assets/fonts/Archivo-Bold.ttf"), + "Archivo-Bold.ttf", + ), + ( + include_bytes!("../../../../assets/fonts/SplineSansMono-Medium.ttf"), + "SplineSansMono-Medium.ttf", + ), + ( + include_bytes!("../../../../assets/fonts/SplineSansMono-Bold.ttf"), + "SplineSansMono-Bold.ttf", + ), +]; + +/// Registers both faces with gpui's text system, once, before the first +/// window opens. Bundled bytes (`include_bytes!`) rather than a runtime +/// read of `assets/` -- the binary carries its own type, full stop, so a +/// build copied off this machine still renders Archivo and Spline Sans Mono +/// with nothing installed system-side. +/// +/// A registration failure (malformed font data) is a build-time bug, not a +/// runtime one -- these bytes are fixed at compile time -- so it panics +/// rather than falling silently back to a system face DESIGN §3 forbids. +pub fn register(cx: &App) { + let fonts: Vec> = + EMBEDDED.iter().map(|(bytes, _)| Cow::Borrowed(*bytes)).collect(); + cx.text_system() + .add_fonts(fonts) + .expect("bundled Archivo / Spline Sans Mono TTFs failed to register"); +} + +#[cfg(test)] +mod tests { + use super::*; + use gpui::FontStyle; + + /// The scale never drifts below DESIGN §3's floor, and role sizes match + /// the numbers §3 names -- a call site changing `13.` to `12.` for the + /// hero timecode is the design contract silently moving. + #[test] + fn the_scale_matches_design_3() { + assert_eq!(HERO_TIMECODE_PX, 13.); + assert_eq!(LABEL_ROW_PX, 10.5); + assert!((9.5..=10.).contains(&CHORD_METADATA_MIN_PX)); + assert_eq!(SECTION_HEAD_PX, 9.); + assert_eq!(FLOOR_PX, 8.); + for size in [ + HERO_TIMECODE_PX, + LABEL_ROW_PX, + CHORD_METADATA_MAX_PX, + CHORD_METADATA_MIN_PX, + SECTION_HEAD_PX, + ] { + assert!(size >= FLOOR_PX, "{size} sits below the floor"); + } + } + + /// Mono asks for tabular figures; Archivo never does (it carries no + /// digit odometers) -- and neither ever asks for italic, which DESIGN + /// §3 bans outright. + #[test] + fn mono_is_tabular_archivo_is_not_and_neither_is_ever_italic() { + let m = mono(LABEL_ROW_PX, FontWeight::MEDIUM); + assert_eq!(m.font.family.as_ref(), SPLINE_SANS_MONO); + assert_eq!(m.font.features.tag_value_list(), &[("tnum".to_string(), 1)]); + assert_eq!(m.font.style, FontStyle::Normal); + + let l = label(LABEL_ROW_PX, FontWeight::MEDIUM); + assert_eq!(l.font.family.as_ref(), ARCHIVO); + assert!(l.font.features.tag_value_list().is_empty()); + assert_eq!(l.font.style, FontStyle::Normal); + } + + /// `head()` is exactly what DESIGN §3 names for section heads: Archivo, + /// 700, 9px. + #[test] + fn head_is_archivo_bold_9px() { + let h = head(); + assert_eq!(h.font.family.as_ref(), ARCHIVO); + assert_eq!(h.font.weight, FontWeight::BOLD); + assert_eq!(h.size, px(SECTION_HEAD_PX)); + } + + /// The five embedded faces are exactly the static weight instances the + /// module doc explains the need for -- a fifth or sixth file added here + /// without also landing in `assets/fonts/` is a build break, not a + /// silent gap. + #[test] + fn five_static_weights_are_embedded() { + assert_eq!(EMBEDDED.len(), 5); + for (bytes, name) in EMBEDDED { + assert!(!bytes.is_empty(), "{name} embedded empty"); + } + } +} diff --git a/crates/app/src/ui/widgets.rs b/crates/app/src/ui/widgets.rs index dd4e0b8..72caa10 100644 --- a/crates/app/src/ui/widgets.rs +++ b/crates/app/src/ui/widgets.rs @@ -6,6 +6,14 @@ use crate::*; /// is given. Peaks are the source's whole envelope; `from`/`to` are the source /// seconds this clip plays, so a cut clip shows its own stretch of the file. pub(crate) fn waveform(peaks: Arc>, from: f64, to: f64) -> impl IntoElement { + waveform_ink(peaks, from, to, FG_SECONDARY()) +} + +/// As [`waveform`], but in a caller-picked ink rather than the fixed +/// secondary foreground -- the darkroom bench's own audio clips draw their +/// envelope in the source's ink (DESIGN §5), which the legacy timeline never +/// needed a colour for. +pub(crate) fn waveform_ink(peaks: Arc>, from: f64, to: f64, ink: u32) -> impl IntoElement { canvas( |_, _, _| (), move |bounds, _, window, _| { @@ -28,7 +36,7 @@ pub(crate) fn waveform(peaks: Arc>, from: f64, to: f64) -> impl let mut path = PathBuilder::fill(); path.add_polygon(&points, true); if let Ok(path) = path.build() { - window.paint_path(path, rgb(FG_SECONDARY())); + window.paint_path(path, rgb(ink)); } }, )