The room speaks and the loop closes at the end of the film
Browse files at this commitb3335739850c56b5cb7f760652492e2115c6a242Parent: b999ecf- feat
- the room speaks and the loop closes at the end of the film
6 changed files +229 -32
- crates/app/src/keymap.rs +8 -7
- crates/app/src/main.rs +1 -1
- crates/app/src/player/transport.rs +62 -2
- crates/app/src/tests/cards.rs +1 -1
- crates/app/src/timeline_math.rs +14 -0
- crates/app/src/ui/stance.rs +143 -21
crates/app/src/keymap.rsmodified+8 -7
| @@ -1143,11 +1143,12 @@ impl Keymap { | |||
| 1143 | // key stays the one people look for -- the modifier is what | 1143 | // key stays the one people look for -- the modifier is what |
| 1144 | // makes it an intention ([`crate::cancels_export`]). | 1144 | // makes it an intention ([`crate::cancels_export`]). |
| 1145 | b(ActionId::CancelExport, "escape", true), | 1145 | b(ActionId::CancelExport, "escape", true), |
| 1146 | - // The help key, where every program's list of what it can do | 1146 | + // The help key (DESIGN.md §9): held, it opens the keys |
| 1147 | - // has always been. Free -- gpui names it "f1" | 1147 | + // overlay; released, it closes -- the room's own `on_key_up` |
| 1148 | - // (platform.rs:880, the keysym's own name lowercased) -- and | 1148 | + // (`ui/stance.rs`) is what makes that a hold and not a latch. |
| 1149 | - // not a letter, so it takes nothing away from the clip keys. | 1149 | + // Its own key, not `shift+/`: gpui reports a shifted symbol as |
| 1150 | - b(ActionId::ShowActions, "f1", false), | 1150 | + // the glyph itself, so `"?"` is what a stroke of it reports. |
| 1151 | + b(ActionId::ShowActions, "?", false), | ||
| 1151 | // "w" is free entirely, bare and ctrl both -- nothing else in | 1152 | // "w" is free entirely, bare and ctrl both -- nothing else in |
| 1152 | // this table answers to it. | 1153 | // this table answers to it. |
| 1153 | b(ActionId::Screenshot, "w", false), | 1154 | b(ActionId::Screenshot, "w", false), |
| @@ -1435,7 +1436,7 @@ mod tests { | |||
| 1435 | assert_eq!(k.lookup("y", false), Some(ActionId::SubtitleStyle)); | 1436 | assert_eq!(k.lookup("y", false), Some(ActionId::SubtitleStyle)); |
| 1436 | assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies)); | 1437 | assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies)); |
| 1437 | assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies)); | 1438 | assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies)); |
| 1438 | - assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions)); | 1439 | + assert_eq!(k.lookup("?", false), Some(ActionId::ShowActions)); |
| 1439 | assert_eq!(k.lookup("h", true), Some(ActionId::Theme)); | 1440 | assert_eq!(k.lookup("h", true), Some(ActionId::Theme)); |
| 1440 | assert_eq!(k.lookup("space", false), Some(ActionId::Play)); | 1441 | assert_eq!(k.lookup("space", false), Some(ActionId::Play)); |
| 1441 | // The seek keys: bare arrows a frame, ctrl arrows a second, and the two | 1442 | // The seek keys: bare arrows a frame, ctrl arrows a second, and the two |
| @@ -1705,7 +1706,7 @@ mod tests { | |||
| 1705 | // The label is the editor's column, and never the file's word for it. | 1706 | // The label is the editor's column, and never the file's word for it. |
| 1706 | assert_eq!(ActionId::CancelExport.label(), "Cancel export"); | 1707 | assert_eq!(ActionId::CancelExport.label(), "Cancel export"); |
| 1707 | assert_eq!(k.display(ActionId::ToggleSnap), "n"); | 1708 | assert_eq!(k.display(ActionId::ToggleSnap), "n"); |
| 1708 | - assert_eq!(k.display(ActionId::ShowActions), "f1"); | 1709 | + assert_eq!(k.display(ActionId::ShowActions), "?"); |
| 1709 | assert_eq!(k.display(ActionId::ToggleSubtitles), "t"); | 1710 | assert_eq!(k.display(ActionId::ToggleSubtitles), "t"); |
| 1710 | assert_eq!(k.display(ActionId::ZoomIn), "ctrl+="); | 1711 | assert_eq!(k.display(ActionId::ZoomIn), "ctrl+="); |
| 1711 | } | 1712 | } |
crates/app/src/main.rsmodified+1 -1
| @@ -68,7 +68,7 @@ use engine::transform::TransformParams; | |||
| 68 | use engine::{Clip, Codec, ExportHandle, Frame, MediaBitrate, PlaybackSession}; | 68 | use engine::{Clip, Codec, ExportHandle, Frame, MediaBitrate, PlaybackSession}; |
| 69 | use gpui::{ | 69 | use gpui::{ |
| 70 | AnyElement, App, Application, Bounds, ClickEvent, Context, CursorStyle, Div, DragMoveEvent, | 70 | AnyElement, App, Application, Bounds, ClickEvent, Context, CursorStyle, Div, DragMoveEvent, |
| 71 | - FocusHandle, KeyDownEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, | 71 | + FocusHandle, KeyDownEvent, KeyUpEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, |
| 72 | PathBuilder, Pixels, Point, RenderImage, ScrollDelta, ScrollHandle, ScrollWheelEvent, | 72 | PathBuilder, Pixels, Point, RenderImage, ScrollDelta, ScrollHandle, ScrollWheelEvent, |
| 73 | SharedString, Size, Stateful, TextAlign, TitlebarOptions, Window, WindowBounds, WindowOptions, | 73 | SharedString, Size, Stateful, TextAlign, TitlebarOptions, Window, WindowBounds, WindowOptions, |
| 74 | canvas, div, img, point, prelude::*, px, relative, rgb, rgba, size, | 74 | canvas, div, img, point, prelude::*, px, relative, rgb, rgba, size, |
crates/app/src/player/transport.rsmodified+62 -2
| @@ -165,14 +165,24 @@ impl Player { | |||
| 165 | // otherwise repaint at vsync forever. Held clear for as long as the | 165 | // otherwise repaint at vsync forever. Held clear for as long as the |
| 166 | // state does, not just on the crossing: nothing else is coming. | 166 | // state does, not just on the crossing: nothing else is coming. |
| 167 | self.seek_since = None; | 167 | self.seek_since = None; |
| 168 | - if crosses_into_loop(was, Transport::Ended, self.loop_on) { | 168 | + // A loop-trim window whose far edge *is* the film's last frame |
| 169 | + // reaches Ended the same tick it would have reached the window's | ||
| 170 | + // own edge, so the top-of-function restart above never gets the | ||
| 171 | + // chance -- `is_playing()` there is already false by the time | ||
| 172 | + // this branch runs. Folded into the same crossing the | ||
| 173 | + // whole-timeline loop already used, so that race has nothing | ||
| 174 | + // left to win: reaching the end while *either* loop is armed | ||
| 175 | + // restarts rather than halts, regardless of which one owns it. | ||
| 176 | + let armed = self.loop_on || self.loop_trim.is_some(); | ||
| 177 | + if crosses_into_loop(was, Transport::Ended, armed) { | ||
| 169 | // The same door the restart button and key use | 178 | // The same door the restart button and key use |
| 170 | // ([`Player::toggle_or_restart`]), minus the `cx` that door | 179 | // ([`Player::toggle_or_restart`]), minus the `cx` that door |
| 171 | // spends only on a repaint -- the pump is already inside one. | 180 | // spends only on a repaint -- the pump is already inside one. |
| 172 | // One seam of a one-frame seam: the restart is a fresh seek | 181 | // One seam of a one-frame seam: the restart is a fresh seek |
| 173 | // and its reopen, not a gapless splice. | 182 | // and its reopen, not a gapless splice. |
| 183 | + let start = loop_restart_frame(self.loop_on, self.loop_trim).unwrap_or(0); | ||
| 174 | if let Some(session) = self.active_session_mut() { | 184 | if let Some(session) = self.active_session_mut() { |
| 175 | - session.seek(0.); | 185 | + session.seek(f64::from(start) / fps); |
| 176 | } | 186 | } |
| 177 | self.reset_after_reseek(); | 187 | self.reset_after_reseek(); |
| 178 | if let Some(session) = self.active_session_mut() { | 188 | if let Some(session) = self.active_session_mut() { |
| @@ -451,4 +461,54 @@ mod tests { | |||
| 451 | assert!(!crosses_into_loop(Transport::Ended, Transport::Ended, true)); | 461 | assert!(!crosses_into_loop(Transport::Ended, Transport::Ended, true)); |
| 452 | assert!(!crosses_into_loop(Transport::Ended, Transport::Playing, true)); | 462 | assert!(!crosses_into_loop(Transport::Ended, Transport::Playing, true)); |
| 453 | } | 463 | } |
| 464 | + | ||
| 465 | + /// `loop_restart_frame` picks the seek target the crossing above plays | ||
| 466 | + /// from: the trim window's near edge when one is armed (it wins over the | ||
| 467 | + /// whole-timeline loop when both happen to be set), the top of the | ||
| 468 | + /// timeline for the whole-timeline loop alone, and no restart at all | ||
| 469 | + /// with neither armed. | ||
| 470 | + #[test] | ||
| 471 | + fn loop_restart_frame_prefers_the_trim_window_then_the_whole_timeline_then_nothing() { | ||
| 472 | + assert_eq!(loop_restart_frame(false, Some((30, 60))), Some(30)); | ||
| 473 | + assert_eq!( | ||
| 474 | + loop_restart_frame(true, Some((30, 60))), | ||
| 475 | + Some(30), | ||
| 476 | + "the trim window wins over the whole-timeline loop" | ||
| 477 | + ); | ||
| 478 | + assert_eq!(loop_restart_frame(true, None), Some(0)); | ||
| 479 | + assert_eq!(loop_restart_frame(false, None), None); | ||
| 480 | + } | ||
| 481 | + | ||
| 482 | + /// The bug this session fixed: a loop-trim window whose far edge (60) | ||
| 483 | + /// *is* the film's own last frame reaches `Ended` the same tick the | ||
| 484 | + /// window's own edge would have restarted it, so `is_playing()` -- | ||
| 485 | + /// gating the top-of-`pump` restart -- can already be false by the time | ||
| 486 | + /// that check runs. The crossing below must fire from `loop_trim` alone, | ||
| 487 | + /// with `loop_on` off, and it must resume at the window's own start | ||
| 488 | + /// (30), not the top of the timeline: reaching the end while a loop is | ||
| 489 | + /// armed restarts, it never silently halts. | ||
| 490 | + #[test] | ||
| 491 | + fn a_loop_trim_window_ending_at_the_films_last_frame_restarts_on_ended() { | ||
| 492 | + let loop_on = false; | ||
| 493 | + let loop_trim = Some((30, 60)); | ||
| 494 | + let armed = loop_on || loop_trim.is_some(); | ||
| 495 | + assert!(armed, "loop_trim alone must arm the crossing"); | ||
| 496 | + assert!(crosses_into_loop(Transport::Playing, Transport::Ended, armed)); | ||
| 497 | + assert_eq!(loop_restart_frame(loop_on, loop_trim), Some(30)); | ||
| 498 | + } | ||
| 499 | + | ||
| 500 | + /// A loop window sitting entirely before the film's end never reaches | ||
| 501 | + /// `Ended` at all -- the top-of-`pump` restart (`should_loop_restart`, | ||
| 502 | + /// gated on `is_playing()`) fires first, on the ordinary tick the | ||
| 503 | + /// playhead crosses the window's far edge, exactly as | ||
| 504 | + /// `should_loop_restart_only_at_the_windows_far_edge` | ||
| 505 | + /// (`tests::editing`) already covers. This crossing helper only ever | ||
| 506 | + /// applies to the end-of-film case above. | ||
| 507 | + #[test] | ||
| 508 | + fn a_mid_timeline_loop_window_never_needs_the_ended_crossing() { | ||
| 509 | + use crate::timeline_math::should_loop_restart; | ||
| 510 | + // Well short of the film's own end: the ordinary restart already | ||
| 511 | + // fires at frame 60 without the transport ever reaching Ended. | ||
| 512 | + assert!(should_loop_restart(60, Some((30, 60)))); | ||
| 513 | + } | ||
| 454 | } | 514 | } |
crates/app/src/tests/cards.rsmodified+1 -1
| @@ -166,7 +166,7 @@ fn a_search_leaves_the_rows_it_names_under_their_own_headings() { | |||
| 166 | ); | 166 | ); |
| 167 | // The card's own door is on the card, by name and by stroke. | 167 | // The card's own door is on the card, by name and by stroke. |
| 168 | assert_eq!( | 168 | assert_eq!( |
| 169 | - acts(&keys_filter("f1", &keymap)), | 169 | + acts(&keys_filter("?", &keymap)), |
| 170 | vec![ActionId::ShowActions] | 170 | vec![ActionId::ShowActions] |
| 171 | ); | 171 | ); |
| 172 | assert_eq!( | 172 | assert_eq!( |
crates/app/src/timeline_math.rsmodified+14 -0
| @@ -362,6 +362,20 @@ pub(crate) fn should_loop_restart(frame: u32, window: Option<(u32, u32)>) -> boo | |||
| 362 | window.is_some_and(|(_, hi)| frame >= hi) | 362 | window.is_some_and(|(_, hi)| frame >= hi) |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | +/// Where a play resumes from on crossing into [`Transport::Ended`] | ||
| 366 | +/// (`Player::pump`): the loop-trim window's own near edge when one is armed, | ||
| 367 | +/// *even when its far edge is the film's own last frame* -- half of all cuts | ||
| 368 | +/// in a two-clip film sit on the final clip (DESIGN.md §6), so that coincidence | ||
| 369 | +/// is not an edge case and must not read as "reached the end, stop". Falls | ||
| 370 | +/// back to the whole-timeline loop's top, and `None` -- neither armed -- | ||
| 371 | +/// restarts nothing, which is the halt this crossing otherwise means. | ||
| 372 | +pub(crate) fn loop_restart_frame(loop_on: bool, loop_trim: Option<(u32, u32)>) -> Option<u32> { | ||
| 373 | + match loop_trim { | ||
| 374 | + Some((lo, _)) => Some(lo), | ||
| 375 | + None => loop_on.then_some(0), | ||
| 376 | + } | ||
| 377 | +} | ||
| 378 | + | ||
| 365 | /// How many timeline frames a stretch of a subtitle track is worth: the one | 379 | /// How many timeline frames a stretch of a subtitle track is worth: the one |
| 366 | /// conversion between the two clocks a caption has -- microseconds for its | 380 | /// conversion between the two clocks a caption has -- microseconds for its |
| 367 | /// words, frames for where it sits -- and the app-side twin of the engine's own | 381 | /// words, frames for where it sits -- and the app-side twin of the engine's own |
crates/app/src/ui/stance.rsmodified+143 -21
| @@ -87,18 +87,22 @@ fn ghost_dual(player: &Player, glyph: &str, action: ActionId, stride: ActionId) | |||
| 87 | ) | 87 | ) |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | -/// The keys overlay (DESIGN §9, §12 step 7): every bound command as one | 90 | +/// The keys overlay (DESIGN §9, §12 step 7): every bound command, sectioned |
| 91 | -/// chord-and-label row, plate-styled per §4 ("readouts are plates"), shown | 91 | +/// by [`keymap::Category`] exactly as the legacy actions card files them |
| 92 | -/// while [`Player::keys_open`] is set (the same field/guard the legacy | 92 | +/// ([`keys_rows`]) -- reusing that registry-driven order is what makes an |
| 93 | -/// modal already used -- `Player::show_actions` sets it, `Player::close_card` | 93 | +/// action added anywhere land here without a second list to forget. Held |
| 94 | -/// clears it on `esc`, both already wired through the darkroom's key | 94 | +/// open by `?` -- [`crate::ui::stance::render`]'s own `on_key_down` opens it |
| 95 | -/// handler below). | 95 | +/// on the press (bypassing the modal `overlaid()` guard, which would |
| 96 | +/// otherwise swallow the second `?` down while the first is still up) and | ||
| 97 | +/// its `on_key_up` closes it on release, so this is the room dimming one | ||
| 98 | +/// fill step for as long as the key is held, never a latch (DESIGN §9: "no | ||
| 99 | +/// modal cheat-sheet"). | ||
| 96 | /// | 100 | /// |
| 97 | /// corner-cut: DESIGN §9 wants chords surfaced *in place beside their | 101 | /// corner-cut: DESIGN §9 wants chords surfaced *in place beside their |
| 98 | -/// controls* across every region, dimming the room one fill step; this is | 102 | +/// controls* across every region; this is one scrolling list plate instead, |
| 99 | -/// one list plate instead, anchored over the bench/ledger footprint so it | 103 | +/// anchored over the bench/ledger footprint so it never reaches the screen. |
| 100 | -/// never reaches the screen. Ceiling: DESIGN §12 step 7's full geographic | 104 | +/// Ceiling: DESIGN §12 step 7's full geographic pass (each region draws its |
| 101 | -/// pass (each region draws its own rows when `keys_open`). | 105 | +/// own rows while held). |
| 102 | fn keys_overlay(player: &Player) -> impl IntoElement { | 106 | fn keys_overlay(player: &Player) -> impl IntoElement { |
| 103 | div() | 107 | div() |
| 104 | .id("stance-keys-overlay") | 108 | .id("stance-keys-overlay") |
| @@ -111,10 +115,11 @@ fn keys_overlay(player: &Player) -> impl IntoElement { | |||
| 111 | .flex() | 115 | .flex() |
| 112 | .child( | 116 | .child( |
| 113 | div() | 117 | div() |
| 118 | + .id("stance-keys-list") | ||
| 114 | .m_auto() | 119 | .m_auto() |
| 115 | - .max_h(px(BENCH_H + LEDGER_H - 16.)) | 120 | + .h(px(BENCH_H + LEDGER_H - 16.)) |
| 116 | - .max_w(px(420.)) | 121 | + .w(px(460.)) |
| 117 | - .overflow_hidden() | 122 | + .overflow_y_scroll() |
| 118 | .p(px(10.)) | 123 | .p(px(10.)) |
| 119 | .rounded(px(4.)) | 124 | .rounded(px(4.)) |
| 120 | .bg(rgb(DARK_PANEL())) | 125 | .bg(rgb(DARK_PANEL())) |
| @@ -123,15 +128,34 @@ fn keys_overlay(player: &Player) -> impl IntoElement { | |||
| 123 | .flex() | 128 | .flex() |
| 124 | .flex_col() | 129 | .flex_col() |
| 125 | .gap(px(3.)) | 130 | .gap(px(3.)) |
| 126 | - .child(section_head("all commands · esc to close")) | 131 | + .child(section_head("all commands · hold ? · release to close")) |
| 127 | - .children(player.keymap.entries().iter().map(|b| { | 132 | + .children(keys_rows().into_iter().map(|row| match row { |
| 128 | - div() | 133 | + KeyRow::Head(category) => div() |
| 134 | + .flex_none() | ||
| 135 | + .pt(px(4.)) | ||
| 136 | + .text_size(px(9.)) | ||
| 137 | + .text_color(rgb(INK3())) | ||
| 138 | + .child(category.label().to_uppercase()) | ||
| 139 | + .into_any_element(), | ||
| 140 | + KeyRow::Act(action) => div() | ||
| 129 | .flex() | 141 | .flex() |
| 130 | .justify_between() | 142 | .justify_between() |
| 131 | .gap(px(12.)) | 143 | .gap(px(12.)) |
| 132 | .text_size(px(9.5)) | 144 | .text_size(px(9.5)) |
| 133 | - .child(div().text_color(rgb(INK2())).child(b.action.label())) | 145 | + .child(div().text_color(rgb(INK2())).child(action.label())) |
| 134 | - .child(div().text_color(rgb(INK3())).child(b.chord.pretty())) | 146 | + .child(div().text_color(rgb(INK3())).child(player.keymap.display(action))) |
| 147 | + .into_any_element(), | ||
| 148 | + KeyRow::Fixed(i) => { | ||
| 149 | + let f = &keymap::FIXED[i]; | ||
| 150 | + div() | ||
| 151 | + .flex() | ||
| 152 | + .justify_between() | ||
| 153 | + .gap(px(12.)) | ||
| 154 | + .text_size(px(9.5)) | ||
| 155 | + .child(div().text_color(rgb(INK2())).child(f.label)) | ||
| 156 | + .child(div().text_color(rgb(INK3())).child(f.chord.clone())) | ||
| 157 | + .into_any_element() | ||
| 158 | + } | ||
| 135 | })), | 159 | })), |
| 136 | ) | 160 | ) |
| 137 | } | 161 | } |
| @@ -285,9 +309,70 @@ fn bench(player: &mut Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 285 | .child(bench_stance::render(player, BENCH_H - 20., cx)) | 309 | .child(bench_stance::render(player, BENCH_H - 20., cx)) |
| 286 | } | 310 | } |
| 287 | 311 | ||
| 312 | +/// Which of the three §8 severities a notice's own words carry. Reuses | ||
| 313 | +/// [`notice_tone`] (the legacy bar's own classification, by word) rather than | ||
| 314 | +/// a second heuristic, and folds its four-way answer onto the darkroom's | ||
| 315 | +/// three tokens: `STATUS_ERROR`/`STATUS_WARNING` are the same constants as | ||
| 316 | +/// `NOTICE_DECIDE`/`NOTICE_LOOK` already (`ui/theme.rs`'s `darkroom` module | ||
| 317 | +/// aliases them both ways), so the two failure/refusal tones fold straight | ||
| 318 | +/// across and everything else -- success included -- reads as *told you*. | ||
| 319 | +fn notice_severity(message: &str) -> u32 { | ||
| 320 | + let tone = notice_tone(message); | ||
| 321 | + if tone == STATUS_ERROR() { | ||
| 322 | + NOTICE_DECIDE() | ||
| 323 | + } else if tone == STATUS_WARNING() { | ||
| 324 | + NOTICE_LOOK() | ||
| 325 | + } else { | ||
| 326 | + NOTICE_TELL() | ||
| 327 | + } | ||
| 328 | +} | ||
| 329 | + | ||
| 330 | +/// A notice plate (DESIGN §8): one at a time, rising above the ledger, its | ||
| 331 | +/// severity a 3px left spine rather than a colour flood. Fed by the same | ||
| 332 | +/// [`Player::notify_user`]/`notices` queue the legacy bar reads | ||
| 333 | +/// ([`Player::notice_bar`]) -- no second notice channel. Dismissal is | ||
| 334 | +/// already wired: [`render`]'s `on_key_down` calls `dismiss_notice()` on | ||
| 335 | +/// every stroke, the same door the legacy handler uses. | ||
| 336 | +/// | ||
| 337 | +/// corner-cut: amber's "carries a jump action" is not wired -- the queue | ||
| 338 | +/// only ever held plain text, no structured jump target, in either the | ||
| 339 | +/// legacy bar or here. Ceiling: give `notify_user` an optional jump payload | ||
| 340 | +/// once a call site actually has one to carry. | ||
| 341 | +fn notice_plate(message: SharedString) -> impl IntoElement { | ||
| 342 | + div() | ||
| 343 | + .id("stance-notice") | ||
| 344 | + .absolute() | ||
| 345 | + .bottom(px(LEDGER_H + 6.)) | ||
| 346 | + .left(px(12.)) | ||
| 347 | + .max_w(px(360.)) | ||
| 348 | + .flex() | ||
| 349 | + .items_center() | ||
| 350 | + .px(px(10.)) | ||
| 351 | + .py(px(6.)) | ||
| 352 | + .rounded(px(2.)) | ||
| 353 | + .bg(rgb(DARK_PANEL())) | ||
| 354 | + // The severity spine (DESIGN §8): a 3px left border, coloured, same | ||
| 355 | + // shape as the legacy notice bar's own tone stripe (`notice_bar`). | ||
| 356 | + .border_l(px(3.)) | ||
| 357 | + .border_color(rgb(notice_severity(&message))) | ||
| 358 | + .text_size(px(10.)) | ||
| 359 | + .text_color(rgb(INK1())) | ||
| 360 | + .child(message) | ||
| 361 | +} | ||
| 362 | + | ||
| 288 | /// Thin strip at the bottom of the centre column: project identity, last | 363 | /// Thin strip at the bottom of the centre column: project identity, last |
| 289 | /// action, export progress, position. Notices rise from here (DESIGN §5, §8). | 364 | /// action, export progress, position. Notices rise from here (DESIGN §5, §8). |
| 290 | -fn ledger() -> impl IntoElement { | 365 | +fn ledger(player: &Player, position: f64) -> impl IntoElement { |
| 366 | + let name = match player.project_path.as_os_str().is_empty() { | ||
| 367 | + true => "untitled".to_string(), | ||
| 368 | + false => file_name(&player.project_path), | ||
| 369 | + }; | ||
| 370 | + let identity = format!("{name} · {}", if player.autosave_dirty { "unsaved" } else { "saved" }); | ||
| 371 | + let last_action = player.notices.back().cloned().unwrap_or_else(|| "—".into()); | ||
| 372 | + let export = player | ||
| 373 | + .exporting() | ||
| 374 | + .map(|h| format!("EXPORTING {:.0}%", h.progress() * 100.)); | ||
| 375 | + let tc = timecode(position, player.active_fps()); | ||
| 291 | div() | 376 | div() |
| 292 | .id("stance-ledger") | 377 | .id("stance-ledger") |
| 293 | .flex_none() | 378 | .flex_none() |
| @@ -297,9 +382,21 @@ fn ledger() -> impl IntoElement { | |||
| 297 | .border_color(rgba(DARK_SEAM())) | 382 | .border_color(rgba(DARK_SEAM())) |
| 298 | .flex() | 383 | .flex() |
| 299 | .items_center() | 384 | .items_center() |
| 385 | + .gap(px(14.)) | ||
| 300 | .px(px(12.)) | 386 | .px(px(12.)) |
| 301 | .child(section_head("ledger")) | 387 | .child(section_head("ledger")) |
| 302 | - // hook: §12 step 7 -- project identity/state, last action, export progress, notices. | 388 | + .child(div().text_size(px(9.5)).text_color(rgb(INK1())).child(identity)) |
| 389 | + .child( | ||
| 390 | + div() | ||
| 391 | + .flex_1() | ||
| 392 | + .min_w(px(0.)) | ||
| 393 | + .truncate() | ||
| 394 | + .text_size(px(9.5)) | ||
| 395 | + .text_color(rgb(INK3())) | ||
| 396 | + .child(last_action), | ||
| 397 | + ) | ||
| 398 | + .children(export.map(|e| div().text_size(px(9.5)).text_color(rgb(INK2())).child(e))) | ||
| 399 | + .child(div().flex_none().text_size(px(9.5)).text_color(rgb(INK2())).child(tc)) | ||
| 303 | } | 400 | } |
| 304 | 401 | ||
| 305 | /// The dock: the only side panel, right, fixed width, carrying the Src/Clip | 402 | /// The dock: the only side panel, right, fixed width, carrying the Src/Clip |
| @@ -342,6 +439,18 @@ pub(crate) fn render( | |||
| 342 | if this.dismiss_notice() { | 439 | if this.dismiss_notice() { |
| 343 | cx.notify(); | 440 | cx.notify(); |
| 344 | } | 441 | } |
| 442 | + // DESIGN §9: "`?` held ... surfaces chords ... release restores. | ||
| 443 | + // No modal cheat-sheet." Opened here, ahead of the modal guard | ||
| 444 | + // below (which would otherwise swallow a second `?` down once | ||
| 445 | + // `keys_open` is already true) -- `on_key_up` is the only thing | ||
| 446 | + // that closes it, so there is no latch to fall through to. | ||
| 447 | + if key == "?" && !ctrl { | ||
| 448 | + if !this.keys_open { | ||
| 449 | + this.show_actions(cx); | ||
| 450 | + } | ||
| 451 | + cx.notify(); | ||
| 452 | + return; | ||
| 453 | + } | ||
| 345 | // Same modal guard the legacy handler's rebinding/keys_open/ | 454 | // Same modal guard the legacy handler's rebinding/keys_open/ |
| 346 | // export_open/exporting/colour/transform/speed/EQ/silence/mix/ | 455 | // export_open/exporting/colour/transform/speed/EQ/silence/mix/ |
| 347 | // subtitle-style/menu chain (`render.rs`) amounts to, read as | 456 | // subtitle-style/menu chain (`render.rs`) amounts to, read as |
| @@ -373,6 +482,16 @@ pub(crate) fn render( | |||
| 373 | this.act(action, window, cx); | 482 | this.act(action, window, cx); |
| 374 | } | 483 | } |
| 375 | })) | 484 | })) |
| 485 | + // The release half of the `?` hold above: whatever opened it, this is | ||
| 486 | + // the one thing that closes it -- there is nothing else in the | ||
| 487 | + // darkroom that sets `keys_open` true, so this cannot close a card | ||
| 488 | + // `?` did not open. | ||
| 489 | + .on_key_up(cx.listener(|this, event: &KeyUpEvent, _, cx| { | ||
| 490 | + if event.keystroke.key.as_str() == "?" { | ||
| 491 | + this.keys_open = false; | ||
| 492 | + cx.notify(); | ||
| 493 | + } | ||
| 494 | + })) | ||
| 376 | .size_full() | 495 | .size_full() |
| 377 | .flex() | 496 | .flex() |
| 378 | .bg(rgb(DARK_CANVAS())) | 497 | .bg(rgb(DARK_CANVAS())) |
| @@ -388,7 +507,10 @@ pub(crate) fn render( | |||
| 388 | .child(screen(player, position, window, cx)) | 507 | .child(screen(player, position, window, cx)) |
| 389 | .child(time_band(player)) | 508 | .child(time_band(player)) |
| 390 | .child(bench(player, cx)) | 509 | .child(bench(player, cx)) |
| 391 | - .child(ledger()) | 510 | + .child(ledger(player, position)) |
| 511 | + .when_some(player.notices.front().cloned(), |el, n| { | ||
| 512 | + el.child(notice_plate(n)) | ||
| 513 | + }) | ||
| 392 | .when(player.keys_open, |el| el.child(keys_overlay(player))), | 514 | .when(player.keys_open, |el| el.child(keys_overlay(player))), |
| 393 | ) | 515 | ) |
| 394 | .child(dock(player, window_h, cx)) | 516 | .child(dock(player, window_h, cx)) |