diff --git a/crates/app/src/keymap.rs b/crates/app/src/keymap.rs index 9ebd283..9f78e50 100644 --- a/crates/app/src/keymap.rs +++ b/crates/app/src/keymap.rs @@ -973,7 +973,12 @@ impl Keymap { b(ActionId::Save, "s", true), b(ActionId::Copy, "c", true), b(ActionId::Paste, "v", true), - b(ActionId::Cut, "c", false), + // Split, on the bare letter DESIGN.md §6 names for it: the + // burst-use command owns the cheap key (§11's frequency + // argument). Bare "c" moves to AddSubtitleLane below, which + // frees up cleanly since a subtitle track also opens on its + // own initial: captions. + b(ActionId::Cut, "s", false), // The two lane keys, on the letters they are named after: both // were free, and neither is next to a key that edits. b(ActionId::Regroup, "g", false), @@ -1005,8 +1010,9 @@ impl Keymap { b(ActionId::Delete, "x", false), b(ActionId::Delete, "delete", false), b(ActionId::Lift, "l", false), - // The c of colour is Cut and ctrl+c is Copy, so the grade takes - // k: free, next to nothing that edits, and one press like the + // The c of colour is now AddSubtitleLane's (captions) and + // ctrl+c is Copy, so the grade takes k: free, next to nothing + // that edits, and one press like the // rest of the clip keys. b(ActionId::Color, "k", false), // The placement card takes the ctrl chord of the grade's own @@ -1048,12 +1054,13 @@ impl Keymap { // takes the free key beside its own letter: "a" neighbours // "q" on the row, and ctrl+q was taken by nothing. b(ActionId::RemoveAudioLane, "q", true), - // The subtitle pair reads the same way: the unshifted initial - // adds one -- "s" is free, the save is the *ctrl* chord -- and a - // ctrl chord takes it back. Ctrl+s is that save, so the removal - // takes the other letter subtitles already answer to here: "t" - // shows and hides them, and ctrl+t takes one off the timeline. - b(ActionId::AddSubtitleLane, "s", false), + // The subtitle pair reads the same way, on a different letter + // now that bare "s" is split's (DESIGN.md §6): "c" is free + // once split moves off it, and it is still an initial the + // track answers to -- captions. The removal takes the other + // letter subtitles already answer to here: "t" shows and + // hides them, and ctrl+t takes one off the timeline. + b(ActionId::AddSubtitleLane, "c", false), b(ActionId::RemoveSubtitleLane, "t", true), // Reading a file's tracks into the palette is not adding a // track to the timeline, so it is not the bare "s": ctrl+i, the @@ -1453,7 +1460,7 @@ mod tests { assert_eq!(k.lookup("s", true), Some(ActionId::Save)); assert_eq!(k.lookup("c", true), Some(ActionId::Copy)); assert_eq!(k.lookup("v", true), Some(ActionId::Paste)); - assert_eq!(k.lookup("c", false), Some(ActionId::Cut)); + assert_eq!(k.lookup("s", false), Some(ActionId::Cut)); assert_eq!(k.lookup("g", false), Some(ActionId::Regroup)); // The take apart / put back pair beside it. assert_eq!(k.lookup("d", false), Some(ActionId::Detach)); @@ -1483,7 +1490,7 @@ mod tests { assert_eq!(k.lookup("a", true), Some(ActionId::SelectAll)); // The subtitle pair, the third kind of track: the initial adds and the // subtitle letter's chord takes it back. - assert_eq!(k.lookup("s", false), Some(ActionId::AddSubtitleLane)); + assert_eq!(k.lookup("c", false), Some(ActionId::AddSubtitleLane)); assert_eq!(k.lookup("t", true), Some(ActionId::RemoveSubtitleLane)); // ...and the palette's own door, which adds no track to the timeline. assert_eq!(k.lookup("i", true), Some(ActionId::ImportSubtitles)); diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 3291c8e..3990867 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -213,6 +213,12 @@ struct Player { /// filter box: the categories are what the media *is*, and every editor /// this one is measured against splits its pool the same way. library_tab: LibraryTab, + /// Which of the darkroom dock's Src/Clip tabs is showing (DESIGN §5). + /// `Player`-owned rather than the process-global static it used to be + /// (VIOLATION 3), and persisted the way `ui::theme`'s pick is + /// (`ui::dock_stance::load`/`save`) so "a room reopens exactly as left" + /// survives a quit and relaunch, not just this window. + pub(crate) dock_src_active: bool, /// What is known about each source's audio, taken once and kept. Keyed on /// the path *and stream* -- two streams of one file are two envelopes -- and /// the key is inserted the moment the decode is *started*: presence means @@ -860,6 +866,7 @@ fn main() { library_menu: None, selected_asset: None, library_tab: LibraryTab::Media, + dock_src_active: ui::dock_stance::load(), waves: HashMap::new(), proxies: HashMap::new(), streams: HashMap::new(), diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index e4b23d2..378d878 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -540,8 +540,13 @@ impl Player { /// Loop-trim (DESIGN.md §6, `/`): loops the transport around the subject /// cut's own span while `[`/`]` move its edges -- the modernized Avid - /// trim mode. Off again drops the window and leaves playback running, - /// exactly as it was found. + /// trim mode. Neither direction touches play/pause: off drops the window + /// and leaves playback exactly as it was found, and on arms the window + /// without forcing a play -- a forced `session.play()` here used to start + /// the clock as a side effect of arming, which left a paused transport + /// already playing when the user's own `space` arrived next; that press + /// then read as a toggle and paused it right back, pinned at the loop's + /// start frame. Space is what starts it, playing or not. pub(crate) fn toggle_loop_trim(&mut self, cx: &mut Context) { if self.loop_trim.take().is_some() { self.notify_user("LOOP-TRIM OFF".into()); @@ -554,9 +559,6 @@ impl Player { self.loop_trim = self.cut_span(lane, idx); if self.loop_trim.is_some() { self.notify_user("LOOP-TRIM ON — looping the subject cut while you trim".into()); - if let Some(session) = self.active_session_mut() { - session.play(); - } } cx.notify(); } diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index afe2bdb..b0c430b 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -2102,3 +2102,23 @@ fn should_loop_restart_only_at_the_windows_far_edge() { assert!(should_loop_restart(61, Some((30, 60))), "past it restarts too"); assert!(!should_loop_restart(60, None), "loop-trim off restarts nothing"); } + +/// The paused-then-started repro this predicate was blamed for and cleared +/// of: `should_loop_restart` takes no play/pause state at all, so resting +/// exactly at the window's far edge -- as a transport paused after playing +/// through the cut once, or paused right on arrival by a scrub -- reads +/// "restart" from the predicate alone regardless. The bug that froze a +/// paused-then-`space`d transport at the loop's start frame was not this: it +/// was `Player::toggle_loop_trim` forcing `session.play()` on arm, so the +/// user's own next `space` toggled straight back to paused. It is +/// `Player::pump`'s `session.is_playing()` guard around this call that must +/// hold a paused transport off the seek until playback actually starts. +#[test] +fn should_loop_restart_is_play_state_blind_the_pump_gates_it() { + use crate::timeline_math::should_loop_restart; + assert!( + should_loop_restart(60, Some((30, 60))), + "the predicate alone can't tell paused-at-the-edge from playing-\ + into-it -- that distinction is pump's is_playing() guard, not this" + ); +} diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index 1b98330..e9124b2 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -4,15 +4,34 @@ use crate::*; -/// corner-cut: which dock tab is showing lives in a module-level flag rather -/// than a `Player` field, because the stance's other regions (spine, screen, -/// time band) are being threaded onto `Player` by a second builder in this -/// same pass and a shared struct is not a safe place for two agents to land -/// fields at once. Ceiling: fold into a `Player::dock_tab` field once that -/// pass lands, so DESIGN §5's "a room reopens exactly as left ... dock tab" -/// continuity (session save/load) can reach it -- today the flag resets with -/// the process. -static DOCK_SRC_ACTIVE: AtomicBool = AtomicBool::new(true); +/// Where the dock tab pick lives: one word beside the theme and the +/// keybindings (`ui::theme::config_path`/`save`/`load` is the exact pattern +/// this follows -- a small, silent, config-file round trip is the mechanism +/// this editor already uses for a preference that outlives the window, and +/// the playhead's own continuity lives in the *project* file, which a dock +/// tab pick is not: it is not part of the timeline, so it does not belong in +/// a `.edith`). +pub(crate) fn config_path() -> std::path::PathBuf { + crate::keymap::Keymap::config_path().with_file_name("dock-tab") +} + +/// The pick from the last session, if there was one. Anything unreadable or +/// unknown leaves the default (`Src`) in force, exactly as a bad theme file +/// does -- neither is the user's work, so neither is worth a startup notice. +pub(crate) fn load() -> bool { + std::fs::read_to_string(config_path()) + .map(|text| text.trim() != "Clip") + .unwrap_or(true) +} + +/// Writes the pick. One word, written whole. +fn save(src_active: bool) { + let path = config_path(); + if let Some(dir) = path.parent() { + let _ = std::fs::create_dir_all(dir); + } + let _ = std::fs::write(path, if src_active { "Src\n" } else { "Clip\n" }); +} /// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in /// `ink3` beside it, read live off the keymap so it can never drift from the @@ -80,8 +99,9 @@ fn dock_tab(id: &'static str, label: &'static str, active: bool, cx: &mut Contex .when(active, |d| d.bg(rgb(DARK_RAISED()))) .cursor_pointer() .hover(|s| s.bg(rgb(DARK_RAISED()))) - .on_click(cx.listener(move |_this, _: &ClickEvent, _, cx| { - DOCK_SRC_ACTIVE.store(label == "Src", Ordering::Relaxed); + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + this.dock_src_active = label == "Src"; + save(this.dock_src_active); cx.notify(); })) .child(label) @@ -202,7 +222,7 @@ fn clip_tab(player: &Player, width: f32, window_h: Pixels, cx: &mut Context) -> impl IntoElement { - let src_active = DOCK_SRC_ACTIVE.load(Ordering::Relaxed); + let src_active = player.dock_src_active; div() .id("stance-dock-body") .flex_1() diff --git a/crates/app/src/ui/preview.rs b/crates/app/src/ui/preview.rs index 260a6d2..36bc8e4 100644 --- a/crates/app/src/ui/preview.rs +++ b/crates/app/src/ui/preview.rs @@ -310,12 +310,19 @@ impl Player { } } - /// Two-up OUT|IN judging (DESIGN.md §6): drawn over the screen only when - /// the playhead rests exactly on one edge of the subject cut -- the - /// outgoing clip's tail beside the incoming one's head, whichever edge - /// the playhead is on. `None` off a cut, off the darkroom path, or with - /// nothing marked, so the legacy picture and a mid-clip darkroom picture - /// both draw untouched. + /// Two-up OUT|IN judging (DESIGN.md §6): drawn *in* the screen, below the + /// picture, only when the playhead rests exactly on one edge of the + /// subject cut -- the outgoing clip's tail beside the incoming one's + /// head, whichever edge the playhead is on. `None` off a cut, off the + /// darkroom path, or with nothing marked, so the legacy picture and a + /// mid-clip darkroom picture both draw untouched. + /// + /// DESIGN §5 "never covered" / §11 check 6: this used to be an + /// `absolute()` plate pair over the bottom of the screen, blacking out + /// real picture pixels. The caller (`ui::stance::screen`) now lays this + /// out as a flex sibling *below* the picture instead of layering it on + /// top, so the picture's own `flex_1` shrinks to make room -- a + /// letterbox band, not an occlusion. /// /// corner-cut: each side names its neighbour (source, timecode) on a /// plate rather than decoding its edge frame into a second picture -- @@ -384,10 +391,12 @@ impl Player { }; Some( div() - .absolute() - .bottom_0() - .left_0() - .right_0() + .id("two-up") + .flex_none() + .w_full() + .bg(rgb(DARK_PANEL())) + .border_t_1() + .border_color(rgba(DARK_SEAM())) .flex() .gap(px(1.)) .p(px(8.)) diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 3e953ea..b3899ca 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -60,6 +60,82 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { ) } +/// A ghost command whose stride-10 sibling is the same command at a +/// different scale (DESIGN §4): one glyph, both chords shown beside each +/// other rather than a second glyph -- the cheap fix VIOLATION 1 asked for, +/// reusing the ghost grammar instead of a new widget. +fn ghost_dual(player: &Player, glyph: &str, action: ActionId, stride: ActionId) -> impl IntoElement { + div() + .flex_none() + .flex() + .flex_col() + .items_center() + .gap(px(2.)) + .py(px(6.)) + .rounded(px(3.)) + .text_size(px(13.)) + .text_color(rgb(INK2())) + .child(glyph.to_string()) + .child( + div() + .flex() + .gap(px(4.)) + .text_size(px(9.5)) + .text_color(rgb(INK3())) + .child(player.keymap.display(action)) + .child(player.keymap.display(stride)), + ) +} + +/// The keys overlay (DESIGN §9, §12 step 7): every bound command as one +/// chord-and-label row, plate-styled per §4 ("readouts are plates"), shown +/// while [`Player::keys_open`] is set (the same field/guard the legacy +/// modal already used -- `Player::show_actions` sets it, `Player::close_card` +/// clears it on `esc`, both already wired through the darkroom's key +/// handler below). +/// +/// corner-cut: DESIGN §9 wants chords surfaced *in place beside their +/// controls* across every region, dimming the room one fill step; this is +/// one list plate instead, anchored over the bench/ledger footprint so it +/// never reaches the screen. Ceiling: DESIGN §12 step 7's full geographic +/// pass (each region draws its own rows when `keys_open`). +fn keys_overlay(player: &Player) -> impl IntoElement { + div() + .id("stance-keys-overlay") + .absolute() + .bottom_0() + .left_0() + .right_0() + .h(px(BENCH_H + LEDGER_H)) + .bg(rgba(SCRIM())) + .flex() + .child( + div() + .m_auto() + .max_h(px(BENCH_H + LEDGER_H - 16.)) + .max_w(px(420.)) + .overflow_hidden() + .p(px(10.)) + .rounded(px(4.)) + .bg(rgb(DARK_PANEL())) + .border_1() + .border_color(rgba(DARK_SEAM())) + .flex() + .flex_col() + .gap(px(3.)) + .child(section_head("all commands · esc to close")) + .children(player.keymap.entries().iter().map(|b| { + div() + .flex() + .justify_between() + .gap(px(12.)) + .text_size(px(9.5)) + .child(div().text_color(rgb(INK2())).child(b.action.label())) + .child(div().text_color(rgb(INK3())).child(b.chord.pretty())) + })), + ) +} + /// The spine: 56px, left, full height. Every command as ghost glyph + chord, /// grouped by task frequency (DESIGN §5) -- transport first (every second), /// then the cut machinery (DESIGN §6, every cut), then the split and the one @@ -80,30 +156,44 @@ fn spine(player: &Player) -> impl IntoElement { .gap(px(4.)) .child(section_head("spine")) .child(ghost(player, "▶", ActionId::Play)) - .child(ghost(player, "‹", ActionId::WalkCutPrev)) - .child(ghost(player, "›", ActionId::WalkCutNext)) + .child(ghost_dual(player, "‹", ActionId::WalkCutPrev, ActionId::WalkCutPrev10)) + .child(ghost_dual(player, "›", ActionId::WalkCutNext, ActionId::WalkCutNext10)) + .child(ghost(player, "{", ActionId::SelectPrev)) + .child(ghost(player, "}", ActionId::SelectNext)) .child(ghost(player, "[", ActionId::TrimIn)) .child(ghost(player, "]", ActionId::TrimOut)) .child(ghost(player, "↻", ActionId::LoopTrim)) .child(ghost(player, "✂", ActionId::Cut)) + .child(ghost(player, "?", ActionId::ShowActions)) } /// The picture region: top of the centre column, takes the remaining space, -/// never occluded (DESIGN §5). Reuses [`Player::picture_area`] rather than a -/// second image element -- the darkroom draws the same picture the legacy -/// tree does -- and layers the two-up OUT|IN judging over it at rest on a -/// cut (DESIGN §6). +/// never occluded (DESIGN §5, §11 check 6). Reuses [`Player::picture_area`] +/// rather than a second image element -- the darkroom draws the same picture +/// the legacy tree does -- and, at rest on a cut, letterboxes it by stacking +/// the two-up OUT|IN judging *below* it as a flex sibling (DESIGN §6) rather +/// than layering plates over it: the picture's own `flex_1` shrinks to make +/// room, so every picture pixel that is drawn stays visible. fn screen(player: &mut Player, position: f64, window: &mut Window, cx: &mut Context) -> impl IntoElement { + let two_up = player.two_up().map(IntoElement::into_any_element); div() .id("stance-screen") .flex_1() .min_h(px(0.)) - .relative() + .flex() + .flex_col() // §4: room chrome takes 0 radius. .rounded(px(0.)) .bg(rgb(DARK_CANVAS())) - .child(player.picture_area(position, window, cx)) - .children(player.two_up()) + .child( + div() + .id("stance-picture") + .flex_1() + .min_h(px(0.)) + .relative() + .child(player.picture_area(position, window, cx)), + ) + .children(two_up) } /// Fixed-height strip under the screen: timecode leads, ghost transport, cut @@ -272,12 +362,12 @@ pub(crate) fn render( return; } if let Some(action) = this.keymap.lookup(key, ctrl) { - // hook: §12 step 7 -- the keys overlay and the export card - // (and the notice plates that would announce an export's - // progress) have no stance surface yet, so the two actions - // that only ever show up there are suppressed here rather - // than left to open a card nothing on screen can draw. - if matches!(action, ActionId::ShowActions | ActionId::Export) { + // hook: §12 step 7 -- the export card (and the notice plates + // that would announce an export's progress) has no stance + // surface yet, so it is suppressed here rather than left to + // open a card nothing on screen can draw. `ShowActions` now + // has one ([`keys_overlay`]) so it is no longer on this list. + if action == ActionId::Export { return; } this.act(action, window, cx); @@ -290,6 +380,7 @@ pub(crate) fn render( .child( div() .id("stance-centre") + .relative() .flex_1() .min_w(px(0.)) .flex() @@ -297,7 +388,8 @@ pub(crate) fn render( .child(screen(player, position, window, cx)) .child(time_band(player)) .child(bench(player, cx)) - .child(ledger()), + .child(ledger()) + .when(player.keys_open, |el| el.child(keys_overlay(player))), ) .child(dock(player, window_h, cx)) } diff --git a/crates/app/src/ui/toolbar.rs b/crates/app/src/ui/toolbar.rs index 9b898dc..5d82e80 100644 --- a/crates/app/src/ui/toolbar.rs +++ b/crates/app/src/ui/toolbar.rs @@ -378,7 +378,7 @@ impl Player { 0., BG_RAISED(), None, - "+ S", + "+ C", "adds a subtitle track under the ones there", ActionId::AddSubtitleLane, cx.listener(|this, _: &ClickEvent, _, cx| {