From b97144e02c1eafb49729129c4503746d96ea1332 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 16:46:27 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(ui):=20every=20command=20finds?= =?UTF-8?q?=20a=20home=20in=20the=20room?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An audit compared the two rooms command by command. Fifteen commands lived only on memorised keys in the darkroom though the old room gave each a control: mute and volume, loop, save, snap, the subtitle trio, proxies, theme, fullscreen, screenshot. They are placed by how often an editor reaches for them — the loud ones in the geography beside the work they belong to, the once-a-project ones ink-demoted into a quiet ROOM group — and each wears its live chord and greys with its reason when refused. Right-clicking a clip did nothing: the menu surface was mounted and nothing ever opened it, so every verb it holds had no mouse path. It opens now, on clips and on subtitle cues, which the bench also draws at last. The param cards were keyboard-dead in the new room — the branches that nudge a value, pick a band and reset a row were left behind in the old one. They are shared by both rooms now rather than copied into one. Silence, mix and subtitle style were mounted nowhere at all, so their keys made the room modal with nothing on screen; they paint, and a test reads the modal predicate's own source to prove every state it consults has a surface. --- crates/app/src/player/cards.rs | 196 +++++++++++++++++++++++++ crates/app/src/render.rs | 206 +-------------------------- crates/app/src/tests/cards.rs | 58 ++++++++ crates/app/src/ui/bench_stance.rs | 168 +++++++++++++++++++++- crates/app/src/ui/dock_stance.rs | 40 +++++- crates/app/src/ui/spine_stance.rs | 93 ++++++++++-- crates/app/src/ui/stance.rs | 12 ++ crates/app/src/ui/timeband_stance.rs | 106 +++++++++++++- 8 files changed, 661 insertions(+), 218 deletions(-) diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index 8c1896d..838e53f 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -1464,4 +1464,200 @@ impl Player { }) .map_or(0, |(i, _)| i) } + + /// Every param card's own key branch (EQ, Colour, Transform, Speed, + /// Silence, Mix, Subtitle style), factored out of the legacy tree's + /// `render.rs` handler so a second stance (`ui/stance.rs`) can drive the + /// same cards without a second, divergent copy of this logic -- the + /// defect class DESIGN §6's "drag while playing... `r` resets" was + /// missing from the darkroom for. Returns `true` when a card was open + /// and ate the key, the caller's cue to `cx.notify()` and stop exactly + /// where each of these branches used to `return` inline. + pub(crate) fn param_card_key(&mut self, key: &str, shift: bool, cx: &mut Context) -> bool { + if self.eq_open.is_some() { + if key == ESCAPE { + // Nothing to undo: every change is already at the clip, and + // undo is undo's own key. + self.eq_open = None; + self.eq_dragging = false; + } else if key == "up" { + self.nudge_band(|b| b.gain_db += EQ_STEP, cx); + } else if key == "down" { + self.nudge_band(|b| b.gain_db -= EQ_STEP, cx); + } else if key == "left" && shift { + self.nudge_band(|b| b.q /= EQ_Q_STEP, cx); + } else if key == "right" && shift { + self.nudge_band(|b| b.q *= EQ_Q_STEP, cx); + } else if key == "left" { + self.nudge_band(|b| b.freq_hz /= EQ_FREQ_STEP, cx); + } else if key == "right" { + self.nudge_band(|b| b.freq_hz *= EQ_FREQ_STEP, cx); + } else if key == "r" { + for band in &mut self.eq_params.bands { + band.gain_db = 0.; + } + self.commit_eq(cx); + } else if key == "f" { + // This one band back to flat, which is the undo of one hand + // movement -- `r` is the undo of the whole card. + self.nudge_band(|b| b.gain_db = 0., cx); + } else if key == "a" { + self.add_band(cx); + } else if key == "x" { + self.remove_band(cx); + } else if key == "s" { + // The analyser off and on. Nothing is committed: it is what + // the card *shows*, so it survives no further than this + // window. + self.eq_spectrum = !self.eq_spectrum; + } else if let Ok(digit) = key.parse::() { + // As the keys are laid out: 1-9 then 0 for the tenth, which + // is the cap ([`EQ_BANDS_MAX`]). A digit past the last band + // picks nothing rather than panics. + let band = match digit { + 0 => EQ_BANDS_MAX - 1, + n => n - 1, + }; + if band < self.eq_params.bands.len() { + self.eq_band = band; + } + } + return true; + } + // The colour card owns the keyboard the same way the export card + // does, and its keys mean nothing outside it: the arrows pick a + // slider and move it, and `r` takes the grade off. Not keymap + // bindings for exactly that reason -- see `FIXED`, where the keys + // menu still lists them. + if self.color_open.is_some() { + match color_key(key) { + Some(ColorKey::Close) => { + self.color_open = None; + self.color_dragging = false; + } + Some(ColorKey::Band(step)) => { + self.color_band = (self.color_band + step) % COLOR_BANDS.len(); + } + Some(ColorKey::Nudge(steps)) => self.nudge_color(steps, cx), + Some(ColorKey::Reset) => { + self.set_color(ColorParams::default(), cx); + } + None => {} + } + return true; + } + // The transform card, the same way again: the arrows pick a slider + // and move it, and `r` puts the placement back to identity. + // Card-local, [`ActionId::Color`]'s own reason (see `FIXED`, where + // the keys menu still lists them). + if self.transform_open.is_some() { + let n = TRANSFORM_BANDS.len(); + if key == ESCAPE { + self.transform_open = None; + self.transform_dragging = false; + } else if key == "down" { + self.transform_band = (self.transform_band + 1) % n; + } else if key == "up" { + self.transform_band = (self.transform_band + n - 1) % n; + } else if key == "right" { + self.nudge_transform(1., cx); + } else if key == "left" { + self.nudge_transform(-1., cx); + } else if key == "r" { + self.set_transform(TransformParams::default(), cx); + } + return true; + } + // The speed card, the same way again: its arrows move the rate and + // `r` puts it back to real time, and neither means anything outside + // the card -- so neither is a binding (see `FIXED`, where the keys + // menu still lists them). + if self.speed_open.is_some() { + match color_key(key) { + Some(ColorKey::Close) => { + self.speed_open = None; + self.speed_dragging = false; + } + // The card has one value, so the pair that picks a slider on + // the colour card moves this one by a whole preset's worth + // instead of a step. + Some(ColorKey::Band(step)) => self.nudge_speed(if step == 1 { -2 } else { 2 }, cx), + Some(ColorKey::Nudge(steps)) => self.nudge_speed(steps as i32, cx), + Some(ColorKey::Reset) => self.set_speed(Speed::NORMAL, cx), + None => {} + } + return true; + } + // The silence card, the same way again: the arrows pick one of its + // rows and move it, and its two apply keys are the two things it can + // do to the timeline. Card-local, every one of them -- and listed in + // the keys menu (keymap.rs `FIXED`), because a key that cuts forty + // places at once is not a secret. + if self.silence_open.is_some() { + if key == ESCAPE { + // Nothing to undo: a preview is not an edit. + self.close_silence(); + } else if key == "down" { + self.silence_field = (self.silence_field + 1) % SILENCE_ROWS; + } else if key == "up" { + self.silence_field = (self.silence_field + SILENCE_ROWS - 1) % SILENCE_ROWS; + } else if key == "right" { + self.nudge_silence(1); + } else if key == "left" { + self.nudge_silence(-1); + } else if key == "enter" { + self.cut_silences(cx); + } else if key == "f" { + self.speed_silences(cx); + } + return true; + } + // The mix card, the same way again: up/down pick a row -- a track's + // fader, the limiter's ceiling or its switch -- and left/right move + // it, held or pressed. Card-local like the four above it. + if self.mix_open { + let rows = self.mix_lanes().len() + MIX_MASTER_ROWS; + if key == ESCAPE { + self.mix_open = false; + } else if key == "down" { + self.mix_field = (self.mix_field + 1) % rows; + } else if key == "up" { + self.mix_field = (self.mix_field + rows - 1) % rows; + } else if key == "right" { + self.nudge_mix(1, cx); + } else if key == "left" { + self.nudge_mix(-1, cx); + } + return true; + } + // The subtitle style card, the same way again: row 0 is the size + // stepper (left/right moves it, held or pressed, the mix card's + // rule) and every row after it a family in `subtitle_fonts` -- + // up/down walk the whole list and `enter` picks the one the arrows + // are on, since a hand with no mouse still has to be able to leave + // the platform default. + if self.subtitle_style_open { + // Row 0 is the size stepper, row 1 the platform default, and + // every row after it a family in `subtitle_fonts`. + let rows = 2 + self.subtitle_fonts.len(); + if key == ESCAPE { + self.subtitle_style_open = false; + } else if key == "down" { + self.subtitle_style_field = (self.subtitle_style_field + 1) % rows; + } else if key == "up" { + self.subtitle_style_field = (self.subtitle_style_field + rows - 1) % rows; + } else if key == "right" { + self.nudge_sub_size(1, cx); + } else if key == "left" { + self.nudge_sub_size(-1, cx); + } else if key == "enter" && self.subtitle_style_field == 1 { + self.set_sub_family(None, cx); + } else if key == "enter" && self.subtitle_style_field > 1 { + let family = self.subtitle_fonts[self.subtitle_style_field - 2].clone(); + self.set_sub_family(Some(family), cx); + } + return true; + } + false + } } diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index d145343..79d791d 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -484,207 +484,11 @@ impl Render for Player { cx.notify(); return; } - // And the equalizer card, the same way again. Its own strokes - // are the card's input, exactly as the export card's digits - // are: a band reachable only by dragging is a band a keyboard - // cannot move at all, and every one of them is listed in the - // keys menu (keymap.rs `FIXED`) rather than being a secret. - if this.eq_open.is_some() { - // Shift makes the two horizontal keys Q instead of - // frequency: both are the *width* of the same hump, so they - // sit on the same axis rather than on two keys nobody would - // guess. Wider is a lower Q, which is why left widens. - let shift = event.keystroke.modifiers.shift; - if key == ESCAPE { - // Nothing to undo: every change is already at the clip, - // and undo is undo's own key. - this.eq_open = None; - this.eq_dragging = false; - } else if key == "up" { - this.nudge_band(|b| b.gain_db += EQ_STEP, cx); - } else if key == "down" { - this.nudge_band(|b| b.gain_db -= EQ_STEP, cx); - } else if key == "left" && shift { - this.nudge_band(|b| b.q /= EQ_Q_STEP, cx); - } else if key == "right" && shift { - this.nudge_band(|b| b.q *= EQ_Q_STEP, cx); - } else if key == "left" { - this.nudge_band(|b| b.freq_hz /= EQ_FREQ_STEP, cx); - } else if key == "right" { - this.nudge_band(|b| b.freq_hz *= EQ_FREQ_STEP, cx); - } else if key == "r" { - for band in &mut this.eq_params.bands { - band.gain_db = 0.; - } - this.commit_eq(cx); - } else if key == "f" { - // This one band back to flat, which is the undo of one - // hand movement -- `r` is the undo of the whole card. - this.nudge_band(|b| b.gain_db = 0., cx); - } else if key == "a" { - this.add_band(cx); - } else if key == "x" { - this.remove_band(cx); - } else if key == "s" { - // The analyser off and on. Nothing is committed: it is - // what the card *shows*, so it survives no further than - // this window. - this.eq_spectrum = !this.eq_spectrum; - } else if let Ok(digit) = key.parse::() { - // As the keys are laid out: 1-9 then 0 for the tenth, - // which is the cap ([`EQ_BANDS_MAX`]). A digit past the - // last band picks nothing rather than panics. - let band = match digit { - 0 => EQ_BANDS_MAX - 1, - n => n - 1, - }; - if band < this.eq_params.bands.len() { - this.eq_band = band; - } - } - cx.notify(); - return; - } - // The colour card owns the keyboard the same way the export - // card does, and its keys mean nothing outside it: the arrows - // pick a slider and move it, and `r` takes the grade off. Not - // keymap bindings for exactly that reason -- see `FIXED`, where - // the keys menu still lists them. - if this.color_open.is_some() { - match color_key(key) { - Some(ColorKey::Close) => { - this.color_open = None; - this.color_dragging = false; - } - Some(ColorKey::Band(step)) => { - this.color_band = (this.color_band + step) % COLOR_BANDS.len(); - } - Some(ColorKey::Nudge(steps)) => this.nudge_color(steps, cx), - Some(ColorKey::Reset) => { - this.set_color(ColorParams::default(), cx); - } - None => {} - } - cx.notify(); - return; - } - // The transform card, the same way again: the arrows pick a - // slider and move it, and `r` puts the placement back to - // identity. Card-local, [`ActionId::Color`]'s own reason (see - // `FIXED`, where the keys menu still lists them). - if this.transform_open.is_some() { - let n = TRANSFORM_BANDS.len(); - if key == ESCAPE { - this.transform_open = None; - this.transform_dragging = false; - } else if key == "down" { - this.transform_band = (this.transform_band + 1) % n; - } else if key == "up" { - this.transform_band = (this.transform_band + n - 1) % n; - } else if key == "right" { - this.nudge_transform(1., cx); - } else if key == "left" { - this.nudge_transform(-1., cx); - } else if key == "r" { - this.set_transform(TransformParams::default(), cx); - } - cx.notify(); - return; - } - // The speed card, the same way again: its arrows move the rate - // and `r` puts it back to real time, and neither means anything - // outside the card -- so neither is a binding (see `FIXED`, - // where the keys menu still lists them). - if this.speed_open.is_some() { - match color_key(key) { - Some(ColorKey::Close) => { - this.speed_open = None; - this.speed_dragging = false; - } - // The card has one value, so the pair that picks a - // slider on the colour card moves this one by a whole - // preset's worth instead of a step. - Some(ColorKey::Band(step)) => { - this.nudge_speed(if step == 1 { -2 } else { 2 }, cx) - } - Some(ColorKey::Nudge(steps)) => this.nudge_speed(steps as i32, cx), - Some(ColorKey::Reset) => this.set_speed(Speed::NORMAL, cx), - None => {} - } - cx.notify(); - return; - } - // The silence card, the same way again: the arrows pick one of - // its rows and move it, and its two apply keys are the two - // things it can do to the timeline. Card-local, every one of - // them -- and listed in the keys menu (keymap.rs `FIXED`), - // because a key that cuts forty places at once is not a secret. - if this.silence_open.is_some() { - if key == ESCAPE { - // Nothing to undo: a preview is not an edit. - this.close_silence(); - } else if key == "down" { - this.silence_field = (this.silence_field + 1) % SILENCE_ROWS; - } else if key == "up" { - this.silence_field = (this.silence_field + SILENCE_ROWS - 1) % SILENCE_ROWS; - } else if key == "right" { - this.nudge_silence(1); - } else if key == "left" { - this.nudge_silence(-1); - } else if key == "enter" { - this.cut_silences(cx); - } else if key == "f" { - this.speed_silences(cx); - } - cx.notify(); - return; - } - // The mix card, the same way again: ↑↓ pick a row -- a track's - // fader, the limiter's ceiling or its switch -- and ←→ move it, - // held or pressed. Card-local like the four above it. - if this.mix_open { - let rows = this.mix_lanes().len() + MIX_MASTER_ROWS; - if key == ESCAPE { - this.mix_open = false; - } else if key == "down" { - this.mix_field = (this.mix_field + 1) % rows; - } else if key == "up" { - this.mix_field = (this.mix_field + rows - 1) % rows; - } else if key == "right" { - this.nudge_mix(1, cx); - } else if key == "left" { - this.nudge_mix(-1, cx); - } - cx.notify(); - return; - } - // The subtitle style card, the same way again: row 0 is the - // size stepper (←→ moves it, held or pressed, the mix card's - // rule) and every row after it a family in - // `subtitle_fonts` -- ↑↓ walk the whole list and `enter` - // picks the one the arrows are on, since a hand with no - // mouse still has to be able to leave the platform default. - if this.subtitle_style_open { - // Row 0 is the size stepper, row 1 the platform default, - // and every row after it a family in `subtitle_fonts`. - let rows = 2 + this.subtitle_fonts.len(); - if key == ESCAPE { - this.subtitle_style_open = false; - } else if key == "down" { - this.subtitle_style_field = (this.subtitle_style_field + 1) % rows; - } else if key == "up" { - this.subtitle_style_field = - (this.subtitle_style_field + rows - 1) % rows; - } else if key == "right" { - this.nudge_sub_size(1, cx); - } else if key == "left" { - this.nudge_sub_size(-1, cx); - } else if key == "enter" && this.subtitle_style_field == 1 { - this.set_sub_family(None, cx); - } else if key == "enter" && this.subtitle_style_field > 1 { - let family = this.subtitle_fonts[this.subtitle_style_field - 2].clone(); - this.set_sub_family(Some(family), cx); - } + // Every param card's own key branch, factored into + // `Player::param_card_key` (`player/cards.rs`) so this tree and + // the darkroom stance drive the same logic rather than a + // second, divergent copy. + if this.param_card_key(key, event.keystroke.modifiers.shift, cx) { cx.notify(); return; } diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index 61c782d..2d26a75 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -36,6 +36,64 @@ fn no_overlaid_state_in_the_stance_goes_modal_without_painting_something() { } } +#[test] +fn every_modal_field_has_a_mounted_surface_somewhere_in_the_darkroom() { + // Every field/method `Player::modal()` reads, pulled from its own body + // rather than hand-copied -- a hand-copied list is exactly the shape + // that let three cards go modal with nothing mounted (GAP 2): the field + // was in `modal()` and nowhere in this test. + let modal_body = fn_body("modal"); + let mut fields = Vec::new(); + for chunk in modal_body.split("self.").skip(1) { + let name: String = chunk + .chars() + .take_while(|c| c.is_alphanumeric() || *c == '_') + .collect(); + if !name.is_empty() && !fields.contains(&name) { + fields.push(name); + } + } + assert!(fields.len() >= 9, "modal()'s own field list looks too short to have been parsed: {fields:?}"); + // The mounted-surface function each field's own card draws, by the + // convention the param cards already follow (`x_open` -> `x_card(` -- + // `Player::eq_card`/`color_card`/... in `ui/cards.rs`). `keys_open` and + // `export_open`/`exporting` don't follow that convention (the keys + // overlay isn't a "card", export pairs with the running-export sheet), + // so they're named explicitly. Anything else unmapped panics loudly -- + // the point is that a ninth card has to earn a line here, not just a + // mount, or this test cannot see it. + let mount_for = |field: &str| -> &'static str { + match field { + "keys_open" => "keys_overlay(", + "export_open" => "export_card(", + "exporting" => "export_progress_card(", + "eq_open" => "eq_card(", + "color_open" => "color_card(", + "transform_open" => "transform_card(", + "speed_open" => "speed_card(", + "silence_open" => "silence_card(", + "mix_open" => "mix_card(", + "subtitle_style_open" => "subtitle_style_card(", + other => panic!( + "Player::modal() now reads `self.{other}` with no entry in this test's \ + mount_for map -- add one naming the function that mounts its surface in \ + the darkroom (ui/stance.rs or ui/dock_stance.rs), or the room can go modal \ + over it with nothing drawn (the silence/mix/subtitle-style bug, GAP 2)." + ), + } + }; + let haystack = format!("{}\n{}", src_text("ui/stance.rs"), src_text("ui/dock_stance.rs")); + for field in &fields { + let mount = mount_for(field); + assert!( + haystack.contains(mount), + "Player::modal()'s `self.{field}` makes overlaid() true, but the darkroom never \ + mounts `{mount}` in ui/stance.rs or ui/dock_stance.rs -- pressing its key opens \ + an invisible modal (GAP 2)." + ); + } +} + #[test] fn a_bare_escape_leaves_player_fullscreen_before_anything_under_it() { // Fires while the picture-only layout is up, on the same bare escape diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index 6a6f617..ce21947 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -233,6 +233,18 @@ fn clip_box( this.pick((lane, idx), event.modifiers.control, cx); }), ) + // The right button selects exactly as the left one does -- the menu + // acts on the clip it names -- then hangs the clip menu at the + // pointer (DESIGN §9's "verbs of the thing under the cursor"). Same + // call and same surface the legacy timeline's clip box opens + // (`ui/timeline.rs`'s `Player::open_menu`; the card itself is + // `context_card`, already mounted at `stance.rs:695`). + .on_mouse_down( + MouseButton::Right, + cx.listener(move |this, event: &MouseDownEvent, _, cx| { + this.open_menu(lane, idx, event.position, cx); + }), + ) // Dragged, it moves: to the frame and the lane it is let go over // (`Player::move_clip`, `ClipDrag`) -- the same payload and the same // ghost tooltip `ui/timeline.rs`'s own clip box drags. @@ -263,6 +275,15 @@ fn clip_box( cx.listener(move |this, event: &MouseDownEvent, _, cx| { this.start_trim(lane, idx, edge, event.modifiers.control, cx); }), + ) + // Occluded, so the box's own right-button listener + // never fires here: the same menu, opened by the same + // call, exactly as the legacy clip's edge strip does. + .on_mouse_down( + MouseButton::Right, + cx.listener(move |this, event: &MouseDownEvent, _, cx| { + this.open_menu(lane, idx, event.position, cx); + }), ); zone = match edge { Edge::Start => zone.left_0(), @@ -385,6 +406,129 @@ fn clip_box( ) } +/// A placed caption's box, on a subtitle lane: [`clip_box`]'s twin, minus the +/// thumbnail/waveform trace a caption has none of (DESIGN §6 -- "the subtitle +/// cue edge IS a cut", so the same selection ring, drag, edge-trim and +/// right-click menu a clip gets apply here too). Reused rather than +/// reimplemented: `Player::trimmed_sub`/`SubDrag`/`sub_pick_name`/`cue_box`, +/// the same plumbing `ui/timeline.rs`'s own caption box already drives. +fn sub_box( + player: &Player, + lane: Lane, + idx: usize, + sub: &SubClip, + scale: Scale, + picks: &[(Lane, usize)], + pick_links: &[Option], + cx: &mut Context, +) -> impl IntoElement + use<> { + let placed = *sub; + let shown = player.trimmed_sub(lane, idx, placed); + let (start, len) = ( + f64::from(shown.start) / player.fps, + f64::from(shown.frames) / player.fps, + ); + let span = scale.width_px(len); + let width = clip_width(span); + let left = scale.px_at(start); + let on = marked((lane, idx), placed.link, picks, pick_links); + // Where in this window the track's own cues actually fall + // (`PlaybackSession::sub_lane_cues`, the same map the export and the + // picture's own plate go through). + let cues: Vec<(f32, f32)> = player.session.as_ref().map_or_else(Vec::new, |s| { + s.sub_lane_cues(lane).iter().map(|cue| cue_box(scale, cue)).collect() + }); + let label = player + .session + .as_ref() + .and_then(|s| sub_pick_name(s.subtitles(), placed.track)); + let ghost: SharedString = label.unwrap_or_else(|| lane.label()).into(); + div() + .id(("bench-sub", lane.ord * 1000 + idx)) + .absolute() + .top_0() + .h_full() + .left(px(left)) + .w(px(width)) + .overflow_hidden() + .rounded(px(0.)) + .bg(rgb(DARK_PANEL())) + .when(on, |d| d.border_1().border_color(rgb(INK1()))) + .cursor_pointer() + .on_mouse_down( + MouseButton::Left, + cx.listener(move |this, event: &MouseDownEvent, _, cx| { + this.pick((lane, idx), event.modifiers.control, cx); + }), + ) + // Same door a clip's box opens its menu by (DESIGN §9). + .on_mouse_down( + MouseButton::Right, + cx.listener(move |this, event: &MouseDownEvent, _, cx| { + this.open_menu(lane, idx, event.position, cx); + }), + ) + .on_drag(SubDrag { lane, idx, sub: placed }, { + let ghost = ghost.clone(); + move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) + }) + // The same edge-trim strips a clip gets, on the same [`trims`] floor. + .children( + [Edge::Start, Edge::End] + .into_iter() + .filter(|_| trims(span)) + .map(|edge| { + let mut zone = div() + .absolute() + .top_0() + .h_full() + .w(px(EDGE_W)) + .occlude() + .cursor(CursorStyle::ResizeLeftRight) + .hover(|s| s.bg(rgb(INK1()))) + .on_mouse_down( + MouseButton::Left, + cx.listener(move |this, event: &MouseDownEvent, _, cx| { + this.start_trim(lane, idx, edge, event.modifiers.control, cx); + }), + ) + .on_mouse_down( + MouseButton::Right, + cx.listener(move |this, event: &MouseDownEvent, _, cx| { + this.open_menu(lane, idx, event.position, cx); + }), + ); + zone = match edge { + Edge::Start => zone.left_0(), + Edge::End => zone.right_0(), + }; + zone + }), + ) + // The cues themselves: where in this window the track's words fall, + // each its own full-height block over the letterbox ground -- a + // placement is a window of a track, not full of speech. + .children(cues.into_iter().map(|(cl, cw)| { + div() + .absolute() + .top(px(1.)) + .bottom(px(1.)) + .left(px(cl)) + .w(px(cw)) + .rounded(px(0.)) + .bg(rgb(CLIP_TEXT())) + })) + .child( + div() + .absolute() + .top_0() + .right_0() + .h_full() + .w(px(1.)) + .bg(rgb(LAMP_WHITE())), + ) +} + /// One lane row: pinned head + bed of clips, DESIGN §5's "lanes V/A/S", drawn /// at the compressed height [`row_h`] gives it. fn lane_row( @@ -406,6 +550,20 @@ fn lane_row( .enumerate() .map(|(idx, clip)| clip_box(player, lane, idx, clip, scale, picks, pick_links, cx)) .collect(); + // The bed's other kind of box: a subtitle lane holds no `Clip` at all + // (`LaneKind::Subtitle`'s own doc), so this is empty everywhere but S1.. + // and `boxes` above is empty on a subtitle lane -- one row draws whichever + // list it was given. + let subs: Vec = player + .session + .as_ref() + .map_or(&[][..], |s| s.sub_lane(lane)) + .to_vec(); + let sub_boxes: Vec<_> = subs + .iter() + .enumerate() + .map(|(idx, sub)| sub_box(player, lane, idx, sub, scale, picks, pick_links, cx)) + .collect(); // DESIGN §5's lane heads: "a small ink dot under each head, coloured by // the lane's source ink" -- the first clip's source stands for the lane, // since a lane with several sources still needs one dot, not a legend. @@ -478,6 +636,13 @@ fn lane_row( }; this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) })) + // A caption already on a lane moves along it, or onto another + // subtitle track, exactly as a clip does (`Player::move_sub`, + // the same call `ui/timeline.rs`'s own bed makes). + .drag_over::(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) + .on_drop(cx.listener(move |this, drag: &SubDrag, window, cx| { + this.move_sub(drag, lane, window.mouse_position().x, cx); + })) // The wheel, matched to the legacy timeline's own mapping: // ctrl+wheel zooms about the pointer, a bare wheel scrolls // the bed along the film (`Player::timeline_wheel`). Stopped @@ -487,7 +652,8 @@ fn lane_row( cx.stop_propagation(); this.timeline_wheel(event, cx); })) - .children(boxes), + .children(boxes) + .children(sub_boxes), ) } diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index d7f81df..bcdd747 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -510,7 +510,10 @@ fn clip_tab(player: &Player, width: f32, window_h: Pixels, cx: &mut Context impl IntoElement { /// §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. +/// `quiet` demotes a row a whole ink step (DESIGN §2's ink-demotion rule, +/// applied per this task's charter to the once-a-session/once-a-project +/// acts -- theme, proxies, screenshot, fullscreen -- rather than to a +/// re-inking gesture): glyph reads `ink3` instead of `ink2`, its chord +/// `ink4` instead of `ink3`, so the ROOM group sits visibly quieter than +/// the burst-use groups above it without a second widget shape. fn glyph( id: &'static str, glyph: &'static str, action: ActionId, active: bool, + quiet: bool, player: &Player, cx: &mut Context, ) -> impl IntoElement + use<> { @@ -82,7 +89,13 @@ fn glyph( // FAULT 1: the glyph is the loudest thing in its row -- BOLD, // not the MEDIUM weight the chord beneath it also wears. .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::BOLD)) - .text_color(rgb(if active { INK1() } else { INK2() })) + .text_color(rgb(if active { + INK1() + } else if quiet { + INK3() + } else { + INK2() + })) .child(glyph), ) .child( @@ -92,7 +105,7 @@ fn glyph( type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM, )) - .text_color(rgb(INK3())) + .text_color(rgb(if quiet { INK4() } else { INK3() })) .child(compact), ) } @@ -209,13 +222,13 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem .gap(px(1.)) .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(glyph("spine-split", "||", ActionId::Cut, false, false, player, cx)) + .child(glyph("spine-delete", "⊂⊃", ActionId::Delete, false, false, player, cx)) + .child(glyph("spine-undo", "↺", ActionId::Undo, false, 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), + glyph("spine-cut-prev", "‹", ActionId::WalkCutPrev, false, false, player, cx), + glyph("spine-cut-next", "›", ActionId::WalkCutNext, false, false, player, cx), )) .child(trim_control(player.loop_trim.is_some(), player, cx)) .child(glyph( @@ -223,6 +236,21 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem "↻", ActionId::LoopTrim, player.loop_trim.is_some(), + false, + player, + cx, + )) + // ToggleSnap (homeless per this task's audit): editing-adjacent -- + // it decides where a drag lands (keymap.rs's own category puts it + // under Editing, not View) -- so it earns the CUT group beside the + // trim/loop-trim it changes the feel of, not the quiet ROOM cluster + // below. Active fill mirrors loop-trim's own on/off convention. + .child(glyph( + "spine-toggle-snap", + "Sn", + ActionId::ToggleSnap, + player.snap, + false, player, cx, )) @@ -236,12 +264,53 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem // less than walking/trimming cuts above it. .child(group_head("view")) .child(pair( - glyph("spine-zoom-out", "−", ActionId::ZoomOut, false, player, cx), - glyph("spine-zoom-in", "+", ActionId::ZoomIn, false, player, cx), + glyph("spine-zoom-out", "−", ActionId::ZoomOut, false, false, player, cx), + glyph("spine-zoom-in", "+", ActionId::ZoomIn, false, false, player, cx), )) - .child(glyph("spine-zoom-fit", "⊡", ActionId::ZoomFit, false, player, cx)) + .child(glyph("spine-zoom-fit", "⊡", ActionId::ZoomFit, false, false, 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(glyph("spine-add-video", "+V", ActionId::AddVideoLane, false, false, player, cx)) + .child(glyph("spine-add-audio", "+A", ActionId::AddAudioLane, false, false, player, cx)) + // The subtitle trio (homeless per this task's audit): AddSubtitleLane + // joins +V/+A on the same "+letter" grammar per this task's own + // instruction ("+S joins +V/+A in TRACK"); remove/import are "the + // subtitle work" the instruction says to place them beside, so they + // share the row underneath rather than each eating a full row (the + // same space-saving `pair` the walk-cuts and zoom in/out already + // use). ToggleSubtitles (whether the cues draw over the picture at + // all) is the fourth subtitle-lane command with no home anywhere in + // the darkroom -- filed here too, "CC" being the glyph every player + // already uses for exactly this toggle, rather than in the quiet + // ROOM cluster below: cue visibility is judged shot to shot, closer + // in frequency to a view toggle used often than to a once-a-session + // preference. + .child(glyph("spine-add-subtitle", "+S", ActionId::AddSubtitleLane, false, false, player, cx)) + .child(pair( + glyph("spine-remove-subtitle", "−S", ActionId::RemoveSubtitleLane, false, false, player, cx), + glyph("spine-import-subtitles", "↓S", ActionId::ImportSubtitles, false, false, player, cx), + )) + .child(glyph("spine-toggle-subtitles", "CC", ActionId::ToggleSubtitles, player.subs_on, false, player, cx)) + // ROOM: the once-a-session/once-a-project acts this task's charter + // names explicitly (theme, proxies, screenshot, fullscreen) -- ink- + // demoted (`quiet: true`) and paired two-to-a-row to keep the group + // cheap, the same "rare acts live out of the way" pattern DESIGN §2 + // names for re-inking, applied here to the spine's own bottom + // instead of a right-click menu (these four are toggled/fired by a + // click, not by picking a source dot, so a context menu is not + // their shape). Left off this list: Save, which sits beside Export + // in the time band instead (see timeband_stance.rs) because the + // ledger already gives the saved/unsaved state a home there, and + // keymap.rs's own `Category::File` files Save beside Export and + // Screenshot on the strength of what each one writes. + .child(group_head("room")) + .child(pair( + glyph("spine-theme", "H", ActionId::Theme, false, true, player, cx), + glyph("spine-proxies", "P", ActionId::ToggleProxies, player.proxies_on, true, player, cx), + )) + .child(pair( + glyph("spine-auto-proxies", "AP", ActionId::ToggleAutoProxies, player.auto_proxies_on, true, player, cx), + glyph("spine-fullscreen", "FS", ActionId::Fullscreen, false, true, player, cx), + )) + .child(glyph("spine-screenshot", "Sh", ActionId::Screenshot, false, true, player, cx)) .child(div().flex_1()) } diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 6d6d650..f036dc6 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -600,6 +600,18 @@ pub(crate) fn render( cx.notify(); return; } + // The param cards' own key branches (arrows nudge the focused + // slider, digits pick an EQ band, `r` resets, card verbs) -- + // `Player::param_card_key` (`player/cards.rs`), the same + // function `render.rs`'s legacy handler now calls too, so this + // is not a second copy of that logic (DESIGN §6: "drag while + // playing... `r` resets"). Asked before the generic modal guard + // below so a card open in the darkroom is not just a key-eating + // black box the way the old uniform guard made it. + if this.param_card_key(key, event.keystroke.modifiers.shift, cx) { + cx.notify(); + return; + } // Same modal guard the legacy handler's rebinding/keys_open/ // export_open/exporting/colour/transform/speed/EQ/silence/mix/ // subtitle-style/menu chain (`render.rs`) amounts to, read as diff --git a/crates/app/src/ui/timeband_stance.rs b/crates/app/src/ui/timeband_stance.rs index 241bd68..dbf448d 100644 --- a/crates/app/src/ui/timeband_stance.rs +++ b/crates/app/src/ui/timeband_stance.rs @@ -45,7 +45,19 @@ thread_local! { /// `action` through [`Player::act`] the same way `stance::ghost` (spine) and /// `spine_stance`'s own ghost already do, `id` making the three transport /// ghosts distinct elements gpui can track. -fn ghost(id: &'static str, player: &Player, glyph: &str, action: ActionId, cx: &mut Context) -> impl IntoElement { +/// `active` (added alongside the volume/loop cluster this task adds) tints +/// the glyph `ink1` instead of `ink2` -- the same on/off convention +/// `spine_stance::glyph` already uses for loop-trim -- so a toggle sitting +/// in this band (`Loop`, `ToggleMute`) can show its own state without a +/// second widget shape. +fn ghost( + id: &'static str, + player: &Player, + glyph: impl Into, + action: ActionId, + active: bool, + cx: &mut Context, +) -> impl IntoElement { let glyph_style = label(type_scale::HERO_TIMECODE_PX, FontWeight::MEDIUM); // The chord names a key, so DESIGN §3's mono rule ("if a string is about // ... a key, it is mono") applies here same as everywhere else in the band. @@ -63,8 +75,8 @@ fn ghost(id: &'static str, player: &Player, glyph: &str, action: ActionId, cx: & })) .font(glyph_style.font) .text_size(glyph_style.size) - .text_color(rgb(INK2())) - .child(glyph.to_string()) + .text_color(rgb(if active { INK1() } else { INK2() })) + .child(glyph.into()) .child( div() .font(chord_style.font) @@ -504,6 +516,7 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context) -> impl IntoElement { + let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); + let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); + div() + .id("stance-tb-save") + .flex_none() + .flex() + .items_center() + .gap(px(4.)) + .cursor_pointer() + .hover(|s| s.text_color(rgb(INK1()))) + .text_color(rgb(INK2())) + .on_click(cx.listener(|this, _: &ClickEvent, window, cx| { + this.act(ActionId::Save, window, cx); + })) + .child( + div() + .font(label_style.font) + .text_size(label_style.size) + .child("Save"), + ) + .child( + div() + .font(chord_style.font) + .text_size(chord_style.size) + .text_color(rgb(INK3())) + .child(player.keymap.chord(ActionId::Save)), + ) +}