forge
Explore
Log in

Don't you dare go Hollow

The room becomes the one in the mock

Browse files at this commit

622904e9655c1a4e34332a1fc656dbd1c5ab0856Ahmet Kaan GümüşParent: 43f5ab4
  • feat
    • the room becomes the one in the mock
Show full message
✨ feat(ui): the room becomes the one in the mock

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.

14 changed files +1400 -164

crates/app/src/importing.rsmodified+15 -0
@@ -62,6 +62,21 @@ pub(crate) enum Wave {
62 Peaks(Arc<Vec<(f32, f32)>>),62 Peaks(Arc<Vec<(f32, f32)>>),
63 }63 }
64 64
65+/// The bench's own version of [`Wave`] for the picture instead of the sound: one
66+/// representative decoded frame per file, kept and reused across every clip cut
67+/// from it (DESIGN.md §5's "real thumbnails across video clips", §12 step 5 --
68+/// this is the frame, not the ink; the ink comes from [`crate::source_tint`]
69+/// until real extraction lands). Audio-only files never enter this map (see
70+/// `cache_media`'s filter), so `Silent` has no counterpart here.
71+#[derive(Clone)]
72+pub(crate) enum Thumb {
73+ /// Asked for; the decode is running on a background thread.
74+ Loading,
75+ /// The decode failed or the file turned out to carry no picture after all.
76+ Failed,
77+ Ready(Arc<gpui::RenderImage>),
78+}
79+
65 /// What a source's stand-in is up to ([`engine::proxy`]). Kept per file and80 /// What a source's stand-in is up to ([`engine::proxy`]). Kept per file and
66 /// filled like every other library fact -- presence means "asked", so a repaint81 /// filled like every other library fact -- presence means "asked", so a repaint
67 /// mid-encode cannot start a second one.82 /// mid-encode cannot start a second one.
crates/app/src/main.rsmodified+31 -1
@@ -223,11 +223,24 @@ struct Player {
223 /// (`ui::dock_stance::load`/`save`) so "a room reopens exactly as left"223 /// (`ui::dock_stance::load`/`save`) so "a room reopens exactly as left"
224 /// survives a quit and relaunch, not just this window.224 /// survives a quit and relaunch, not just this window.
225 pub(crate) dock_src_active: bool,225 pub(crate) dock_src_active: bool,
226+ /// The Sources tab's own filter text (darkroom dock, MOCK-SPEC "Dock" §2)
227+ /// and whether it is the thing typed strokes go to right now -- the same
228+ /// capture-flag shape `keys_search`/`keys_open` already use, so a letter
229+ /// filters the list instead of firing a spine action while the box is
230+ /// focused, and does nothing to the keymap once it is not.
231+ pub(crate) dock_filter: String,
232+ pub(crate) dock_filter_edit: bool,
233+ /// Which of the four sort chips is showing (MOCK-SPEC "Dock" §3).
234+ pub(crate) dock_sort: ui::dock_stance::DockSort,
226 /// What is known about each source's audio, taken once and kept. Keyed on235 /// What is known about each source's audio, taken once and kept. Keyed on
227 /// the path *and stream* -- two streams of one file are two envelopes -- and236 /// the path *and stream* -- two streams of one file are two envelopes -- and
228 /// the key is inserted the moment the decode is *started*: presence means237 /// the key is inserted the moment the decode is *started*: presence means
229 /// "asked", so a repaint mid-decode cannot ask again.238 /// "asked", so a repaint mid-decode cannot ask again.
230 waves: HashMap<(PathBuf, usize), Wave>,239 waves: HashMap<(PathBuf, usize), Wave>,
240+ /// The bench's poster frame per file ([`Thumb`]), filled like `waves` --
241+ /// presence means "asked" -- one per file rather than one per clip, since
242+ /// every clip cut from a file shares its picture.
243+ thumbs: HashMap<PathBuf, Thumb>,
231 /// What each source's stand-in is up to ([`engine::proxy`]), filled like244 /// What each source's stand-in is up to ([`engine::proxy`]), filled like
232 /// `waves`: presence means "asked", so the encode is started once per file245 /// `waves`: presence means "asked", so the encode is started once per file
233 /// however many times the library is drawn. The switch that decides whether246 /// however many times the library is drawn. The switch that decides whether
@@ -765,7 +778,16 @@ fn main() {
765 // DESIGN.md §1: "the room is the film's" -- darkroom mode owns the778 // DESIGN.md §1: "the room is the film's" -- darkroom mode owns the
766 // palette outright, so the saved pick above is overridden the moment the779 // palette outright, so the saved pick above is overridden the moment the
767 // flag is read, once, before the first paint.780 // flag is read, once, before the first paint.
768- let darkroom = std::env::var("EDITH_DARKROOM").is_ok();781+ //
782+ // Darkroom is the default room now (user order: "make darkroom default
783+ // no need to pass environment"). `OLD_GUI=1` (any case) is the one door
784+ // back into the legacy four-region tree -- `EDITH_DARKROOM` opted IN to
785+ // the new room; this opts OUT of it, which is why the sense of the read
786+ // below is inverted rather than the flag renamed in place.
787+ let old_gui = std::env::vars()
788+ .find(|(k, _)| k.eq_ignore_ascii_case("OLD_GUI"))
789+ .is_some_and(|(_, v)| v.eq_ignore_ascii_case("1"));
790+ let darkroom = !old_gui;
769 if darkroom {791 if darkroom {
770 ui::theme::set(ui::theme::PaletteId::Darkroom);792 ui::theme::set(ui::theme::PaletteId::Darkroom);
771 }793 }
@@ -794,6 +816,10 @@ fn main() {
794 .map_or_else(|| NO_FILE.into(), |arg| file_name(arg).into());816 .map_or_else(|| NO_FILE.into(), |arg| file_name(arg).into());
795 817
796 Application::new().run(move |cx: &mut App| {818 Application::new().run(move |cx: &mut App| {
819+ // Bundled Archivo / Spline Sans Mono, before the first paint --
820+ // DESIGN §3's two faces, embedded so no build depends on the host
821+ // having them installed (see `ui::type_scale`'s doc comment).
822+ ui::type_scale::register(cx);
797 // 720p: the picture's own size is not known yet -- knowing it is the823 // 720p: the picture's own size is not known yet -- knowing it is the
798 // twelve seconds this window exists to be up during -- and a window824 // twelve seconds this window exists to be up during -- and a window
799 // that resized itself under a hand already dragging it would be worse825 // that resized itself under a hand already dragging it would be worse
@@ -871,7 +897,11 @@ fn main() {
871 selected_asset: None,897 selected_asset: None,
872 library_tab: LibraryTab::Media,898 library_tab: LibraryTab::Media,
873 dock_src_active: ui::dock_stance::load(),899 dock_src_active: ui::dock_stance::load(),
900+ dock_filter: String::new(),
901+ dock_filter_edit: false,
902+ dock_sort: ui::dock_stance::DockSort::Recent,
874 waves: HashMap::new(),903 waves: HashMap::new(),
904+ thumbs: HashMap::new(),
875 proxies: HashMap::new(),905 proxies: HashMap::new(),
876 streams: HashMap::new(),906 streams: HashMap::new(),
877 bitrates: HashMap::new(),907 bitrates: HashMap::new(),
crates/app/src/player/export.rsmodified+39 -0
@@ -89,6 +89,45 @@ impl Player {
89 })89 })
90 .detach();90 .detach();
91 }91 }
92+ // The bench's poster frame per file (`Thumb`, DESIGN §5's "real
93+ // thumbnails across video clips"): one representative frame, decoded
94+ // off the render thread like the peaks above through the same
95+ // single-frame door `engine::decode::DecodeSession::open_range`
96+ // already opens for a poster frame -- no second decode path invented.
97+ // Filtered to files with a picture at all: an audio-only source has
98+ // no frame to ask for, so it never enters this map (mirroring `Wave`'s
99+ // own `Silent`, but as an absence rather than a state).
100+ for path in unseen_paths(session.sources(), &self.thumbs)
101+ .into_iter()
102+ .filter(|p| !engine::is_audio(p))
103+ {
104+ self.thumbs.insert(path.clone(), Thumb::Loading);
105+ let decoded = cx.background_executor().spawn({
106+ let path = path.clone();
107+ async move {
108+ let (_, rx, _cancel) =
109+ engine::decode::DecodeSession::open_range(&path, 0, 1).ok()?;
110+ let frame = rx.recv().ok()?;
111+ let buf = image::RgbaImage::from_raw(frame.width, frame.height, frame.bgra)?;
112+ Some(std::sync::Arc::new(RenderImage::new(vec![image::Frame::new(buf)])))
113+ }
114+ });
115+ cx.spawn(async move |this, cx| {
116+ let decoded = decoded.await;
117+ this.update(cx, |this, cx| {
118+ this.thumbs.insert(
119+ path,
120+ match decoded {
121+ Some(image) => Thumb::Ready(image),
122+ None => Thumb::Failed,
123+ },
124+ );
125+ cx.notify();
126+ })
127+ .ok();
128+ })
129+ .detach();
130+ }
92 // Which decoder each file will run on, for the row that says so before131 // Which decoder each file will run on, for the row that says so before
93 // a frame of it plays. Off the render thread like the streams above: a132 // a frame of it plays. Off the render thread like the streams above: a
94 // stream the plugin takes costs one VA-API init (~90 ms) to answer.133 // stream the plugin takes costs one VA-API init (~90 ms) to answer.
crates/app/src/player/library.rsmodified+26 -0
@@ -172,6 +172,7 @@ impl Player {
172 self.speed_open = None;172 self.speed_open = None;
173 self.close_silence();173 self.close_silence();
174 self.waves.clear();174 self.waves.clear();
175+ self.thumbs.clear();
175 self.streams.clear();176 self.streams.clear();
176 self.bitrates.clear();177 self.bitrates.clear();
177 self.sizes.clear();178 self.sizes.clear();
@@ -1037,6 +1038,31 @@ impl Player {
1037 .detach();1038 .detach();
1038 }1039 }
1039 1040
1041+ /// The dock's "Paste path" verb (MOCK-SPEC "Dock" IMPORT section): reads
1042+ /// whatever text sits on the OS clipboard and imports it the same way a
1043+ /// drop or the Import button would, if it names a file that exists.
1044+ /// `gpui::App::read_from_clipboard` already covers this -- no new
1045+ /// dependency for what is otherwise a clipboard read and the existing
1046+ /// [`Player::import`] door.
1047+ pub(crate) fn paste_file_path(&mut self, cx: &mut Context<Self>) {
1048+ if self.exporting().is_some() {
1049+ return;
1050+ }
1051+ let Some(text) = cx.read_from_clipboard().and_then(|item| item.text()) else {
1052+ self.notify_user("PASTE PATH — nothing on the clipboard".into());
1053+ cx.notify();
1054+ return;
1055+ };
1056+ let text = text.trim().trim_matches(['"', '\'']);
1057+ let path = std::path::PathBuf::from(text);
1058+ if !path.is_file() {
1059+ self.notify_user(format!("PASTE PATH — not a file: {text}").into());
1060+ cx.notify();
1061+ return;
1062+ }
1063+ self.import(&path, cx);
1064+ }
1065+
1040 /// The `+ S` button and its key: asks the desktop for a file and takes the1066 /// The `+ S` button and its key: asks the desktop for a file and takes the
1041 /// subtitle tracks out of it -- a standalone `.srt`/`.vtt`/`.ass` is one of1067 /// subtitle tracks out of it -- a standalone `.srt`/`.vtt`/`.ass` is one of
1042 /// them, a Matroska however many are inside. Only the subtitles: the file1068 /// them, a Matroska however many are inside. Only the subtitles: the file
crates/app/src/render.rsmodified+29 -1
@@ -245,7 +245,8 @@ impl Render for Player {
245 self.panned = false;245 self.panned = false;
246 }246 }
247 247
248- // DESIGN.md §12 step 2: the stance skeleton behind `EDITH_DARKROOM`.248+ // DESIGN.md §12 step 2: the stance skeleton, on by default now
249+ // (`OLD_GUI=1` opts back into the tree below).
249 // `.into_any_element()` on both arms is the one thing this branch250 // `.into_any_element()` on both arms is the one thing this branch
250 // costs the legacy tree below -- an `impl IntoElement` return can251 // costs the legacy tree below -- an `impl IntoElement` return can
251 // only be one concrete type, and the two trees are not the same one.252 // only be one concrete type, and the two trees are not the same one.
@@ -353,6 +354,33 @@ impl Render for Player {
353 cx.notify();354 cx.notify();
354 return;355 return;
355 }356 }
357+ // The dock's Sources filter (MOCK-SPEC "Dock" §2): owns the
358+ // keyboard only while it was clicked into, exactly the
359+ // `keys_search` shape above -- a letter typed anywhere else in
360+ // the room still means what the spine says it means.
361+ if this.dock_filter_edit {
362+ if key == "escape" || key == "enter" {
363+ this.dock_filter_edit = false;
364+ } else if key == "backspace" {
365+ this.dock_filter.pop();
366+ } else if let Some(c) = typed(key) {
367+ this.dock_filter.push(c);
368+ }
369+ cx.notify();
370+ return;
371+ }
372+ // `↵` adds the picked source at the playhead (MOCK-SPEC "Dock"
373+ // hint paragraph, gesture 2) -- the keyboard door beside the
374+ // legacy "Add at playhead" button's pointer one, live only
375+ // where a row is actually picked so a bare enter elsewhere
376+ // keeps meaning whatever it already means below.
377+ if key == "enter" && this.dock_src_active && this.selected_asset.is_some() && this.exporting().is_none() {
378+ if let Some((path, stream)) = this.selected_asset.clone() {
379+ this.insert_source(&path, stream, None, None, cx);
380+ }
381+ cx.notify();
382+ return;
383+ }
356 // The export card owns it the same way, and for the same384 // The export card owns it the same way, and for the same
357 // reason. Escape closes it -- nothing has been written yet, so385 // reason. Escape closes it -- nothing has been written yet, so
358 // there is nothing here to cancel -- and the card's own letters386 // there is nothing here to cancel -- and the card's own letters
crates/app/src/tests/layout.rsmodified+3 -2
@@ -1795,11 +1795,12 @@ fn the_stance_renders_its_six_regions_in_the_documented_order() {
1795 );1795 );
1796 1796
1797 // The flag has to reach it, or the skeleton is dead code behind a door1797 // The flag has to reach it, or the skeleton is dead code behind a door
1798- // nobody opens.1798+ // nobody opens. Darkroom is the default room now (`OLD_GUI=1` is the
1799+ // opt-out) -- `Player::darkroom` is still the field render.rs reads.
1799 let render_rs = src_text("render.rs");1800 let render_rs = src_text("render.rs");
1800 assert!(1801 assert!(
1801 render_rs.contains("if self.darkroom") && render_rs.contains("ui::stance::render("),1802 render_rs.contains("if self.darkroom") && render_rs.contains("ui::stance::render("),
1802- "EDITH_DARKROOM never reaches ui::stance::render"1803+ "Player::darkroom never reaches ui::stance::render"
1803 );1804 );
1804 }1805 }
1805 1806
crates/app/src/ui/bench_stance.rsmodified+79 -21
@@ -28,7 +28,6 @@
28 //! answer for.28 //! answer for.
29 29
30 use crate::*;30 use crate::*;
31-use crate::ui::widgets::waveform;
32 31
33 /// The pinned ruler's own height, above the lane stack.32 /// The pinned ruler's own height, above the lane stack.
34 const RULER_H: f32 = 10.;33 const RULER_H: f32 = 10.;
@@ -62,6 +61,26 @@ enum Tier {
62 Sliver,61 Sliver,
63 }62 }
64 63
64+/// `MM:SS` for a clip's own readout -- the bench talks in the film's units,
65+/// not in seconds with a decimal point.
66+fn mmss(secs: f64) -> String {
67+ let s = secs.max(0.).round() as u64;
68+ format!("{}:{:02}", s / 60, s % 60)
69+}
70+
71+/// A clip's thumbnail, filling its box. `Cover` rather than `Contain`: a clip
72+/// is a strip of film, so it crops rather than letterboxing inside a lane.
73+fn cover_image(image: std::sync::Arc<gpui::RenderImage>) -> impl IntoElement {
74+ canvas(
75+ |_, _, _| (),
76+ move |bounds, _, window, _| {
77+ let fitted = gpui::ObjectFit::Cover.get_bounds(bounds, image.size(0));
78+ let _ = window.paint_image(fitted, Corners::default(), image, 0, false);
79+ },
80+ )
81+ .size_full()
82+}
83+
65 fn tier(span: f32) -> Tier {84 fn tier(span: f32) -> Tier {
66 match span {85 match span {
67 s if s >= 120. => Tier::Full,86 s if s >= 120. => Tier::Full,
@@ -103,12 +122,17 @@ fn clip_box(
103 let left = scale.px_at(start);122 let left = scale.px_at(start);
104 let on = marked((lane, idx), clip.link, picks, pick_links);123 let on = marked((lane, idx), clip.link, picks, pick_links);
105 let t = tier(span);124 let t = tier(span);
106- let label = player.sources().get(clip.source).map(|s| file_name(&s.path));125+ let source = player.sources().get(clip.source);
126+ let label = source.map(|s| file_name(&s.path));
107 let audio = lane.kind == LaneKind::Audio;127 let audio = lane.kind == LaneKind::Audio;
108- let wave = player128+ let wave = source.and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream))).cloned();
109- .sources()129+ // hook: §12 step 5 -- per-source film ink attaches here, replacing
110- .get(clip.source)130+ // `source_tint` (library_meta.rs's own placeholder wheel, index-keyed and
111- .and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream)))131+ // already different per source) with the source's own quantized hue.
132+ let ink = source_tint(clip.source);
133+ let thumb = (!audio)
134+ .then(|| source.and_then(|s| player.thumbs.get(&s.path)))
135+ .flatten()
112 .cloned();136 .cloned();
113 let has_trace = t != Tier::Sliver;137 let has_trace = t != Tier::Sliver;
114 let has_spine = t != Tier::Sliver;138 let has_spine = t != Tier::Sliver;
@@ -116,6 +140,21 @@ fn clip_box(
116 let has_chip = t == Tier::Full && !clip.speed.is_normal();140 let has_chip = t == Tier::Full && !clip.speed.is_normal();
117 let (in_frame, out_frame) = (f64::from(clip.in_frame) / player.fps, f64::from(clip.out_frame) / player.fps);141 let (in_frame, out_frame) = (f64::from(clip.in_frame) / player.fps, f64::from(clip.out_frame) / player.fps);
118 let speed = clip.speed;142 let speed = clip.speed;
143+ // Right-aligned readout: the trim delta off the source's full length when
144+ // this clip is shorter than the file it was cut from, else the plain
145+ // duration (DESIGN §5). corner-cut: reads only against the *source's* full
146+ // length, not the subject cut's own out/in marks the time band's readout
147+ // means (§12's cut object has no per-edge history at this layer) --
148+ // ceiling is wiring this to the same cut state once the time band exposes
149+ // it, rather than a second reading of "trim" here.
150+ let full_frames = source.map(|s| player.session.as_ref().map_or(0, |sess| sess.file_frames(&s.path)));
151+ let readout = match full_frames {
152+ Some(full) if full > clip.frames() => {
153+ let delta = f64::from(full - clip.frames()) / player.fps;
154+ format!("−{}", mmss(delta))
155+ }
156+ _ => format!("{len:.1}s"),
157+ };
119 div()158 div()
120 .id(("bench-clip", lane.ord * 1000 + lane.kind as usize * 100 + idx))159 .id(("bench-clip", lane.ord * 1000 + lane.kind as usize * 100 + idx))
121 .absolute()160 .absolute()
@@ -138,7 +177,7 @@ fn clip_box(
138 this.pick((lane, idx), event.modifiers.control, cx);177 this.pick((lane, idx), event.modifiers.control, cx);
139 }),178 }),
140 )179 )
141- // Ink spine: 3px left edge, the placeholder ink until §12 step 5.180+ // Ink spine: 3px left edge, the source's own ink (hook above).
142 .when(has_spine, |d| {181 .when(has_spine, |d| {
143 d.child(182 d.child(
144 div()183 div()
@@ -147,11 +186,12 @@ fn clip_box(
147 .top_0()186 .top_0()
148 .h_full()187 .h_full()
149 .w(px(3.))188 .w(px(3.))
150- .bg(rgb(INK2())),189+ .bg(rgb(ink)),
151 )190 )
152 })191 })
153- // Trace: real waveform for audio, a flat placeholder body for video192+ // Trace: real waveform for audio, a real decoded thumbnail for video
154- // (thumbnails are §12 step 5's, same hook).193+ // (falling back to a flat placeholder body while it loads or if the
194+ // file never yields one).
155 .when(has_trace && audio, |d| {195 .when(has_trace && audio, |d| {
156 d.children(wave.and_then(|w| match w {196 d.children(wave.and_then(|w| match w {
157 Wave::Peaks(peaks) => Some(197 Wave::Peaks(peaks) => Some(
@@ -161,7 +201,7 @@ fn clip_box(
161 .right_0()201 .right_0()
162 .top_0()202 .top_0()
163 .bottom_0()203 .bottom_0()
164- .child(waveform(peaks, in_frame, out_frame)),204+ .child(waveform_ink(peaks, in_frame, out_frame, ink)),
165 ),205 ),
166 _ => None,206 _ => None,
167 }))207 }))
@@ -174,32 +214,50 @@ fn clip_box(
174 .right_0()214 .right_0()
175 .top(px(2.))215 .top(px(2.))
176 .bottom(px(2.))216 .bottom(px(2.))
177- .bg(rgb(INK4())),217+ .overflow_hidden()
218+ .bg(rgb(INK4()))
219+ .when_some(thumb, |d, thumb| match thumb {
220+ Thumb::Ready(image) => d.child(cover_image(image)),
221+ _ => d,
222+ }),
178 )223 )
179 })224 })
180- // Name plate: DESIGN §4's plate (canvas-on-panel), mono label.225+ // Name plate + trim/duration readout: one strip, DESIGN §4's plate
181- .when_some(label.filter(|_| has_label), |d, label| {226+ // (canvas-on-panel), sat at the clip's top-left/top-right per the mock
227+ // rather than the name alone hanging below the box.
228+ .when(has_label, |d| {
182 d.child(229 d.child(
183 div()230 div()
184 .absolute()231 .absolute()
185 .left(px(3.))232 .left(px(3.))
186 .right_0()233 .right_0()
187- .bottom_0()234+ .top_0()
188 .h(px(13.))235 .h(px(13.))
189 .px(px(3.))236 .px(px(3.))
237+ .flex()
238+ .items_center()
239+ .justify_between()
240+ .gap(px(4.))
190 .bg(rgba(DARK_SEAM()))241 .bg(rgba(DARK_SEAM()))
191- .truncate()242+ .when_some(label, |d, label| {
192- .text_size(px(9.5))243+ d.child(div().min_w(px(0.)).truncate().text_size(px(9.5)).text_color(rgb(INK1())).child(label))
193- .text_color(rgb(INK1()))244+ })
194- .child(label),245+ .child(
246+ div()
247+ .flex_none()
248+ .text_size(px(9.))
249+ .text_color(rgb(INK3()))
250+ .child(readout),
251+ ),
195 )252 )
196 })253 })
197- // Speed chip: dropped first in the ladder.254+ // Speed chip: dropped first in the ladder, tucked in the bottom-right
255+ // corner so it never fights the name/readout strip above.
198 .when(has_chip, |d| {256 .when(has_chip, |d| {
199 d.child(257 d.child(
200 div()258 div()
201 .absolute()259 .absolute()
202- .top_0()260+ .bottom_0()
203 .right_0()261 .right_0()
204 .px(px(3.))262 .px(px(3.))
205 .bg(rgb(DARK_RAISED()))263 .bg(rgb(DARK_RAISED()))
crates/app/src/ui/dock_stance.rsmodified+397 -25
@@ -1,6 +1,15 @@
1 //! The dock's own content: the Sources/Clip tab pair and what each shows1 //! The dock's own content: the Sources/Clip tab pair and what each shows
2 //! (DESIGN.md §5, §12 step 4). `stance.rs::dock()` owns the panel's frame2 //! (DESIGN.md §5, §12 step 4). `stance.rs::dock()` owns the panel's frame
3 //! (width, surfaces, border); this module owns what fills it.3 //! (width, surfaces, border); this module owns what fills it.
4+//!
5+//! The Sources tab used to be `Player::library` verbatim -- the legacy
6+//! panel's pill tabs, Media/Audio/Text row, filled Import button and amber
7+//! accent, wearing the darkroom surfaces only because its tokens happened to
8+//! alias into them. The user named that: "this place is not fitting design
9+//! language. it's same as our original." This module now builds the tab
10+//! fresh, off MOCK-SPEC.md's "Dock" section -- `library.rs`/`library_meta.rs`
11+//! still supply the row facts ([`library_rows`], [`source_tint`],
12+//! [`clip_middle`]...), only the anatomy around them is new.
4 13
5 use crate::*;14 use crate::*;
6 15
@@ -33,6 +42,30 @@ fn save(src_active: bool) {
33 let _ = std::fs::write(path, if src_active { "Src\n" } else { "Clip\n" });42 let _ = std::fs::write(path, if src_active { "Src\n" } else { "Clip\n" });
34 }43 }
35 44
45+/// The Sources tab's four sort chips (MOCK-SPEC "Dock" §3). `Recent` is the
46+/// library's own arrival order -- the only order this editor tracks without
47+/// a fourth field to keep it in.
48+#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
49+pub(crate) enum DockSort {
50+ #[default]
51+ Recent,
52+ Name,
53+ Usage,
54+ Unused,
55+}
56+
57+impl DockSort {
58+ const ALL: [DockSort; 4] = [DockSort::Recent, DockSort::Name, DockSort::Usage, DockSort::Unused];
59+ fn label(self) -> &'static str {
60+ match self {
61+ DockSort::Recent => "Recent",
62+ DockSort::Name => "Name",
63+ DockSort::Usage => "Usage",
64+ DockSort::Unused => "Unused",
65+ }
66+ }
67+}
68+
36 /// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in69 /// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in
37 /// `ink3` beside it, read live off the keymap so it can never drift from the70 /// `ink3` beside it, read live off the keymap so it can never drift from the
38 /// key that does the same thing. Hover is one fill step and an ink brighten;71 /// key that does the same thing. Hover is one fill step and an ink brighten;
@@ -83,39 +116,378 @@ fn ghost_verb(
83 )116 )
84 }117 }
85 118
86-/// One tab glyph of the Src/Clip pair: a plate (2px radius per §4), `ink1` +119+/// A row in the IMPORT section: a ghost verb that has no [`ActionId`] of its
87-/// `raised` fill when it is the showing tab, `ink2` at rest.120+/// own to read a chord off. `Add files`/`Paste path` have no keymap binding
88-fn dock_tab(id: &'static str, label: &'static str, active: bool, cx: &mut Context<Player>) -> impl IntoElement {121+/// -- nearly every ctrl+letter in this editor's table is already spoken for
122+/// (`git grep '", true)'` in `keymap.rs` turns up every letter but a handful),
123+/// and giving either one a fresh global chord is a keymap-wide decision --
124+/// which strokes move, which don't -- outside one dock diff. The verb still
125+/// works by click; the chord badge is honest about there being none rather
126+/// than inventing one MOCK-SPEC's `^o`/`^v` never actually bind to.
127+///
128+/// corner-cut: no chord. Ceiling: a keymap diff that clears two ctrl slots
129+/// (or two bare ones -- neither Import nor "paste a path" has ever had a key
130+/// in this editor) and threads `ActionId`s for both through `oracle::enable`
131+/// and `Player::act`, at which point this calls [`ghost_verb`] instead.
132+fn import_verb(
133+ id: &'static str,
134+ label: &'static str,
135+ hint: &'static str,
136+ on: bool,
137+ on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
138+) -> impl IntoElement {
139+ div()
140+ .id(id)
141+ .flex_none()
142+ .flex()
143+ .items_center()
144+ .justify_between()
145+ .h(px(CONTROL_H))
146+ .px(px(8.))
147+ .rounded(px(3.))
148+ .text_color(rgb(INK2()))
149+ .tooltip(move |_, cx| cx.new(|_| Tip(hint.into())).into())
150+ .when(!on, |d| d.opacity(0.4).cursor_not_allowed())
151+ .when(on, |d| {
152+ d.cursor_pointer()
153+ .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))
154+ .on_click(on_click)
155+ })
156+ .child(label)
157+ .child(div().flex_none().text_size(px(9.5)).text_color(rgb(INK3())).child("—"))
158+}
159+
160+/// One tab of the Src/Clip pair (MOCK-SPEC "Dock": no pill, no fill, no
161+/// rounded button -- a 1px `ink1` top rule and `ink1` text mark the showing
162+/// tab; the resting one is `ink3`). `chord` is decorative, not bound: tab
163+/// switching has no gesture named in the charter's four, so it is drawn but
164+/// not wired to a global key, exactly `import_verb`'s reasoning above.
165+fn dock_tab(id: &'static str, label: &'static str, chord: &'static str, active: bool, cx: &mut Context<Player>) -> impl IntoElement {
89 div()166 div()
90 .id(id)167 .id(id)
91 .flex_1()168 .flex_1()
92 .flex()169 .flex()
93 .items_center()170 .items_center()
94 .justify_center()171 .justify_center()
95- .rounded(px(2.))172+ .gap(px(4.))
96- .py(px(6.))173+ .pt(px(6.))
174+ .pb(px(6.))
175+ .when(active, |d| d.border_t_1().border_color(rgb(INK1())))
97 .text_size(px(10.5))176 .text_size(px(10.5))
98- .text_color(rgb(if active { INK1() } else { INK2() }))177+ .text_color(rgb(if active { INK1() } else { INK3() }))
99- .when(active, |d| d.bg(rgb(DARK_RAISED())))
100 .cursor_pointer()178 .cursor_pointer()
101- .hover(|s| s.bg(rgb(DARK_RAISED())))
102 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {179 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
103- this.dock_src_active = label == "Src";180+ this.dock_src_active = label == "SOURCES";
104 save(this.dock_src_active);181 save(this.dock_src_active);
105 cx.notify();182 cx.notify();
106 }))183 }))
107- .child(label)184+ .child(
185+ div()
186+ .text_size(px(10.5))
187+ .text_color(rgb(if active { INK1() } else { INK3() }))
188+ .child(label),
189+ )
190+ .child(div().text_color(rgb(INK3())).child(chord))
191+}
192+
193+/// A 9px uppercase Archivo section head, `ink3` (DESIGN §3).
194+fn section_head(text: impl Into<SharedString>) -> impl IntoElement {
195+ div()
196+ .flex_none()
197+ .text_size(px(9.))
198+ .text_color(rgb(INK3()))
199+ .child(text.into())
200+}
201+
202+/// Every lane a source plays on right now, as its own `V1`/`A1` labels
203+/// (MOCK-SPEC "Dock" §4's usage line), plus how many clips altogether --
204+/// [`Player::row_ctx`]'s `placed` count, the same number the library card's
205+/// Remove refusal reads.
206+fn usage_line(player: &Player, source_idx: usize, placed: usize) -> String {
207+ if placed == 0 {
208+ return "unused".to_string();
209+ }
210+ let lanes: Vec<String> = player.session.as_ref().map_or_else(Vec::new, |session| {
211+ session
212+ .lanes()
213+ .into_iter()
214+ .filter(|lane| session.lane_clips(*lane).iter().any(|c| c.source == source_idx))
215+ .map(Lane::label)
216+ .collect()
217+ });
218+ format!("{} · {placed} use{}", lanes.join(" "), if placed == 1 { "" } else { "s" })
219+}
220+
221+/// One source row, two lines (MOCK-SPEC "Dock" §4): an ink dot, the name in
222+/// mono `ink1` -- readable, complete, ellipsized at the end rather than
223+/// clipped mid-glyph or faded -- and right-aligned usage; under it, the
224+/// codec/length/decoder line in mono `ink3`. Drag (gesture 1), `↵` (gesture
225+/// 2, wired in `render.rs`'s key handler since a row takes no keyboard focus
226+/// of its own), double-click (gesture 3) and right-click the dot (gesture 4)
227+/// all live here.
228+fn source_row(player: &Player, i: usize, row: &Row, placed: usize, picked: bool, cx: &mut Context<Player>) -> impl IntoElement {
229+ let usable = row.unusable.is_none();
230+ let name: SharedString = row.name.clone().into();
231+ let under: String = match &row.unusable {
232+ Some(why) => why.clone(),
233+ None => join_detail(&row.detail, &timecode(f64::from(row.frames) / player.fps, player.fps)),
234+ };
235+ let usage = usage_line(player, row.tint, placed);
236+ let (path, stream) = (row.path.clone(), row.stream);
237+ let dragged = (path.clone(), stream);
238+ let dot_path = path.clone();
239+ let ghost = name.clone();
240+ div()
241+ .id(("dock-source", i))
242+ .flex_none()
243+ .flex()
244+ .flex_col()
245+ .gap(px(2.))
246+ .px(px(8.))
247+ .py(px(4.))
248+ .rounded(px(3.))
249+ .when(!usable, |d| d.opacity(0.5))
250+ .when(picked, |d| d.bg(rgb(DARK_RAISED())))
251+ .when(usable, |d| {
252+ d.cursor_pointer()
253+ .hover(|s| s.bg(rgb(DARK_RAISED())))
254+ .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
255+ this.selected_asset = Some((path.clone(), stream));
256+ // Gesture 3: a second click in the same spot plays the
257+ // source in the screen, the way `library.rs`'s preview
258+ // triangle already does -- `open_preview` is the one
259+ // door either takes.
260+ if event.click_count() >= 2 {
261+ this.open_preview(&path, stream, cx);
262+ }
263+ cx.notify();
264+ }))
265+ // Gesture 1: the row is a drag source exactly as
266+ // `library.rs`'s row is -- same payload, same ghost tip --
267+ // and the bench's `AssetDrag` drop target already accepts it
268+ // (`ui/bench_stance.rs`'s bed). The bug the user hit ("can't
269+ // drag media in timeline") was the dock showing the *legacy*
270+ // panel, which the darkroom bench was never wired against;
271+ // this row is the darkroom's own half of that pairing.
272+ .on_drag(AssetDrag(dragged.0, dragged.1), move |_, _, _, cx| {
273+ cx.new(|_| Tip(ghost.clone()))
274+ })
275+ })
276+ .child(
277+ div()
278+ .flex()
279+ .items_center()
280+ .gap(px(6.))
281+ .child(
282+ div()
283+ .id(("dock-source-dot", i))
284+ .flex_none()
285+ .w(px(8.))
286+ .h(px(8.))
287+ .rounded(px(4.))
288+ .bg(rgb(source_tint(row.tint)))
289+ .when(usable, |d| {
290+ d.on_mouse_down(
291+ MouseButton::Right,
292+ cx.listener(move |this, event: &MouseDownEvent, _, cx| {
293+ // Gesture 4, and DESIGN §2's demotion rule at
294+ // once: re-inking lives nowhere but here.
295+ // The library's own right-click menu is the
296+ // affordance this opens -- DESIGN §12 step 5
297+ // allows a stub where extraction-by-hue isn't
298+ // built yet, as long as the menu appears; it
299+ // does, over the same file this dot names.
300+ cx.stop_propagation();
301+ this.selected_asset = Some((dot_path.clone(), stream));
302+ this.library_menu = Some(LibraryMenu {
303+ path: dot_path.clone(),
304+ stream,
305+ at: event.position,
306+ details: false,
307+ });
308+ cx.notify();
309+ }),
310+ )
311+ }),
312+ )
313+ .child(
314+ div()
315+ .flex_1()
316+ .min_w(px(0.))
317+ .truncate()
318+ .text_size(px(10.5))
319+ .text_color(rgb(INK1()))
320+ .child(name),
321+ )
322+ .child(
323+ div()
324+ .flex_none()
325+ .text_size(px(9.5))
326+ .text_color(rgb(INK3()))
327+ .child(usage),
328+ ),
329+ )
330+ .child(
331+ div()
332+ .pl(px(14.))
333+ .truncate()
334+ .text_size(px(9.5))
335+ .text_color(rgb(INK3()))
336+ .child(under),
337+ )
108 }338 }
109 339
110-/// The Sources tab: [`Player::library`] verbatim -- filter tabs, usage340+/// The Sources tab, built off MOCK-SPEC.md's "Dock" section: count line,
111-/// (proxy/preview) chips, Import, drag, Add at playhead -- restyled for free,341+/// filter, sort chips, rows, IMPORT, hint -- none of it the legacy
112-/// because its rows already paint through the theme tokens `library.rs`342+/// Media/Audio/Text panel `library.rs` draws. That panel's row facts
113-/// shares with this stance (`BG_PANEL` etc. alias to the Darkroom substrate343+/// ([`library_rows`]) are still what every row here is built from.
114-/// under `PaletteId::Darkroom`). No ink/re-inking control lives in it (DESIGN344+fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
115-/// §2's demotion rule): `library.rs` never put one on a row to begin with, so345+ let sources = player.session.as_ref().map_or(&[][..], PlaybackSession::sources);
116-/// there is nothing here to strip.346+ let meta = player.session.as_ref().map(PlaybackSession::meta);
117-fn sources_tab(player: &Player, width: f32, cx: &mut Context<Player>) -> impl IntoElement {347+ let all_rows: Vec<Row> = library_rows(sources, &player.streams, &player.decoders, player.timeline_audio(), |path| {
118- player.library(width, cx)348+ player.session.as_ref().map_or(0, |session| session.file_frames(path))
349+ });
350+ let _ = meta;
351+ let unused_count = all_rows
352+ .iter()
353+ .filter(|row| player.row_ctx(&row.path, row.stream).placed == 0)
354+ .count();
355+ let filter = player.dock_filter.to_lowercase();
356+ let mut rows: Vec<(Row, usize)> = all_rows
357+ .into_iter()
358+ .map(|row| {
359+ let placed = player.row_ctx(&row.path, row.stream).placed;
360+ (row, placed)
361+ })
362+ .filter(|(row, placed)| {
363+ filter.is_empty()
364+ || row.name.to_lowercase().contains(&filter)
365+ || row.detail.to_lowercase().contains(&filter)
366+ || ("unused".contains(&filter) && *placed == 0)
367+ })
368+ .collect();
369+ match player.dock_sort {
370+ DockSort::Recent => {}
371+ DockSort::Name => rows.sort_by(|(a, _), (b, _)| a.name.to_lowercase().cmp(&b.name.to_lowercase())),
372+ DockSort::Usage => rows.sort_by(|(_, a), (_, b)| b.cmp(a)),
373+ DockSort::Unused => rows.sort_by_key(|(_, placed)| *placed > 0),
374+ }
375+ let total = rows.len();
376+ let filter_text: SharedString = player.dock_filter.clone().into();
377+ div()
378+ .id("dock-sources")
379+ .flex_1()
380+ .min_h(px(0.))
381+ .flex()
382+ .flex_col()
383+ .gap(px(6.))
384+ .p(px(8.))
385+ .overflow_y_scroll()
386+ .child(section_head(format!("SOURCES · {total} · {unused_count} UNUSED")))
387+ .child(
388+ div()
389+ .id("dock-filter")
390+ .flex_none()
391+ .cursor_text()
392+ .text_size(px(10.))
393+ .text_color(rgb(if player.dock_filter_edit { INK1() } else { INK3() }))
394+ .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
395+ this.dock_filter_edit = true;
396+ cx.notify();
397+ }))
398+ .child(match player.dock_filter.is_empty() {
399+ true => "⌕ type to filter — name, codec, unused…".to_string(),
400+ false => format!("⌕ {filter_text}"),
401+ }),
402+ )
403+ .child(
404+ div()
405+ .flex_none()
406+ .flex()
407+ .gap(px(4.))
408+ .children(DockSort::ALL.map(|sort| {
409+ let on = sort == player.dock_sort;
410+ div()
411+ .id(("dock-sort", sort as usize))
412+ .flex_none()
413+ .px(px(6.))
414+ .py(px(2.))
415+ .rounded(px(3.))
416+ .text_size(px(9.5))
417+ .when(on, |d| d.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))
418+ .when(!on, |d| d.text_color(rgb(INK3())))
419+ .cursor_pointer()
420+ .hover(|s| s.bg(rgb(DARK_RAISED())))
421+ .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
422+ this.dock_sort = sort;
423+ cx.notify();
424+ }))
425+ .child(sort.label())
426+ })),
427+ )
428+ .child(
429+ div()
430+ .id("dock-source-rows")
431+ .flex_1()
432+ .min_h(px(0.))
433+ .flex()
434+ .flex_col()
435+ .gap(px(2.))
436+ .overflow_y_scroll()
437+ .when(rows.is_empty(), |d| {
438+ d.child(
439+ div()
440+ .text_size(px(10.5))
441+ .text_color(rgb(INK3()))
442+ .child(match player.dock_filter.is_empty() {
443+ true => "No sources yet — Add files, or drop one on the window".to_string(),
444+ false => "nothing matches the filter".to_string(),
445+ }),
446+ )
447+ })
448+ .children({
449+ let elements: Vec<_> = rows
450+ .iter()
451+ .enumerate()
452+ .map(|(i, (row, placed))| {
453+ let picked = player.selected_asset.as_ref().is_some_and(|p| *p == (row.path.clone(), row.stream));
454+ source_row(player, i, row, *placed, picked, cx).into_any_element()
455+ })
456+ .collect();
457+ elements
458+ }),
459+ )
460+ .child(section_head("IMPORT"))
461+ .child(
462+ div()
463+ .flex_none()
464+ .flex()
465+ .flex_col()
466+ .child(import_verb(
467+ "dock-import-files",
468+ "Add files",
469+ "adds a file to this list — or drop one on the window",
470+ player.exporting().is_none(),
471+ cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)),
472+ ))
473+ .child(import_verb(
474+ "dock-paste-path",
475+ "Paste path",
476+ "imports the file named on the clipboard",
477+ player.exporting().is_none(),
478+ cx.listener(|this, _: &ClickEvent, _, cx| this.paste_file_path(cx)),
479+ )),
480+ )
481+ .child(
482+ div()
483+ .flex_none()
484+ .text_size(px(9.))
485+ .text_color(rgb(INK3()))
486+ .child(
487+ "drag a row to a lane · ↵ add at playhead · double-click plays in screen · \
488+ right-click the dot to re-ink a source (rare — lives out of the way)",
489+ ),
490+ )
119 }491 }
120 492
121 /// The Clip tab: the four verbs DESIGN §5 names, as ghosts, over whichever493 /// 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<Play
219 /// to, is the first region asked to give up its width entirely (a step591 /// to, is the first region asked to give up its width entirely (a step
220 /// `layout.rs`'s split budget already owns for the legacy inspector/library592 /// `layout.rs`'s split budget already owns for the legacy inspector/library
221 /// pair). What degrades *inside* fixed width is the two tabs' own content:593 /// pair). What degrades *inside* fixed width is the two tabs' own content:
222-/// Sources hands off to `library.rs`'s own row anatomy and ladder; Clip's594+/// Sources scrolls its own row list; Clip's param rows are whatever their
223-/// param rows are whatever their card already draws at this width.595+/// card already draws at this width.
224 pub(crate) fn render(player: &Player, width: f32, window_h: Pixels, cx: &mut Context<Player>) -> impl IntoElement {596 pub(crate) fn render(player: &Player, width: f32, window_h: Pixels, cx: &mut Context<Player>) -> impl IntoElement {
225 let src_active = player.dock_src_active;597 let src_active = player.dock_src_active;
226 div()598 div()
@@ -235,14 +607,14 @@ pub(crate) fn render(player: &Player, width: f32, window_h: Pixels, cx: &mut Con
235 .flex_none()607 .flex_none()
236 .flex()608 .flex()
237 .gap(px(4.))609 .gap(px(4.))
238- .p(px(8.))610+ .px(px(8.))
239 .border_b_1()611 .border_b_1()
240 .border_color(rgb(DARK_HAIRLINE()))612 .border_color(rgb(DARK_HAIRLINE()))
241- .child(dock_tab("dock-tab-src", "Src", src_active, cx))613+ .child(dock_tab("dock-tab-src", "SOURCES", "L", src_active, cx))
242- .child(dock_tab("dock-tab-clip", "Clip", !src_active, cx)),614+ .child(dock_tab("dock-tab-clip", "CLIP", "I", !src_active, cx)),
243 )615 )
244 .child(match src_active {616 .child(match src_active {
245- true => sources_tab(player, width, cx).into_any_element(),617+ true => sources_tab(player, cx).into_any_element(),
246 false => clip_tab(player, width, window_h, cx).into_any_element(),618 false => clip_tab(player, width, window_h, cx).into_any_element(),
247 })619 })
248 }620 }
crates/app/src/ui/mod.rsmodified+3 -0
@@ -10,8 +10,11 @@ pub mod inspector;
10 pub mod library;10 pub mod library;
11 pub mod overlays;11 pub mod overlays;
12 pub mod preview;12 pub mod preview;
13+pub mod spine_stance;
13 pub mod stance;14 pub mod stance;
14 pub mod theme;15 pub mod theme;
16+pub mod timeband_stance;
15 pub mod timeline;17 pub mod timeline;
16 pub mod toolbar;18 pub mod toolbar;
19+pub mod type_scale;
17 pub mod widgets;20 pub mod widgets;
crates/app/src/ui/spine_stance.rsadded+167 -0
@@ -0,0 +1,167 @@
1+//! The spine's own content (DESIGN.md §5, MOCK-SPEC.md "Spine"): grouped
2+//! task-frequency clusters, each row a glyph stacked over its own chord --
3+//! not the flat ungrouped list of glyph-beside-chord rows the shipped room
4+//! drew. `stance.rs::spine()` keeps the panel frame (width, surface,
5+//! border); this module owns the rows inside it.
6+//!
7+//! corner-cut: sizes below are plain `px()` literals matching DESIGN §3's
8+//! scale (13px glyph, 9.5px chord, 9px head) rather than calls into a
9+//! `ui::type_scale` API -- that module had not landed in this tree at the
10+//! time this was written. Ceiling: swap these three constants for its
11+//! tokens once it lands; nothing else here would change.
12+
13+use crate::*;
14+
15+const GLYPH_SIZE: f32 = 13.;
16+const CHORD_SIZE: f32 = 9.5;
17+const HEAD_SIZE: f32 = 9.;
18+
19+/// A group head: 9px uppercase Archivo 700(-weight token, same as every
20+/// other section head in the stance) in `ink3`, +0.14em tracking (DESIGN
21+/// §3) -- reused as its own small fn rather than `stance::section_head`
22+/// because that one is private to its module and carries a different
23+/// vertical rhythm (a region label, not a spine group head).
24+fn group_head(label: &str) -> impl IntoElement {
25+ div()
26+ .flex_none()
27+ .pt(px(6.))
28+ .text_size(px(HEAD_SIZE))
29+ .text_color(rgb(INK3()))
30+ .child(label.to_uppercase())
31+}
32+
33+/// One command: glyph over its chord, centred (MOCK-SPEC.md "Spine" --
34+/// "Not glyph-beside-chord on one line"). The chord is read live off
35+/// [`Keymap::display`], never a literal, so a rebind can never leave the
36+/// spine showing a stroke that no longer fires it. Ghost grammar (DESIGN
37+/// §4): borderless, hover is one fill step, active is `ink1` + fill, and a
38+/// refused verb greys with its reason on hover rather than disappearing
39+/// (DESIGN §8) -- the same oracle door `dock_stance::ghost_verb` opens.
40+fn glyph(
41+ id: &'static str,
42+ glyph: &'static str,
43+ action: ActionId,
44+ active: bool,
45+ player: &Player,
46+ cx: &mut Context<Player>,
47+) -> impl IntoElement + use<> {
48+ let enabled = player.enable(action, None);
49+ let key = player.keymap.display(action);
50+ let say: SharedString = match enabled.why() {
51+ Some(why) => format!("{key} — {why}"),
52+ None => format!("{key} — {}", action.label()),
53+ }
54+ .into();
55+ let on = enabled.yes();
56+ div()
57+ .id(id)
58+ .flex_none()
59+ .flex()
60+ .flex_col()
61+ .items_center()
62+ .gap(px(2.))
63+ .px(px(4.))
64+ .py(px(4.))
65+ .rounded(px(3.))
66+ .when(active, |d| d.bg(rgb(DARK_RAISED())))
67+ .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into())
68+ .when(!on, |d| d.opacity(0.4).cursor_not_allowed())
69+ .when(on, |d| {
70+ d.cursor_pointer()
71+ .hover(|s| s.bg(rgb(DARK_RAISED())))
72+ .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| {
73+ this.act(action, window, cx)
74+ }))
75+ })
76+ .child(
77+ div()
78+ .text_size(px(GLYPH_SIZE))
79+ .text_color(rgb(if active { INK1() } else { INK2() }))
80+ .child(glyph),
81+ )
82+ .child(
83+ div()
84+ .text_size(px(CHORD_SIZE))
85+ .text_color(rgb(INK3()))
86+ .child(key),
87+ )
88+}
89+
90+/// Two commands side by side in one row -- the opposite-direction pairs
91+/// (walk cuts, no-aim trim) that share a row in the mock rather than each
92+/// eating a full row of the spine's own height.
93+fn pair(left: impl IntoElement, right: impl IntoElement) -> impl IntoElement {
94+ div()
95+ .flex_none()
96+ .flex()
97+ .items_center()
98+ .justify_center()
99+ .gap(px(10.))
100+ .child(left)
101+ .child(right)
102+}
103+
104+/// The spine's rows, grouped by task frequency (DESIGN §5, §11 check 1):
105+/// EDIT (split, delete, undo -- every edit), CUT (walk/trim/loop-trim --
106+/// every cut), TRACK (add a lane -- once per project, cheapest land at the
107+/// bottom of the frequent group). `?` stays on `stance::spine`'s own frame,
108+/// not duplicated here.
109+///
110+/// Gap, named rather than shipped as a dead control: the mock's LEAN row
111+/// (`⊡` / `\`, "lean/zen mode") has no [`ActionId`] anywhere in
112+/// `keymap.rs` -- `Fullscreen` is the nearest existing action but it is a
113+/// different verb (the platform's own fullscreen, bound to `f11`, not a
114+/// zen/lean UI mode) so reusing it under the mock's glyph would be exactly
115+/// the fake-control this task's own instructions forbid. Left out; the
116+/// group and its bottom anchor do not exist here.
117+pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
118+ div()
119+ .id("spine-stance-rows")
120+ .flex_1()
121+ .min_h(px(0.))
122+ .w_full()
123+ .flex()
124+ .flex_col()
125+ .items_center()
126+ .gap(px(10.))
127+ .overflow_y_scroll()
128+ .child(group_head("edit"))
129+ .child(glyph("spine-split", "||", ActionId::Cut, false, player, cx))
130+ .child(glyph("spine-delete", "⊂⊃", ActionId::Delete, false, player, cx))
131+ .child(glyph("spine-undo", "↺", ActionId::Undo, false, player, cx))
132+ .child(group_head("cut"))
133+ .child(pair(
134+ glyph("spine-cut-prev", "‹", ActionId::WalkCutPrev, false, player, cx),
135+ glyph("spine-cut-next", "›", ActionId::WalkCutNext, false, player, cx),
136+ ))
137+ .child(pair(
138+ glyph(
139+ "spine-trim-in",
140+ "±1",
141+ ActionId::TrimIn,
142+ player.loop_trim.is_some(),
143+ player,
144+ cx,
145+ ),
146+ glyph(
147+ "spine-trim-out",
148+ "±1",
149+ ActionId::TrimOut,
150+ player.loop_trim.is_some(),
151+ player,
152+ cx,
153+ ),
154+ ))
155+ .child(glyph(
156+ "spine-loop-trim",
157+ "↻",
158+ ActionId::LoopTrim,
159+ player.loop_trim.is_some(),
160+ player,
161+ cx,
162+ ))
163+ .child(group_head("track"))
164+ .child(glyph("spine-add-video", "+V", ActionId::AddVideoLane, false, player, cx))
165+ .child(glyph("spine-add-audio", "+A", ActionId::AddAudioLane, false, player, cx))
166+ .child(div().flex_1())
167+}
crates/app/src/ui/stance.rsmodified+39 -113
@@ -1,6 +1,7 @@
1-//! DESIGN.md §5 -- the stance: fixed geography behind `EDITH_DARKROOM`, drawn1+//! DESIGN.md §5 -- the stance: fixed geography, drawn by default now
2-//! whole here rather than folded into the legacy four-region tree so the two2+//! (`OLD_GUI=1` opts back into the legacy four-region tree), whole here
3-//! can be told apart, and swapped, with a single `if` in `render.rs`.3+//! rather than folded into that tree so the two can be told apart, and
4+//! swapped, with a single `if` in `render.rs`.
4 //!5 //!
5 //! This step lays out the six regions and nothing else: correct geometry,6 //! This step lays out the six regions and nothing else: correct geometry,
6 //! correct surfaces, a section-head label per region. No content, no7 //! correct surfaces, a section-head label per region. No content, no
@@ -10,6 +11,8 @@
10 use crate::*;11 use crate::*;
11 use crate::ui::bench_stance;12 use crate::ui::bench_stance;
12 use crate::ui::dock_stance;13 use crate::ui::dock_stance;
14+use crate::ui::timeband_stance;
15+use crate::ui::spine_stance;
13 16
14 /// Left rail, full height (DESIGN §5).17 /// Left rail, full height (DESIGN §5).
15 const SPINE_W: f32 = 56.;18 const SPINE_W: f32 = 56.;
@@ -60,33 +63,6 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {
60 )63 )
61 }64 }
62 65
63-/// A ghost command whose stride-10 sibling is the same command at a
64-/// different scale (DESIGN §4): one glyph, both chords shown beside each
65-/// other rather than a second glyph -- the cheap fix VIOLATION 1 asked for,
66-/// reusing the ghost grammar instead of a new widget.
67-fn ghost_dual(player: &Player, glyph: &str, action: ActionId, stride: ActionId) -> impl IntoElement {
68- div()
69- .flex_none()
70- .flex()
71- .flex_col()
72- .items_center()
73- .gap(px(2.))
74- .py(px(6.))
75- .rounded(px(3.))
76- .text_size(px(13.))
77- .text_color(rgb(INK2()))
78- .child(glyph.to_string())
79- .child(
80- div()
81- .flex()
82- .gap(px(4.))
83- .text_size(px(9.5))
84- .text_color(rgb(INK3()))
85- .child(player.keymap.display(action))
86- .child(player.keymap.display(stride)),
87- )
88-}
89-
90 /// The keys overlay (DESIGN §9, §12 step 7): every bound command, sectioned66 /// The keys overlay (DESIGN §9, §12 step 7): every bound command, sectioned
91 /// by [`keymap::Category`] exactly as the legacy actions card files them67 /// by [`keymap::Category`] exactly as the legacy actions card files them
92 /// ([`keys_rows`]) -- reusing that registry-driven order is what makes an68 /// ([`keys_rows`]) -- reusing that registry-driven order is what makes an
@@ -163,11 +139,12 @@ fn keys_overlay(player: &Player) -> impl IntoElement {
163 )139 )
164 }140 }
165 141
166-/// The spine: 56px, left, full height. Every command as ghost glyph + chord,142+/// The spine: 56px, left, full height. Frame only -- grouped rows, task
167-/// grouped by task frequency (DESIGN §5) -- transport first (every second),143+/// frequency, glyph-over-chord grammar and every click all live in
168-/// then the cut machinery (DESIGN §6, every cut), then the split and the one144+/// [`crate::ui::spine_stance`] now (MOCK-SPEC.md "Spine"); this fn keeps
169-/// boxed exception is left to the time band, which is where Export lives.145+/// the panel's own surface and the `?` row, which stays part of the frame
170-fn spine(player: &Player) -> impl IntoElement {146+/// since it opens [`keys_overlay`] right here rather than through `act`.
147+fn spine(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
171 div()148 div()
172 .id("stance-spine")149 .id("stance-spine")
173 .flex_none()150 .flex_none()
@@ -182,15 +159,7 @@ fn spine(player: &Player) -> impl IntoElement {
182 .py(px(8.))159 .py(px(8.))
183 .gap(px(4.))160 .gap(px(4.))
184 .child(section_head("spine"))161 .child(section_head("spine"))
185- .child(ghost(player, "▶", ActionId::Play))162+ .child(spine_stance::render(player, cx))
186- .child(ghost_dual(player, "‹", ActionId::WalkCutPrev, ActionId::WalkCutPrev10))
187- .child(ghost_dual(player, "›", ActionId::WalkCutNext, ActionId::WalkCutNext10))
188- .child(ghost(player, "{", ActionId::SelectPrev))
189- .child(ghost(player, "}", ActionId::SelectNext))
190- .child(ghost(player, "[", ActionId::TrimIn))
191- .child(ghost(player, "]", ActionId::TrimOut))
192- .child(ghost(player, "↻", ActionId::LoopTrim))
193- .child(ghost(player, "✂", ActionId::Cut))
194 .child(ghost(player, "?", ActionId::ShowActions))163 .child(ghost(player, "?", ActionId::ShowActions))
195 }164 }
196 165
@@ -225,23 +194,13 @@ fn screen(player: &mut Player, position: f64, window: &mut Window, cx: &mut Cont
225 }194 }
226 195
227 /// Fixed-height strip under the screen: timecode leads, ghost transport, cut196 /// Fixed-height strip under the screen: timecode leads, ghost transport, cut
228-/// readout, the contact strip, boxed Export at the end (DESIGN §5).197+/// readout, the contact strip, boxed Export at the end (DESIGN §5,
229-fn time_band(player: &Player) -> impl IntoElement {198+/// MOCK-SPEC.md "Time band"). Frame only -- every row and the Export chip's
199+/// click live in [`crate::ui::timeband_stance`] now, the same split
200+/// `spine_stance`/`bench_stance`/`dock_stance` already make for their
201+/// regions.
202+fn time_band(player: &mut Player, cx: &mut Context<Player>) -> impl IntoElement {
230 let position = player.active_session().map_or(0., PlaybackSession::now);203 let position = player.active_session().map_or(0., PlaybackSession::now);
231- let tc = timecode(position, player.active_fps());
232- // The odometer (DESIGN §6): the subject cut's own place among its
233- // lane's, or an empty readout with nothing marked -- a plate that reads
234- // blank rather than one that lies about a cut zero.
235- let readout = player
236- .selected
237- .anchor()
238- .and_then(|(lane, idx)| {
239- player
240- .session
241- .as_ref()
242- .map(|s| format!("{}/{}", idx + 1, s.lane_clips(lane).len()))
243- })
244- .unwrap_or_else(|| "—/—".to_string());
245 div()204 div()
246 .id("stance-time-band")205 .id("stance-time-band")
247 .flex_none()206 .flex_none()
@@ -250,47 +209,7 @@ fn time_band(player: &Player) -> impl IntoElement {
250 .border_t_1()209 .border_t_1()
251 .border_color(rgba(DARK_SEAM()))210 .border_color(rgba(DARK_SEAM()))
252 .flex()211 .flex()
253- .items_center()212+ .child(timeband_stance::render(player, position, cx))
254- .gap(px(16.))
255- .px(px(12.))
256- // The most-read element anchors its region (DESIGN §5): the
257- // timecode leads, 13px hero, 700, colons in `ink3`.
258- .child(
259- div()
260- .text_size(px(13.))
261- .text_color(rgb(INK1()))
262- .child(tc),
263- )
264- .child(ghost(player, if player.transport().is_playing() { "❚❚" } else { "▶" }, ActionId::Play))
265- // The cut readout: a plate, mono, the odometer DESIGN §6 asks for.
266- .child(
267- div()
268- .flex_none()
269- .px(px(8.))
270- .py(px(4.))
271- .rounded(px(2.))
272- .bg(rgb(DARK_CANVAS()))
273- .text_size(px(10.5))
274- .text_color(rgb(INK1()))
275- .child(readout),
276- )
277- .child(div().flex_1())
278- // Boxed Export: the one bordered control on the surface (DESIGN §4).
279- .child(
280- div()
281- .id("stance-export")
282- .flex_none()
283- .px(px(10.))
284- .py(px(6.))
285- .rounded(px(3.))
286- .border_1()
287- .border_color(rgb(DARK_HAIRLINE()))
288- .bg(rgb(DARK_RAISED()))
289- .text_size(px(10.5))
290- .text_color(rgb(INK1()))
291- .cursor_pointer()
292- .child(format!("Export ({})", player.keymap.display(ActionId::Export))),
293- )
294 }213 }
295 214
296 /// Lanes, under the time band. `canvas` is the bench background too (DESIGN215 /// Lanes, under the time band. `canvas` is the bench background too (DESIGN
@@ -429,7 +348,8 @@ pub(crate) fn render(
429 window: &mut Window,348 window: &mut Window,
430 cx: &mut Context<Player>,349 cx: &mut Context<Player>,
431 ) -> impl IntoElement {350 ) -> impl IntoElement {
432- let window_h = window.viewport_size().height;351+ let window_size = window.viewport_size();
352+ let window_h = window_size.height;
433 let position = player.playhead(player.drawn_duration());353 let position = player.playhead(player.drawn_duration());
434 div()354 div()
435 .id("stance-room")355 .id("stance-room")
@@ -475,14 +395,13 @@ pub(crate) fn render(
475 return;395 return;
476 }396 }
477 if let Some(action) = this.keymap.lookup(key, ctrl) {397 if let Some(action) = this.keymap.lookup(key, ctrl) {
478- // hook: §12 step 7 -- the export card (and the notice plates398+ // `ActionId::Export` used to be suppressed here because the
479- // that would announce an export's progress) has no stance399+ // darkroom drew no export surface for the card to land on
480- // surface yet, so it is suppressed here rather than left to400+ // (DESIGN §12 step 7's own hook). It has one now
481- // open a card nothing on screen can draw. `ShowActions` now401+ // ([`timeband_stance::export_chip`] opens it, `render`
482- // has one ([`keys_overlay`]) so it is no longer on this list.402+ // below mounts [`Player::export_card`]/`export_progress_card`
483- if action == ActionId::Export {403+ // exactly where the legacy tree does), so `^e` dispatches
484- return;404+ // like every other action.
485- }
486 this.act(action, window, cx);405 this.act(action, window, cx);
487 }406 }
488 }))407 }))
@@ -499,7 +418,7 @@ pub(crate) fn render(
499 .size_full()418 .size_full()
500 .flex()419 .flex()
501 .bg(rgb(DARK_CANVAS()))420 .bg(rgb(DARK_CANVAS()))
502- .child(spine(player))421+ .child(spine(player, cx))
503 .child(422 .child(
504 div()423 div()
505 .id("stance-centre")424 .id("stance-centre")
@@ -509,13 +428,20 @@ pub(crate) fn render(
509 .flex()428 .flex()
510 .flex_col()429 .flex_col()
511 .child(screen(player, position, window, cx))430 .child(screen(player, position, window, cx))
512- .child(time_band(player))431+ .child(time_band(player, cx))
513 .child(bench(player, cx))432 .child(bench(player, cx))
514 .child(ledger(player, position))433 .child(ledger(player, position))
515 .when_some(player.notices.front().cloned(), |el, n| {434 .when_some(player.notices.front().cloned(), |el, n| {
516 el.child(notice_plate(n))435 el.child(notice_plate(n))
517 })436 })
518- .when(player.keys_open, |el| el.child(keys_overlay(player))),437+ .when(player.keys_open, |el| el.child(keys_overlay(player)))
438+ // The export card and its running-progress sheet, mounted
439+ // over the whole room exactly as the legacy tree mounts them
440+ // (`render.rs`) -- the fix for the shipped "Export does
441+ // nothing" defect: the chip/chord open `export_open`, this is
442+ // what draws it once open.
443+ .children(player.export_card(window_size, cx))
444+ .children(player.export_progress_card(cx)),
519 )445 )
520 .child(dock(player, window_h, cx))446 .child(dock(player, window_h, cx))
521 }447 }
crates/app/src/ui/timeband_stance.rsadded+342 -0
@@ -0,0 +1,342 @@
1+//! The time band's own content (MOCK-SPEC.md "Time band", DESIGN.md §5):
2+//! hero timecode, ghost transport, cut readout, the contact strip (whole-film
3+//! minimap) and the boxed Export chip. `stance.rs::time_band()`'s frame draws
4+//! the strip; this module owns what fills it, the same split
5+//! `dock_stance.rs`/`bench_stance.rs` already make for their regions.
6+//!
7+//! Type note: DESIGN.md §3 says the hero timecode is 13px; the approved mock
8+//! (MOCK-SPEC.md) reads closer to ~20px. Kept at 13px here -- the binding
9+//! contract's own number, already what `stance.rs::time_band()` shipped --
10+//! rather than silently picking the mock's, and named here per this task's
11+//! own instruction to say so when the two disagree.
12+
13+use crate::*;
14+
15+thread_local! {
16+ // corner-cut: every other drag surface in this codebase (the bench
17+ // scrollbar's `scroll_drag`, the volume slider's `volume_dragging`) keeps
18+ // its anchor and its measured bounds as `Player` fields (`main.rs`). That
19+ // file belongs to a concurrent builder this session, so the contact
20+ // strip's own transient gesture state lives here instead, in the same
21+ // `Rc<Cell<Bounds<Pixels>>>` shape `bounds_probe` already takes. Ceiling:
22+ // fold both into `Player` once `main.rs` is free again.
23+ static STRIP_BOUNDS: Rc<Cell<Bounds<Pixels>>> = Rc::new(Cell::new(Bounds::default()));
24+ static PAN_ANCHOR: Cell<Option<f32>> = Cell::new(None);
25+}
26+
27+/// A stacked ghost command (DESIGN §4, MOCK-SPEC "Ghost transport"/"spine"):
28+/// glyph ~13px `ink2` over its chord ~9.5px `ink3`, read live off the keymap
29+/// so a rebind can never leave the band showing a stroke that no longer
30+/// fires it -- the same shape `stance::ghost` draws for the spine, kept local
31+/// here so this module owns its own region end to end.
32+fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {
33+ div()
34+ .flex_none()
35+ .flex()
36+ .flex_col()
37+ .items_center()
38+ .gap(px(1.))
39+ .text_size(px(13.))
40+ .text_color(rgb(INK2()))
41+ .child(glyph.to_string())
42+ .child(
43+ div()
44+ .text_size(px(9.))
45+ .text_color(rgb(INK3()))
46+ .child(player.keymap.display(action)),
47+ )
48+}
49+
50+/// The hero timecode, digits `ink1` and colons `ink3` (DESIGN §3, MOCK-SPEC
51+/// "Hero timecode"): the one place in the band the string is split apart
52+/// rather than painted whole, so the colons can read a shade quieter than
53+/// the numbers either side of them.
54+fn hero_timecode(tc: &str) -> impl IntoElement {
55+ div()
56+ .flex_none()
57+ .flex()
58+ .text_size(px(13.))
59+ .children(tc.chars().map(|c| {
60+ let ink = if c == ':' { INK3() } else { INK1() };
61+ div().text_color(rgb(ink)).child(c.to_string())
62+ }))
63+}
64+
65+/// A signed `±M:SS` delta, the shape MOCK-SPEC's cut readout writes trim
66+/// deltas in (`−02:10`, `+01:04`) -- the sign says which way the edge moved
67+/// since roll armed, [`clock`] says how far.
68+fn signed_delta(frames: i64, fps: f64) -> String {
69+ let secs = (frames.unsigned_abs() as f32) / (fps as f32).max(1.);
70+ format!("{}{}", if frames < 0 { "−" } else { "+" }, clock(secs))
71+}
72+
73+/// The cut readout (MOCK-SPEC "Cut readout"): the odometer (`cut 14/37`),
74+/// the subject cut's own trim deltas against where roll armed it (only real
75+/// once [`Player::loop_trim`] has a baseline to measure against), and the
76+/// roll word itself, on or dim. `·` separators in `ink3`, values in `ink2`.
77+fn cut_readout(player: &Player) -> impl IntoElement {
78+ let sep = || div().text_color(rgb(INK3())).child(" · ");
79+ let val = |s: String| div().text_color(rgb(INK2())).child(s);
80+ let anchor = player.selected.anchor();
81+ let odometer = anchor
82+ .and_then(|(lane, idx)| {
83+ player
84+ .session
85+ .as_ref()
86+ .map(|s| format!("cut {}/{}", idx + 1, s.lane_clips(lane).len()))
87+ })
88+ .unwrap_or_else(|| "cut —/—".to_string());
89+ // The baseline a roll session captured at arm time (`toggle_loop_trim`)
90+ // doubles as the trim deltas' zero point: the same span it loops is the
91+ // span its own edges are measured from.
92+ let deltas = anchor.and_then(|(lane, idx)| {
93+ let (lo, hi) = player.loop_trim?;
94+ let clip = player.session.as_ref()?.lane_clips(lane).get(idx)?;
95+ let fps = player.active_fps();
96+ Some((
97+ signed_delta(i64::from(clip.start) - i64::from(lo), fps),
98+ signed_delta(i64::from(clip.end()) - i64::from(hi), fps),
99+ ))
100+ });
101+ let roll_on = player.loop_trim.is_some();
102+ div()
103+ .id("stance-cut-readout")
104+ .flex_none()
105+ .flex()
106+ .items_center()
107+ .px(px(8.))
108+ .py(px(4.))
109+ .rounded(px(2.))
110+ .bg(rgb(DARK_CANVAS()))
111+ .text_size(px(10.5))
112+ .child(val(odometer))
113+ .when_some(deltas, |el, (in_d, out_d)| {
114+ el.child(sep())
115+ .child(val(format!("out {out_d}")))
116+ .child(sep())
117+ .child(val(format!("in {in_d}")))
118+ })
119+ .child(sep())
120+ .child(
121+ div()
122+ .text_color(rgb(if roll_on { INK1() } else { INK4() }))
123+ .child("roll"),
124+ )
125+}
126+
127+/// The contact strip (MOCK-SPEC "Contact strip"): the whole-film minimap
128+/// filling the band's remaining width, with a 1px viewport bracket marking
129+/// where the bench's own window sits. Click jumps the playhead; drag pans
130+/// the bench window.
131+///
132+/// hook: the trace itself is splice positions (real clip boundaries, from
133+/// [`PlaybackSession::lanes`]/`lane_clips` -- data the app already has), not
134+/// a motion or audio trace -- that needs a per-frame decode of the whole
135+/// film this task did not budget for. What would make it real: a cached
136+/// low-res luma/RMS pass over each source at import, sampled here instead of
137+/// clip boundaries.
138+fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
139+ let duration = player.drawn_duration();
140+ let view = player.view();
141+ let (left_frac, width_frac) = if duration > 0. {
142+ (
143+ (view.scale.start / duration).clamp(0., 1.) as f32,
144+ (view.span() / duration).clamp(0., 1.) as f32,
145+ )
146+ } else {
147+ (0., 1.)
148+ };
149+ let fps = player.active_fps();
150+ let ticks: Vec<f32> = player
151+ .session
152+ .as_ref()
153+ .map(|s| {
154+ s.lanes()
155+ .into_iter()
156+ .filter(|l| l.kind == LaneKind::Video)
157+ .flat_map(|l| s.lane_clips(l).iter().map(Clip::end).collect::<Vec<_>>())
158+ .collect::<Vec<_>>()
159+ })
160+ .unwrap_or_default()
161+ .into_iter()
162+ .filter(|_| duration > 0.)
163+ .map(|f| ((f64::from(f) / fps) / duration).clamp(0., 1.) as f32)
164+ .collect();
165+ let strip_bounds = STRIP_BOUNDS.with(Rc::clone);
166+ div()
167+ .id("stance-contact-strip")
168+ .relative()
169+ .flex_1()
170+ .min_w(px(0.))
171+ .h(px(28.))
172+ .cursor_pointer()
173+ .tooltip(|_, cx| {
174+ cx.new(|_| Tip("Contact strip — click jumps, drag pans the bench".into()))
175+ .into()
176+ })
177+ .on_mouse_down(
178+ MouseButton::Left,
179+ cx.listener({
180+ let bounds = strip_bounds.clone();
181+ move |this, event: &MouseDownEvent, _, cx| {
182+ let duration = this.drawn_duration();
183+ if duration > 0. {
184+ let frac = frac_along(event.position.x, bounds.get());
185+ this.seek(f64::from(frac) * duration, cx);
186+ }
187+ PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x))));
188+ }
189+ }),
190+ )
191+ .on_mouse_move(cx.listener(move |this, event: &MouseMoveEvent, _, cx| {
192+ let Some(last_x) = PAN_ANCHOR.with(Cell::get) else {
193+ return;
194+ };
195+ match event.pressed_button {
196+ Some(MouseButton::Left) => {
197+ let bounds = STRIP_BOUNDS.with(Rc::clone).get();
198+ let w = f32::from(bounds.size.width).max(1.);
199+ let dx = f32::from(event.position.x) - last_x;
200+ let duration = this.drawn_duration();
201+ if duration > 0. {
202+ let delta = f64::from(dx / w) * duration;
203+ let span = this.view().span();
204+ let max_start = (duration - span).max(0.);
205+ this.scale.start = (this.scale.start + delta).clamp(0., max_start);
206+ }
207+ PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x))));
208+ cx.notify();
209+ }
210+ _ => PAN_ANCHOR.with(|a| a.set(None)),
211+ }
212+ }))
213+ .on_mouse_up(
214+ MouseButton::Left,
215+ cx.listener(|_, _, _, _| PAN_ANCHOR.with(|a| a.set(None))),
216+ )
217+ .child(bounds_probe(strip_bounds))
218+ // The baseline trace (see the `hook:` above).
219+ .child(
220+ div()
221+ .absolute()
222+ .left_0()
223+ .right_0()
224+ .top(px(13.))
225+ .h(px(2.))
226+ .bg(rgb(DARK_HAIRLINE())),
227+ )
228+ .children(ticks.into_iter().map(|frac| {
229+ div()
230+ .absolute()
231+ .left(relative(frac))
232+ .top(px(9.))
233+ .w(px(1.))
234+ .h(px(10.))
235+ .bg(rgb(LAMP_WHITE()))
236+ }))
237+ // The viewport bracket: the bench window's own span, with grip
238+ // notches at each edge (MOCK-SPEC: "1px viewport bracket (with grip
239+ // notches)").
240+ .child(
241+ div()
242+ .absolute()
243+ .left(relative(left_frac))
244+ .top_0()
245+ .h_full()
246+ .w(relative(width_frac.max(0.01)))
247+ .border_1()
248+ .border_color(rgb(INK1()))
249+ .child(
250+ div()
251+ .absolute()
252+ .left_0()
253+ .top_0()
254+ .w(px(2.))
255+ .h(px(6.))
256+ .bg(rgb(INK1())),
257+ )
258+ .child(
259+ div()
260+ .absolute()
261+ .right_0()
262+ .bottom_0()
263+ .w(px(2.))
264+ .h(px(6.))
265+ .bg(rgb(INK1())),
266+ ),
267+ )
268+}
269+
270+/// The Export chip (MOCK-SPEC "Export chip", DESIGN §4): the room's single
271+/// bordered control. Opens the export card exactly the way the legacy room's
272+/// own Export button does ([`Player::open_export`], `ui/toolbar.rs`'s
273+/// `action_control` click) -- this is the fix for the shipped defect: the
274+/// darkroom used to suppress `ActionId::Export` outright because it drew no
275+/// surface for the card to land on; `stance.rs::render` now dispatches it
276+/// like every other action, and the card itself
277+/// ([`Player::export_card`]/`export_progress_card`) is mounted over the room
278+/// by [`super::stance::render`] the same way the keys overlay is.
279+fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
280+ let exporting = player.exporting().is_some();
281+ div()
282+ .id("stance-export")
283+ .flex_none()
284+ .px(px(10.))
285+ .py(px(6.))
286+ .rounded(px(3.))
287+ .border_1()
288+ .border_color(rgb(DARK_HAIRLINE()))
289+ .bg(rgb(DARK_RAISED()))
290+ .text_size(px(10.5))
291+ .text_color(rgb(INK1()))
292+ .cursor_pointer()
293+ .hover(|s| s.bg(rgb(DARK_PANEL())))
294+ .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
295+ if this.exporting().is_some() {
296+ this.cancel_export();
297+ } else {
298+ this.open_export(cx);
299+ }
300+ cx.notify();
301+ }))
302+ .child(format!(
303+ "{} {}",
304+ if exporting { "Exporting" } else { "Export" },
305+ player.keymap.display(ActionId::Export)
306+ ))
307+}
308+
309+/// The whole band, left to right per MOCK-SPEC: hero timecode, ghost
310+/// transport, cut readout, the contact strip filling the rest, the Export
311+/// chip at the end.
312+pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player>) -> impl IntoElement {
313+ let tc = timecode(position, player.active_fps());
314+ div()
315+ .id("stance-time-band")
316+ .flex_none()
317+ .h_full()
318+ .flex()
319+ .items_center()
320+ .gap(px(16.))
321+ .px(px(12.))
322+ // The most-read element anchors its region (DESIGN §5): the
323+ // timecode leads.
324+ .child(hero_timecode(&tc))
325+ .child(
326+ div()
327+ .flex_none()
328+ .flex()
329+ .items_center()
330+ .gap(px(10.))
331+ .child(ghost(player, "◀◀", ActionId::JumpBack))
332+ .child(ghost(
333+ player,
334+ if player.transport().is_playing() { "❚❚" } else { "▶" },
335+ ActionId::Play,
336+ ))
337+ .child(ghost(player, "▶▶", ActionId::JumpForward)),
338+ )
339+ .child(cut_readout(player))
340+ .child(contact_strip(player, cx))
341+ .child(export_chip(player, cx))
342+}
crates/app/src/ui/type_scale.rsadded+221 -0
@@ -0,0 +1,221 @@
1+//! DESIGN.md §3 -- the room's two faces, bundled so nothing depends on the
2+//! machine happening to have them (`fc-list` on the dev box finds neither).
3+//!
4+//! Archivo is the room's voice (labels, verbs, section heads); Spline Sans
5+//! Mono is everything the film says (timecode, chords, readouts, metadata,
6+//! names, the ledger). Every call site asks this module for a style by
7+//! *role*, the same discipline `ui::theme` holds for colour -- no element
8+//! spells a family string or a raw weight number itself.
9+//!
10+//! The two TTFs in `assets/fonts/` are Google Fonts variable masters (one
11+//! file, a `wght` axis). gpui's Linux text backend is `cosmic-text` 0.14,
12+//! which carries no variable-font axis support (grepped: no `fvar`/variation
13+//! handling anywhere in its source) -- so embedding the variable master
14+//! directly would register exactly one face per family and render every
15+//! requested weight as that face's single baked-in weight. The five
16+//! `*-Regular.ttf` / `*-Medium.ttf` / `*-Bold.ttf` files beside the masters
17+//! are static instances pinned with `fonttools varLib.instancer` (already on
18+//! this box; no new Rust dependency), one per weight DESIGN §3 actually
19+//! names. They share the master's OFL licence (an instanced subset is a
20+//! derivative work, which OFL permits) and its typographic family name, so
21+//! `font_kit::matching::find_best_match` picks the right static face for a
22+//! requested weight the same way it would pick among any other family's
23+//! separately-shipped weight files.
24+
25+// The four region rebuilds (dock/bench/time band/spine) consume this module's
26+// `label`/`mono`/`head` in their own concurrent steps; until they land, this
27+// crate's only caller of the public API is `main.rs`'s `register`.
28+#![allow(dead_code)]
29+
30+use gpui::{App, Font, FontFeatures, FontWeight, Pixels, SharedString, font, px};
31+use std::borrow::Cow;
32+
33+/// Archivo: labels, verbs, section heads.
34+pub const ARCHIVO: &str = "Archivo";
35+/// Spline Sans Mono: timecode, chords, readouts, metadata, names, the ledger.
36+pub const SPLINE_SANS_MONO: &str = "Spline Sans Mono";
37+
38+/// DESIGN §3's scale, named so a call site reads the role, not a number.
39+pub const HERO_TIMECODE_PX: f32 = 13.;
40+pub const LABEL_ROW_PX: f32 = 10.5;
41+pub const CHORD_METADATA_MAX_PX: f32 = 10.;
42+pub const CHORD_METADATA_MIN_PX: f32 = 9.5;
43+pub const SECTION_HEAD_PX: f32 = 9.;
44+/// The floor DESIGN §3 sets: nothing in the room reads smaller than this.
45+pub const FLOOR_PX: f32 = 8.;
46+
47+/// A family, weight and size together -- what a call site needs to paint
48+/// text with `.font(style.font).text_size(style.size)`, and nothing it has
49+/// to spell out by hand.
50+#[derive(Clone, Debug)]
51+pub struct TypeStyle {
52+ pub font: Font,
53+ pub size: Pixels,
54+}
55+
56+/// Tabular figures, wherever digits align (odometers, timecodes, readouts).
57+/// `tnum` is an arbitrary OpenType feature tag to gpui's `FontFeatures`, so
58+/// this is the one place that spells it -- every mono call site gets it for
59+/// free rather than asking for it by hand.
60+fn tabular_figures() -> FontFeatures {
61+ FontFeatures(std::sync::Arc::new(vec![("tnum".to_string(), 1)]))
62+}
63+
64+fn family_font(family: impl Into<SharedString>, weight: FontWeight, tabular: bool) -> Font {
65+ let mut f = font(family).with_weight(weight);
66+ if tabular {
67+ f.features = tabular_figures();
68+ }
69+ f
70+}
71+
72+trait WithWeight {
73+ fn with_weight(self, weight: FontWeight) -> Self;
74+}
75+impl WithWeight for Font {
76+ fn with_weight(mut self, weight: FontWeight) -> Self {
77+ self.weight = weight;
78+ self
79+ }
80+}
81+
82+/// Archivo, at the given size and weight -- labels, verbs, section heads.
83+/// No italics anywhere in the room (DESIGN §3), so this never offers one.
84+pub fn label(size_px: f32, weight: FontWeight) -> TypeStyle {
85+ debug_assert!(size_px >= FLOOR_PX, "below DESIGN §3's 8px floor: {size_px}");
86+ TypeStyle {
87+ font: family_font(ARCHIVO, weight, false),
88+ size: px(size_px),
89+ }
90+}
91+
92+/// Spline Sans Mono, at the given size and weight, tabular figures on --
93+/// everything the film says.
94+pub fn mono(size_px: f32, weight: FontWeight) -> TypeStyle {
95+ debug_assert!(size_px >= FLOOR_PX, "below DESIGN §3's 8px floor: {size_px}");
96+ TypeStyle {
97+ font: family_font(SPLINE_SANS_MONO, weight, true),
98+ size: px(size_px),
99+ }
100+}
101+
102+/// A 9px Archivo 700 section head, `ink3`. The caller still has to uppercase
103+/// its own text (`.to_uppercase()`) and paint `ink3` -- this module only
104+/// owns type, not colour, and stays out of `ui::theme`'s door.
105+///
106+/// The +0.14em tracking DESIGN §3 asks for has no home: gpui 0.2.2 carries
107+/// no letter-spacing API at all (grepped `styled.rs`, `style.rs`,
108+/// `text_system.rs` -- no `letter_spacing` symbol anywhere in the crate), so
109+/// section heads render at zero tracking until gpui gains one or a caller
110+/// hand-kerns with inserted thin spaces (not done here: that would change
111+/// the text content, not just its style).
112+pub fn head() -> TypeStyle {
113+ label(SECTION_HEAD_PX, FontWeight::BOLD)
114+}
115+
116+/// One face's worth of TTFs to embed, `(bytes, name)` for the doc comment
117+/// above `register` to explain if a load ever fails.
118+const EMBEDDED: &[(&[u8], &str)] = &[
119+ (
120+ include_bytes!("../../../../assets/fonts/Archivo-Regular.ttf"),
121+ "Archivo-Regular.ttf",
122+ ),
123+ (
124+ include_bytes!("../../../../assets/fonts/Archivo-Medium.ttf"),
125+ "Archivo-Medium.ttf",
126+ ),
127+ (
128+ include_bytes!("../../../../assets/fonts/Archivo-Bold.ttf"),
129+ "Archivo-Bold.ttf",
130+ ),
131+ (
132+ include_bytes!("../../../../assets/fonts/SplineSansMono-Medium.ttf"),
133+ "SplineSansMono-Medium.ttf",
134+ ),
135+ (
136+ include_bytes!("../../../../assets/fonts/SplineSansMono-Bold.ttf"),
137+ "SplineSansMono-Bold.ttf",
138+ ),
139+];
140+
141+/// Registers both faces with gpui's text system, once, before the first
142+/// window opens. Bundled bytes (`include_bytes!`) rather than a runtime
143+/// read of `assets/` -- the binary carries its own type, full stop, so a
144+/// build copied off this machine still renders Archivo and Spline Sans Mono
145+/// with nothing installed system-side.
146+///
147+/// A registration failure (malformed font data) is a build-time bug, not a
148+/// runtime one -- these bytes are fixed at compile time -- so it panics
149+/// rather than falling silently back to a system face DESIGN §3 forbids.
150+pub fn register(cx: &App) {
151+ let fonts: Vec<Cow<'static, [u8]>> =
152+ EMBEDDED.iter().map(|(bytes, _)| Cow::Borrowed(*bytes)).collect();
153+ cx.text_system()
154+ .add_fonts(fonts)
155+ .expect("bundled Archivo / Spline Sans Mono TTFs failed to register");
156+}
157+
158+#[cfg(test)]
159+mod tests {
160+ use super::*;
161+ use gpui::FontStyle;
162+
163+ /// The scale never drifts below DESIGN §3's floor, and role sizes match
164+ /// the numbers §3 names -- a call site changing `13.` to `12.` for the
165+ /// hero timecode is the design contract silently moving.
166+ #[test]
167+ fn the_scale_matches_design_3() {
168+ assert_eq!(HERO_TIMECODE_PX, 13.);
169+ assert_eq!(LABEL_ROW_PX, 10.5);
170+ assert!((9.5..=10.).contains(&CHORD_METADATA_MIN_PX));
171+ assert_eq!(SECTION_HEAD_PX, 9.);
172+ assert_eq!(FLOOR_PX, 8.);
173+ for size in [
174+ HERO_TIMECODE_PX,
175+ LABEL_ROW_PX,
176+ CHORD_METADATA_MAX_PX,
177+ CHORD_METADATA_MIN_PX,
178+ SECTION_HEAD_PX,
179+ ] {
180+ assert!(size >= FLOOR_PX, "{size} sits below the floor");
181+ }
182+ }
183+
184+ /// Mono asks for tabular figures; Archivo never does (it carries no
185+ /// digit odometers) -- and neither ever asks for italic, which DESIGN
186+ /// §3 bans outright.
187+ #[test]
188+ fn mono_is_tabular_archivo_is_not_and_neither_is_ever_italic() {
189+ let m = mono(LABEL_ROW_PX, FontWeight::MEDIUM);
190+ assert_eq!(m.font.family.as_ref(), SPLINE_SANS_MONO);
191+ assert_eq!(m.font.features.tag_value_list(), &[("tnum".to_string(), 1)]);
192+ assert_eq!(m.font.style, FontStyle::Normal);
193+
194+ let l = label(LABEL_ROW_PX, FontWeight::MEDIUM);
195+ assert_eq!(l.font.family.as_ref(), ARCHIVO);
196+ assert!(l.font.features.tag_value_list().is_empty());
197+ assert_eq!(l.font.style, FontStyle::Normal);
198+ }
199+
200+ /// `head()` is exactly what DESIGN §3 names for section heads: Archivo,
201+ /// 700, 9px.
202+ #[test]
203+ fn head_is_archivo_bold_9px() {
204+ let h = head();
205+ assert_eq!(h.font.family.as_ref(), ARCHIVO);
206+ assert_eq!(h.font.weight, FontWeight::BOLD);
207+ assert_eq!(h.size, px(SECTION_HEAD_PX));
208+ }
209+
210+ /// The five embedded faces are exactly the static weight instances the
211+ /// module doc explains the need for -- a fifth or sixth file added here
212+ /// without also landing in `assets/fonts/` is a build break, not a
213+ /// silent gap.
214+ #[test]
215+ fn five_static_weights_are_embedded() {
216+ assert_eq!(EMBEDDED.len(), 5);
217+ for (bytes, name) in EMBEDDED {
218+ assert!(!bytes.is_empty(), "{name} embedded empty");
219+ }
220+ }
221+}
crates/app/src/ui/widgets.rsmodified+9 -1
@@ -6,6 +6,14 @@ use crate::*;
6 /// is given. Peaks are the source's whole envelope; `from`/`to` are the source6 /// is given. Peaks are the source's whole envelope; `from`/`to` are the source
7 /// seconds this clip plays, so a cut clip shows its own stretch of the file.7 /// seconds this clip plays, so a cut clip shows its own stretch of the file.
8 pub(crate) fn waveform(peaks: Arc<Vec<(f32, f32)>>, from: f64, to: f64) -> impl IntoElement {8 pub(crate) fn waveform(peaks: Arc<Vec<(f32, f32)>>, from: f64, to: f64) -> impl IntoElement {
9+ waveform_ink(peaks, from, to, FG_SECONDARY())
10+}
11+
12+/// As [`waveform`], but in a caller-picked ink rather than the fixed
13+/// secondary foreground -- the darkroom bench's own audio clips draw their
14+/// envelope in the source's ink (DESIGN §5), which the legacy timeline never
15+/// needed a colour for.
16+pub(crate) fn waveform_ink(peaks: Arc<Vec<(f32, f32)>>, from: f64, to: f64, ink: u32) -> impl IntoElement {
9 canvas(17 canvas(
10 |_, _, _| (),18 |_, _, _| (),
11 move |bounds, _, window, _| {19 move |bounds, _, window, _| {
@@ -28,7 +36,7 @@ pub(crate) fn waveform(peaks: Arc<Vec<(f32, f32)>>, from: f64, to: f64) -> impl
28 let mut path = PathBuilder::fill();36 let mut path = PathBuilder::fill();
29 path.add_polygon(&points, true);37 path.add_polygon(&points, true);
30 if let Ok(path) = path.build() {38 if let Ok(path) = path.build() {
31- window.paint_path(path, rgb(FG_SECONDARY()));39+ window.paint_path(path, rgb(ink));
32 }40 }
33 },41 },
34 )42 )