The cut becomes the subject and the dock fills
Browse files at this commit14bd4a65ade27399289c741d80f4363a21d16824Parent: 9499168- feat
- the cut becomes the subject and the dock fills
11 changed files +660 -64
- crates/app/src/main.rs +16 -0
- crates/app/src/player/actions.rs +106 -7
- crates/app/src/player/transport.rs +11 -0
- crates/app/src/render.rs +4 -2
- crates/app/src/tests/editing.rs +40 -0
- crates/app/src/tests/layout.rs +4 -1
- crates/app/src/timeline_math.rs +31 -0
- crates/app/src/ui/dock_stance.rs +228 -0
- crates/app/src/ui/mod.rs +1 -0
- crates/app/src/ui/preview.rs +86 -0
- crates/app/src/ui/stance.rs +133 -54
crates/app/src/main.rsmodified+16 -0
| @@ -122,6 +122,20 @@ struct Player { | |||
| 122 | /// timeline frames -- `None` for the whole timeline. Session state, like | 122 | /// timeline frames -- `None` for the whole timeline. Session state, like |
| 123 | /// the mark itself: never saved to a `.edith` ([`ExportSettings::range`]). | 123 | /// the mark itself: never saved to a `.edith` ([`ExportSettings::range`]). |
| 124 | range: Option<(u32, u32)>, | 124 | range: Option<(u32, u32)>, |
| 125 | + /// Loop-trim (DESIGN.md §6, `/`): the frame window `[start, end)` the | ||
| 126 | + /// transport loops inside while it is on -- the subject cut's own clip | ||
| 127 | + /// span, which is what a `[`/`]` nudge is moving. `None` is the mode off, | ||
| 128 | + /// which is also what lets [`Player::pump`] answer | ||
| 129 | + /// [`should_loop_restart`] with one field instead of asking whether the | ||
| 130 | + /// mode is on and then separately what the window is. | ||
| 131 | + loop_trim: Option<(u32, u32)>, | ||
| 132 | + /// Whether the stroke [`Player::act`] is running for was held with shift | ||
| 133 | + /// -- the odometer's stride (DESIGN.md §6: bare walks one cut, shift | ||
| 134 | + /// strides ten). Set by the key handler right before `act`, since | ||
| 135 | + /// [`ActionId`] carries no modifier of its own (`.` and `shift+.` are the | ||
| 136 | + /// same [`ActionId::WalkCutNext`], by design -- see keymap.rs's own | ||
| 137 | + /// `bshift`) and nothing else here reads it. | ||
| 138 | + walk_shift: bool, | ||
| 125 | /// Timeline seconds -> frame index, so the clock can be compared to what | 139 | /// Timeline seconds -> frame index, so the clock can be compared to what |
| 126 | /// the decoder hands over. | 140 | /// the decoder hands over. |
| 127 | fps: f64, | 141 | fps: f64, |
| @@ -814,6 +828,8 @@ fn main() { | |||
| 814 | player_fullscreen: false, | 828 | player_fullscreen: false, |
| 815 | loop_on: false, | 829 | loop_on: false, |
| 816 | range: None, | 830 | range: None, |
| 831 | + loop_trim: None, | ||
| 832 | + walk_shift: false, | ||
| 817 | // Full and unmuted, which is what the session it was just | 833 | // Full and unmuted, which is what the session it was just |
| 818 | // handed is already set to: nothing to push at startup. | 834 | // handed is already set to: nothing to push at startup. |
| 819 | volume: Volume::default(), | 835 | volume: Volume::default(), |
crates/app/src/player/actions.rsmodified+106 -7
| @@ -162,13 +162,20 @@ impl Player { | |||
| 162 | ActionId::CancelExport => {} | 162 | ActionId::CancelExport => {} |
| 163 | ActionId::ShowActions => self.show_actions(cx), | 163 | ActionId::ShowActions => self.show_actions(cx), |
| 164 | ActionId::Screenshot => self.take_screenshot(cx), | 164 | ActionId::Screenshot => self.take_screenshot(cx), |
| 165 | - // Cut machinery (DESIGN.md §6): keymap.rs/oracle.rs plumbing only | 165 | + // Cut machinery (DESIGN.md §6): the subject cut is the marked |
| 166 | - // so far -- a later task wires these to real behaviour. | 166 | + // clip ([`Selection::anchor`]) -- the oracle already refused |
| 167 | - ActionId::WalkCutNext | 167 | + // every one of these with nothing marked, so an anchor is here |
| 168 | - | ActionId::WalkCutPrev | 168 | + // to read. |
| 169 | - | ActionId::TrimIn | 169 | + ActionId::WalkCutNext => self.walk_cut(true, cx), |
| 170 | - | ActionId::TrimOut | 170 | + ActionId::WalkCutPrev => self.walk_cut(false, cx), |
| 171 | - | ActionId::LoopTrim => {} | 171 | + // `[` `]` close in on the clip like the brackets they are: `[` |
| 172 | + // trims a frame off the head, `]` a frame off the tail -- no-aim, | ||
| 173 | + // frame detents, clamped to the room the engine already answers | ||
| 174 | + // ([`nudge_edge`]), which is what makes them work at any zoom | ||
| 175 | + // down to a 4px clip with nothing to click. | ||
| 176 | + ActionId::TrimIn => self.nudge_cut(Edge::Start, 1, cx), | ||
| 177 | + ActionId::TrimOut => self.nudge_cut(Edge::End, -1, cx), | ||
| 178 | + ActionId::LoopTrim => self.toggle_loop_trim(cx), | ||
| 172 | } | 179 | } |
| 173 | } | 180 | } |
| 174 | 181 | ||
| @@ -452,6 +459,98 @@ impl Player { | |||
| 452 | cx.notify(); | 459 | cx.notify(); |
| 453 | } | 460 | } |
| 454 | 461 | ||
| 462 | + /// The odometer (DESIGN.md §6, `,` `.`): the subject cut steps to its | ||
| 463 | + /// neighbour along its own lane, [`walk_shift`](Player) striding ten | ||
| 464 | + /// instead of one, clamped rather than wrapping at either end | ||
| 465 | + /// ([`walk_cut`]). The playhead follows it there, which is what puts the | ||
| 466 | + /// screen at rest on the new cut for the two-up to draw. | ||
| 467 | + pub(crate) fn walk_cut(&mut self, forward: bool, cx: &mut Context<Self>) { | ||
| 468 | + let Some((lane, idx)) = self.selected.anchor() else { | ||
| 469 | + return; | ||
| 470 | + }; | ||
| 471 | + let Some(session) = &self.session else { | ||
| 472 | + return; | ||
| 473 | + }; | ||
| 474 | + let clips = session.lane_clips(lane); | ||
| 475 | + let stride = if self.walk_shift { 10 } else { 1 }; | ||
| 476 | + let next = walk_cut(idx, clips.len(), forward, stride); | ||
| 477 | + let at = clips.get(next).map(|c| f64::from(c.start) / self.fps); | ||
| 478 | + self.select((lane, next), cx); | ||
| 479 | + if let Some(at) = at { | ||
| 480 | + self.seek(at, cx); | ||
| 481 | + } | ||
| 482 | + } | ||
| 483 | + | ||
| 484 | + /// The subject cut's own span, `[start, end)` in timeline frames -- | ||
| 485 | + /// what loop-trim loops and what the odometer's readout counts against. | ||
| 486 | + pub(crate) fn cut_span(&self, lane: Lane, idx: usize) -> Option<(u32, u32)> { | ||
| 487 | + self.session | ||
| 488 | + .as_ref()? | ||
| 489 | + .lane_clips(lane) | ||
| 490 | + .get(idx) | ||
| 491 | + .map(|c| (c.start, c.end())) | ||
| 492 | + } | ||
| 493 | + | ||
| 494 | + /// The no-aim trim (DESIGN.md §6, `[` `]`): one frame detent off the | ||
| 495 | + /// subject cut's chosen edge, clamped to the room the engine already | ||
| 496 | + /// answers ([`nudge_edge`]) -- the same wall a pointer drag is clamped | ||
| 497 | + /// to, so no aim and no hit-testing are needed at any zoom. | ||
| 498 | + pub(crate) fn nudge_cut(&mut self, edge: Edge, dir: i32, cx: &mut Context<Self>) { | ||
| 499 | + let Some((lane, idx)) = self.selected.anchor() else { | ||
| 500 | + return; | ||
| 501 | + }; | ||
| 502 | + let Some(session) = &self.session else { | ||
| 503 | + return; | ||
| 504 | + }; | ||
| 505 | + let Some((lo, hi)) = session.trim_room(lane, idx, edge) else { | ||
| 506 | + return; | ||
| 507 | + }; | ||
| 508 | + let Some(current) = session.lane_clips(lane).get(idx).map(|c| match edge { | ||
| 509 | + Edge::Start => c.start, | ||
| 510 | + Edge::End => c.end(), | ||
| 511 | + }) else { | ||
| 512 | + return; | ||
| 513 | + }; | ||
| 514 | + let to = nudge_edge(current, dir, lo, hi); | ||
| 515 | + self.mark_dirty(); | ||
| 516 | + let trimmed = self | ||
| 517 | + .session | ||
| 518 | + .as_mut() | ||
| 519 | + .is_some_and(|s| s.trim_clip(lane, idx, edge, to)); | ||
| 520 | + if trimmed { | ||
| 521 | + self.reset_after_reseek(); | ||
| 522 | + // Loop-trim follows the edge it is trimming: the whole point of | ||
| 523 | + // the mode is hearing the cut as it moves. | ||
| 524 | + if self.loop_trim.is_some() { | ||
| 525 | + self.loop_trim = self.cut_span(lane, idx); | ||
| 526 | + } | ||
| 527 | + } | ||
| 528 | + cx.notify(); | ||
| 529 | + } | ||
| 530 | + | ||
| 531 | + /// Loop-trim (DESIGN.md §6, `/`): loops the transport around the subject | ||
| 532 | + /// cut's own span while `[`/`]` move its edges -- the modernized Avid | ||
| 533 | + /// trim mode. Off again drops the window and leaves playback running, | ||
| 534 | + /// exactly as it was found. | ||
| 535 | + pub(crate) fn toggle_loop_trim(&mut self, cx: &mut Context<Self>) { | ||
| 536 | + if self.loop_trim.take().is_some() { | ||
| 537 | + self.notify_user("LOOP-TRIM OFF".into()); | ||
| 538 | + cx.notify(); | ||
| 539 | + return; | ||
| 540 | + } | ||
| 541 | + let Some((lane, idx)) = self.selected.anchor() else { | ||
| 542 | + return; | ||
| 543 | + }; | ||
| 544 | + self.loop_trim = self.cut_span(lane, idx); | ||
| 545 | + if self.loop_trim.is_some() { | ||
| 546 | + self.notify_user("LOOP-TRIM ON — looping the subject cut while you trim".into()); | ||
| 547 | + if let Some(session) = self.active_session_mut() { | ||
| 548 | + session.play(); | ||
| 549 | + } | ||
| 550 | + } | ||
| 551 | + cx.notify(); | ||
| 552 | + } | ||
| 553 | + | ||
| 455 | pub(crate) fn undo(&mut self, cx: &mut Context<Self>) { | 554 | pub(crate) fn undo(&mut self, cx: &mut Context<Self>) { |
| 456 | if self.session.as_mut().is_some_and(PlaybackSession::undo) { | 555 | if self.session.as_mut().is_some_and(PlaybackSession::undo) { |
| 457 | self.reset_after_reseek(); | 556 | self.reset_after_reseek(); |
crates/app/src/player/transport.rsmodified+11 -0
| @@ -46,6 +46,17 @@ impl Player { | |||
| 46 | let Some(session) = self.preview_session.as_mut().or(self.session.as_mut()) else { | 46 | let Some(session) = self.preview_session.as_mut().or(self.session.as_mut()) else { |
| 47 | return; | 47 | return; |
| 48 | }; | 48 | }; |
| 49 | + // Loop-trim (DESIGN.md §6): the transport is kept inside the subject | ||
| 50 | + // cut's own span while the mode is on, so a trim can be heard and | ||
| 51 | + // seen without a manual replay after every nudge. Checked off the | ||
| 52 | + // engine's own clock, not a frame counter this pump keeps -- the | ||
| 53 | + // same `now()` [`Player::step`] reads. | ||
| 54 | + if session.is_playing() | ||
| 55 | + && should_loop_restart(frame_at(session.now(), fps), self.loop_trim) | ||
| 56 | + { | ||
| 57 | + let start = self.loop_trim.map_or(0, |(lo, _)| lo); | ||
| 58 | + session.seek(f64::from(start) / fps); | ||
| 59 | + } | ||
| 49 | // Whether the span now decoding has yet to hand over a picture, read | 60 | // Whether the span now decoding has yet to hand over a picture, read |
| 50 | // *before* the drain: the frame the drain is about to take is the one | 61 | // *before* the drain: the frame the drain is about to take is the one |
| 51 | // that ends the prime, and its own lateness -- however long the span's | 62 | // that ends the prime, and its own lateness -- however long the span's |
crates/app/src/render.rsmodified+4 -2
| @@ -17,8 +17,10 @@ impl Player { | |||
| 17 | /// The picture region alone: the image, the subtitle cue plate, the | 17 | /// The picture region alone: the image, the subtitle cue plate, the |
| 18 | /// preview badge and the three transient bars over its bottom edge. | 18 | /// preview badge and the three transient bars over its bottom edge. |
| 19 | /// Its own method so player fullscreen ([`Player::act`]) can stand it up | 19 | /// Its own method so player fullscreen ([`Player::act`]) can stand it up |
| 20 | - /// as the window's only child without a second copy of what it draws. | 20 | + /// as the window's only child without a second copy of what it draws -- |
| 21 | - fn picture_area( | 21 | + /// and so the darkroom's own screen region (DESIGN.md §5, |
| 22 | + /// `ui::stance::screen`) draws the same picture rather than a second one. | ||
| 23 | + pub(crate) fn picture_area( | ||
| 22 | &mut self, | 24 | &mut self, |
| 23 | position: f64, | 25 | position: f64, |
| 24 | window: &mut Window, | 26 | window: &mut Window, |
crates/app/src/tests/editing.rsmodified+40 -0
| @@ -2062,3 +2062,43 @@ fn a_fade_drag_converts_pixels_to_frames_at_the_beds_scale() { | |||
| 2062 | assert_eq!(fade_delta_frames(40., 0., 25.), 0); | 2062 | assert_eq!(fade_delta_frames(40., 0., 25.), 0); |
| 2063 | assert_eq!(fade_delta_frames(40., -1., 25.), 0); | 2063 | assert_eq!(fade_delta_frames(40., -1., 25.), 0); |
| 2064 | } | 2064 | } |
| 2065 | + | ||
| 2066 | +/// The cut odometer (DESIGN.md §6): `,` `.` walk it one cut at a time, shift | ||
| 2067 | +/// strides ten, and either end holds rather than wrapping. | ||
| 2068 | +#[test] | ||
| 2069 | +fn walk_cut_strides_and_clamps_at_either_end() { | ||
| 2070 | + use crate::timeline_math::walk_cut; | ||
| 2071 | + assert_eq!(walk_cut(3, 10, true, 1), 4); | ||
| 2072 | + assert_eq!(walk_cut(3, 10, false, 1), 2); | ||
| 2073 | + assert_eq!(walk_cut(3, 10, true, 10), 9, "clamps at the last cut"); | ||
| 2074 | + assert_eq!(walk_cut(3, 10, false, 10), 0, "clamps at the first cut"); | ||
| 2075 | + assert_eq!(walk_cut(9, 10, true, 1), 9, "already at the end holds"); | ||
| 2076 | + assert_eq!(walk_cut(0, 10, false, 1), 0, "already at the start holds"); | ||
| 2077 | + // No cuts at all: nothing to land on. | ||
| 2078 | + assert_eq!(walk_cut(0, 0, true, 1), 0); | ||
| 2079 | +} | ||
| 2080 | + | ||
| 2081 | +/// The no-aim trim (DESIGN.md §6): a frame detent clamped to the room the | ||
| 2082 | +/// engine already answered, in either direction, and never past it. | ||
| 2083 | +#[test] | ||
| 2084 | +fn nudge_edge_moves_one_frame_and_clamps_to_the_room() { | ||
| 2085 | + use crate::timeline_math::nudge_edge; | ||
| 2086 | + assert_eq!(nudge_edge(50, 1, 0, 100), 51); | ||
| 2087 | + assert_eq!(nudge_edge(50, -1, 0, 100), 49); | ||
| 2088 | + assert_eq!(nudge_edge(0, -1, 0, 100), 0, "the room's own floor holds"); | ||
| 2089 | + assert_eq!(nudge_edge(100, 1, 0, 100), 100, "the room's own ceiling holds"); | ||
| 2090 | + // A 4px-wide clip's room can be one frame wide: still clamps, never | ||
| 2091 | + // panics on the narrow end. | ||
| 2092 | + assert_eq!(nudge_edge(5, 1, 5, 5), 5); | ||
| 2093 | +} | ||
| 2094 | + | ||
| 2095 | +/// Loop-trim's restart (DESIGN.md §6): only once the window's far edge is | ||
| 2096 | +/// reached, and never with the mode off. | ||
| 2097 | +#[test] | ||
| 2098 | +fn should_loop_restart_only_at_the_windows_far_edge() { | ||
| 2099 | + use crate::timeline_math::should_loop_restart; | ||
| 2100 | + assert!(!should_loop_restart(40, Some((30, 60)))); | ||
| 2101 | + assert!(should_loop_restart(60, Some((30, 60)))); | ||
| 2102 | + assert!(should_loop_restart(61, Some((30, 60))), "past it restarts too"); | ||
| 2103 | + assert!(!should_loop_restart(60, None), "loop-trim off restarts nothing"); | ||
| 2104 | +} | ||
crates/app/src/tests/layout.rsmodified+4 -1
| @@ -1743,7 +1743,10 @@ fn the_stance_renders_its_six_regions_in_the_documented_order() { | |||
| 1743 | // them in it too, or the geometry above is dead prose. | 1743 | // them in it too, or the geometry above is dead prose. |
| 1744 | let render_body = | 1744 | let render_body = |
| 1745 | &stance[stance.find("pub(crate) fn render(").expect("the stance's entry point")..]; | 1745 | &stance[stance.find("pub(crate) fn render(").expect("the stance's entry point")..]; |
| 1746 | - let calls = ["spine()", "screen()", "time_band()", "bench()", "ledger()", "dock()"]; | 1746 | + // Open paren only, no close: DESIGN §12 steps 3 and 4 hand most of the |
| 1747 | + // regions player/window state to read, so their call sites carry | ||
| 1748 | + // arguments now. Order is what this asserts, not arity. | ||
| 1749 | + let calls = ["spine(", "screen(", "time_band(", "bench(", "ledger(", "dock("]; | ||
| 1747 | let composed: Vec<usize> = calls | 1750 | let composed: Vec<usize> = calls |
| 1748 | .iter() | 1751 | .iter() |
| 1749 | .map(|c| { | 1752 | .map(|c| { |
crates/app/src/timeline_math.rsmodified+31 -0
| @@ -331,6 +331,37 @@ pub(crate) fn trimmed_clip(clip: Clip, edge: Edge, to: u32, still: bool) -> Clip | |||
| 331 | } | 331 | } |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | +/// The cut odometer's own arithmetic (DESIGN.md §6): where `,` `.` land from | ||
| 335 | +/// `idx`, `stride` cuts forward or back among `len` of them. Clamped rather | ||
| 336 | +/// than wrapping -- an odometer that wraps at the last cut reads as landing | ||
| 337 | +/// back at the first, which is not "next" -- so a walk already at either end | ||
| 338 | +/// simply holds there, the way [`Player::step`]'s own ends do. | ||
| 339 | +pub(crate) fn walk_cut(idx: usize, len: usize, forward: bool, stride: usize) -> usize { | ||
| 340 | + if len == 0 { | ||
| 341 | + return 0; | ||
| 342 | + } | ||
| 343 | + let delta = stride.min(len - 1) as isize; | ||
| 344 | + let at = if forward { idx as isize + delta } else { idx as isize - delta }; | ||
| 345 | + at.clamp(0, len as isize - 1) as usize | ||
| 346 | +} | ||
| 347 | + | ||
| 348 | +/// The no-aim trim's own arithmetic (DESIGN.md §6): `current` moved `dir` | ||
| 349 | +/// frames (usually ±1, a held key's ratchet) and clamped into the room | ||
| 350 | +/// [`engine::PlaybackSession::trim_room`] already answered -- the same wall a | ||
| 351 | +/// pointer drag is clamped to, so a keyboard trim can never draw an edge the | ||
| 352 | +/// engine would refuse. | ||
| 353 | +pub(crate) fn nudge_edge(current: u32, dir: i32, lo: u32, hi: u32) -> u32 { | ||
| 354 | + (i64::from(current) + i64::from(dir)).clamp(i64::from(lo), i64::from(hi)) as u32 | ||
| 355 | +} | ||
| 356 | + | ||
| 357 | +/// Whether a loop-trim window ([`ActionId::LoopTrim`]) has been played out to | ||
| 358 | +/// its far edge and wants restarting at its near one: pure so the pump's own | ||
| 359 | +/// tick ([`Player::pump`]) is one `if` over a fact this decides. `None` -- | ||
| 360 | +/// loop-trim off -- never restarts anything. | ||
| 361 | +pub(crate) fn should_loop_restart(frame: u32, window: Option<(u32, u32)>) -> bool { | ||
| 362 | + window.is_some_and(|(_, hi)| frame >= hi) | ||
| 363 | +} | ||
| 364 | + | ||
| 334 | /// How many timeline frames a stretch of a subtitle track is worth: the one | 365 | /// How many timeline frames a stretch of a subtitle track is worth: the one |
| 335 | /// conversion between the two clocks a caption has -- microseconds for its | 366 | /// conversion between the two clocks a caption has -- microseconds for its |
| 336 | /// words, frames for where it sits -- and the app-side twin of the engine's own | 367 | /// words, frames for where it sits -- and the app-side twin of the engine's own |
crates/app/src/ui/dock_stance.rsadded+228 -0
| @@ -0,0 +1,228 @@ | |||
| 1 | +//! 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 frame | ||
| 3 | +//! (width, surfaces, border); this module owns what fills it. | ||
| 4 | + | ||
| 5 | +use crate::*; | ||
| 6 | + | ||
| 7 | +/// corner-cut: which dock tab is showing lives in a module-level flag rather | ||
| 8 | +/// than a `Player` field, because the stance's other regions (spine, screen, | ||
| 9 | +/// time band) are being threaded onto `Player` by a second builder in this | ||
| 10 | +/// same pass and a shared struct is not a safe place for two agents to land | ||
| 11 | +/// fields at once. Ceiling: fold into a `Player::dock_tab` field once that | ||
| 12 | +/// pass lands, so DESIGN §5's "a room reopens exactly as left ... dock tab" | ||
| 13 | +/// continuity (session save/load) can reach it -- today the flag resets with | ||
| 14 | +/// the process. | ||
| 15 | +static DOCK_SRC_ACTIVE: AtomicBool = AtomicBool::new(true); | ||
| 16 | + | ||
| 17 | +/// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in | ||
| 18 | +/// `ink3` beside it, read live off the keymap so it can never drift from the | ||
| 19 | +/// key that does the same thing. Hover is one fill step and an ink brighten; | ||
| 20 | +/// held open (`active`) keeps both. A refused verb dims and says why on | ||
| 21 | +/// hover instead of disappearing (§8). | ||
| 22 | +fn ghost_verb( | ||
| 23 | + id: &'static str, | ||
| 24 | + label: &'static str, | ||
| 25 | + action: ActionId, | ||
| 26 | + active: bool, | ||
| 27 | + hint: &str, | ||
| 28 | + player: &Player, | ||
| 29 | + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | ||
| 30 | +) -> impl IntoElement { | ||
| 31 | + let enabled = player.enable(action, None); | ||
| 32 | + let key = player.keymap.display(action); | ||
| 33 | + let say: SharedString = match enabled.why() { | ||
| 34 | + Some(why) => format!("{key} — {why}"), | ||
| 35 | + None => format!("{key} — {hint}"), | ||
| 36 | + } | ||
| 37 | + .into(); | ||
| 38 | + let on = enabled.yes(); | ||
| 39 | + div() | ||
| 40 | + .id(id) | ||
| 41 | + .flex_none() | ||
| 42 | + .flex() | ||
| 43 | + .items_center() | ||
| 44 | + .justify_between() | ||
| 45 | + .h(px(CONTROL_H)) | ||
| 46 | + .px(px(8.)) | ||
| 47 | + .rounded(px(3.)) | ||
| 48 | + .when(active, |d| d.bg(rgb(DARK_RAISED()))) | ||
| 49 | + .text_color(rgb(if active { INK1() } else { INK2() })) | ||
| 50 | + .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) | ||
| 51 | + .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) | ||
| 52 | + .when(on, |d| { | ||
| 53 | + d.cursor_pointer() | ||
| 54 | + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) | ||
| 55 | + .on_click(on_click) | ||
| 56 | + }) | ||
| 57 | + .child(label) | ||
| 58 | + .child( | ||
| 59 | + div() | ||
| 60 | + .flex_none() | ||
| 61 | + .text_size(px(9.5)) | ||
| 62 | + .text_color(rgb(if active { INK1() } else { INK3() })) | ||
| 63 | + .child(key), | ||
| 64 | + ) | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +/// One tab glyph of the Src/Clip pair: a plate (2px radius per §4), `ink1` + | ||
| 68 | +/// `raised` fill when it is the showing tab, `ink2` at rest. | ||
| 69 | +fn dock_tab(id: &'static str, label: &'static str, active: bool, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 70 | + div() | ||
| 71 | + .id(id) | ||
| 72 | + .flex_1() | ||
| 73 | + .flex() | ||
| 74 | + .items_center() | ||
| 75 | + .justify_center() | ||
| 76 | + .rounded(px(2.)) | ||
| 77 | + .py(px(6.)) | ||
| 78 | + .text_size(px(10.5)) | ||
| 79 | + .text_color(rgb(if active { INK1() } else { INK2() })) | ||
| 80 | + .when(active, |d| d.bg(rgb(DARK_RAISED()))) | ||
| 81 | + .cursor_pointer() | ||
| 82 | + .hover(|s| s.bg(rgb(DARK_RAISED()))) | ||
| 83 | + .on_click(cx.listener(move |_this, _: &ClickEvent, _, cx| { | ||
| 84 | + DOCK_SRC_ACTIVE.store(label == "Src", Ordering::Relaxed); | ||
| 85 | + cx.notify(); | ||
| 86 | + })) | ||
| 87 | + .child(label) | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +/// The Sources tab: [`Player::library`] verbatim -- filter tabs, usage | ||
| 91 | +/// (proxy/preview) chips, Import, drag, Add at playhead -- restyled for free, | ||
| 92 | +/// because its rows already paint through the theme tokens `library.rs` | ||
| 93 | +/// shares with this stance (`BG_PANEL` etc. alias to the Darkroom substrate | ||
| 94 | +/// under `PaletteId::Darkroom`). No ink/re-inking control lives in it (DESIGN | ||
| 95 | +/// §2's demotion rule): `library.rs` never put one on a row to begin with, so | ||
| 96 | +/// there is nothing here to strip. | ||
| 97 | +fn sources_tab(player: &Player, width: f32, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 98 | + player.library(width, cx) | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +/// The Clip tab: the four verbs DESIGN §5 names, as ghosts, over whichever | ||
| 102 | +/// param-row card they open -- [`Player::eq_card`], [`Player::color_card`], | ||
| 103 | +/// [`Player::transform_card`], [`Player::speed_card`] verbatim, the same | ||
| 104 | +/// param-row rendering `inspector.rs`'s selection section already opens | ||
| 105 | +/// these onto. Drag-while-playing and every other gesture on a row is | ||
| 106 | +/// whatever that card already does; nothing about the gesture is reimplemented | ||
| 107 | +/// here. | ||
| 108 | +fn clip_tab(player: &Player, width: f32, window_h: Pixels, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 109 | + let room = size(px(width), window_h); | ||
| 110 | + let none_open = player.eq_open.is_none() | ||
| 111 | + && player.color_open.is_none() | ||
| 112 | + && player.transform_open.is_none() | ||
| 113 | + && player.speed_open.is_none(); | ||
| 114 | + div() | ||
| 115 | + .id("dock-clip") | ||
| 116 | + .flex_1() | ||
| 117 | + .min_h(px(0.)) | ||
| 118 | + .flex() | ||
| 119 | + .flex_col() | ||
| 120 | + .overflow_y_scroll() | ||
| 121 | + .child( | ||
| 122 | + div() | ||
| 123 | + .id("dock-clip-verbs") | ||
| 124 | + .flex_none() | ||
| 125 | + .flex() | ||
| 126 | + .flex_col() | ||
| 127 | + .gap(px(2.)) | ||
| 128 | + .p(px(8.)) | ||
| 129 | + .child(ghost_verb( | ||
| 130 | + "dock-verb-speed", | ||
| 131 | + "Speed", | ||
| 132 | + ActionId::Speed, | ||
| 133 | + player.speed_open.is_some(), | ||
| 134 | + "how fast this clip and its group play", | ||
| 135 | + player, | ||
| 136 | + cx.listener(|this, _: &ClickEvent, _, cx| this.open_speed(cx)), | ||
| 137 | + )) | ||
| 138 | + .child(ghost_verb( | ||
| 139 | + "dock-verb-color", | ||
| 140 | + "Colour", | ||
| 141 | + ActionId::Color, | ||
| 142 | + player.color_open.is_some(), | ||
| 143 | + "exposure, contrast, saturation and temperature", | ||
| 144 | + player, | ||
| 145 | + cx.listener(|this, _: &ClickEvent, _, cx| this.open_color(cx)), | ||
| 146 | + )) | ||
| 147 | + .child(ghost_verb( | ||
| 148 | + "dock-verb-transform", | ||
| 149 | + "Transform", | ||
| 150 | + ActionId::Transform, | ||
| 151 | + player.transform_open.is_some(), | ||
| 152 | + "position, scale, rotation and crop for this clip", | ||
| 153 | + player, | ||
| 154 | + cx.listener(|this, _: &ClickEvent, _, cx| this.open_transform(cx)), | ||
| 155 | + )) | ||
| 156 | + .child(ghost_verb( | ||
| 157 | + "dock-verb-eq", | ||
| 158 | + "EQ", | ||
| 159 | + ActionId::Equalizer, | ||
| 160 | + player.eq_open.is_some(), | ||
| 161 | + "the bands this clip's sound is filtered through", | ||
| 162 | + player, | ||
| 163 | + cx.listener(|this, _: &ClickEvent, _, cx| this.open_eq(cx)), | ||
| 164 | + )), | ||
| 165 | + ) | ||
| 166 | + .child( | ||
| 167 | + div() | ||
| 168 | + .id("dock-clip-rows") | ||
| 169 | + .flex_1() | ||
| 170 | + .min_h(px(0.)) | ||
| 171 | + .px(px(8.)) | ||
| 172 | + .pb(px(8.)) | ||
| 173 | + .children(player.eq_card(room, cx)) | ||
| 174 | + .children(player.color_card(cx)) | ||
| 175 | + .children(player.transform_card(cx)) | ||
| 176 | + .children(player.speed_card(cx)) | ||
| 177 | + // A plate, not bare space: DESIGN §11's "states" checklist -- | ||
| 178 | + // nothing picked reads as a hint, not as a hole in the panel. | ||
| 179 | + .when(none_open, |d| { | ||
| 180 | + d.child( | ||
| 181 | + div() | ||
| 182 | + .rounded(px(2.)) | ||
| 183 | + .bg(rgb(DARK_CANVAS())) | ||
| 184 | + .p(px(8.)) | ||
| 185 | + .text_size(px(10.5)) | ||
| 186 | + .text_color(rgb(INK3())) | ||
| 187 | + .child("pick a verb above"), | ||
| 188 | + ) | ||
| 189 | + }), | ||
| 190 | + ) | ||
| 191 | +} | ||
| 192 | + | ||
| 193 | +/// The dock's content, under `stance.rs::dock()`'s tab-bar-and-body frame: | ||
| 194 | +/// the tab row, then whichever tab is showing. | ||
| 195 | +/// | ||
| 196 | +/// Degradation (DESIGN §7): the dock is a fixed-width side panel, not a lane | ||
| 197 | +/// bed, so it has no width ladder of its own to walk -- the panel is either | ||
| 198 | +/// on screen at its one width or, at the narrowest floors this editor draws | ||
| 199 | +/// to, is the first region asked to give up its width entirely (a step | ||
| 200 | +/// `layout.rs`'s split budget already owns for the legacy inspector/library | ||
| 201 | +/// pair). What degrades *inside* fixed width is the two tabs' own content: | ||
| 202 | +/// Sources hands off to `library.rs`'s own row anatomy and ladder; Clip's | ||
| 203 | +/// param rows are whatever their card already draws at this width. | ||
| 204 | +pub(crate) fn render(player: &Player, width: f32, window_h: Pixels, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 205 | + let src_active = DOCK_SRC_ACTIVE.load(Ordering::Relaxed); | ||
| 206 | + div() | ||
| 207 | + .id("stance-dock-body") | ||
| 208 | + .flex_1() | ||
| 209 | + .min_h(px(0.)) | ||
| 210 | + .flex() | ||
| 211 | + .flex_col() | ||
| 212 | + .child( | ||
| 213 | + div() | ||
| 214 | + .id("stance-dock-tabs") | ||
| 215 | + .flex_none() | ||
| 216 | + .flex() | ||
| 217 | + .gap(px(4.)) | ||
| 218 | + .p(px(8.)) | ||
| 219 | + .border_b_1() | ||
| 220 | + .border_color(rgb(DARK_HAIRLINE())) | ||
| 221 | + .child(dock_tab("dock-tab-src", "Src", src_active, cx)) | ||
| 222 | + .child(dock_tab("dock-tab-clip", "Clip", !src_active, cx)), | ||
| 223 | + ) | ||
| 224 | + .child(match src_active { | ||
| 225 | + true => sources_tab(player, width, cx).into_any_element(), | ||
| 226 | + false => clip_tab(player, width, window_h, cx).into_any_element(), | ||
| 227 | + }) | ||
| 228 | +} | ||
crates/app/src/ui/mod.rsmodified+1 -0
| @@ -4,6 +4,7 @@ | |||
| 4 | //! which is why a colour or a rule fixed in one place kept surviving in the | 4 | //! which is why a colour or a rule fixed in one place kept surviving in the |
| 5 | //! next: there was no seam to sweep. The seams are the regions themselves. | 5 | //! next: there was no seam to sweep. The seams are the regions themselves. |
| 6 | pub mod cards; | 6 | pub mod cards; |
| 7 | +pub mod dock_stance; | ||
| 7 | pub mod inspector; | 8 | pub mod inspector; |
| 8 | pub mod library; | 9 | pub mod library; |
| 9 | pub mod overlays; | 10 | pub mod overlays; |
crates/app/src/ui/preview.rsmodified+86 -0
| @@ -310,6 +310,92 @@ impl Player { | |||
| 310 | } | 310 | } |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | + /// Two-up OUT|IN judging (DESIGN.md §6): drawn over the screen only when | ||
| 314 | + /// the playhead rests exactly on one edge of the subject cut -- the | ||
| 315 | + /// outgoing clip's tail beside the incoming one's head, whichever edge | ||
| 316 | + /// the playhead is on. `None` off a cut, off the darkroom path, or with | ||
| 317 | + /// nothing marked, so the legacy picture and a mid-clip darkroom picture | ||
| 318 | + /// both draw untouched. | ||
| 319 | + /// | ||
| 320 | + /// corner-cut: each side names its neighbour (source, timecode) on a | ||
| 321 | + /// plate rather than decoding its edge frame into a second picture -- | ||
| 322 | + /// the pixel-accurate two-up wants a frame read off the *other* clip's | ||
| 323 | + /// span while the shown picture is the marked one's, which is a second | ||
| 324 | + /// decode this step does not open. Upgrade path: a still pulled from the | ||
| 325 | + /// neighbour's edge frame ([`engine::PlaybackSession::video_source_frame_at`] | ||
| 326 | + /// is the same lookup [`Player::live_decode`] already makes) in place of | ||
| 327 | + /// the plate's text. | ||
| 328 | + pub(crate) fn two_up(&self) -> Option<impl IntoElement> { | ||
| 329 | + if !self.darkroom { | ||
| 330 | + return None; | ||
| 331 | + } | ||
| 332 | + let (lane, idx) = self.selected.anchor()?; | ||
| 333 | + let session = self.session.as_ref()?; | ||
| 334 | + let clips = session.lane_clips(lane); | ||
| 335 | + let clip = clips.get(idx)?; | ||
| 336 | + let now = frame_at(session.now(), self.fps); | ||
| 337 | + let name_of = |source: usize| { | ||
| 338 | + session | ||
| 339 | + .sources() | ||
| 340 | + .get(source) | ||
| 341 | + .map_or_else(|| "?".to_string(), |s| file_name(&s.path)) | ||
| 342 | + }; | ||
| 343 | + // Which edge, if either, the playhead is resting on -- the one | ||
| 344 | + // question "at rest on a cut" is. | ||
| 345 | + let (out_label, in_label) = if now == clip.start { | ||
| 346 | + let out = idx | ||
| 347 | + .checked_sub(1) | ||
| 348 | + .and_then(|i| clips.get(i)) | ||
| 349 | + .map_or("— nothing before it".to_string(), |c| { | ||
| 350 | + format!("{} @{}", name_of(c.source), c.end()) | ||
| 351 | + }); | ||
| 352 | + (out, format!("{} @{}", name_of(clip.source), clip.start)) | ||
| 353 | + } else if now == clip.end() { | ||
| 354 | + let inn = clips | ||
| 355 | + .get(idx + 1) | ||
| 356 | + .map_or("— nothing after it".to_string(), |c| { | ||
| 357 | + format!("{} @{}", name_of(c.source), c.start) | ||
| 358 | + }); | ||
| 359 | + (format!("{} @{}", name_of(clip.source), clip.end()), inn) | ||
| 360 | + } else { | ||
| 361 | + return None; | ||
| 362 | + }; | ||
| 363 | + let plate = |label: &str, text: String| { | ||
| 364 | + div() | ||
| 365 | + .flex_1() | ||
| 366 | + .flex() | ||
| 367 | + .flex_col() | ||
| 368 | + .gap(px(4.)) | ||
| 369 | + .p(px(8.)) | ||
| 370 | + .bg(rgb(DARK_CANVAS())) | ||
| 371 | + .rounded(px(2.)) | ||
| 372 | + .child( | ||
| 373 | + div() | ||
| 374 | + .text_size(px(9.)) | ||
| 375 | + .text_color(rgb(INK3())) | ||
| 376 | + .child(label.to_string()), | ||
| 377 | + ) | ||
| 378 | + .child( | ||
| 379 | + div() | ||
| 380 | + .text_size(px(10.5)) | ||
| 381 | + .text_color(rgb(INK1())) | ||
| 382 | + .child(text), | ||
| 383 | + ) | ||
| 384 | + }; | ||
| 385 | + Some( | ||
| 386 | + div() | ||
| 387 | + .absolute() | ||
| 388 | + .bottom_0() | ||
| 389 | + .left_0() | ||
| 390 | + .right_0() | ||
| 391 | + .flex() | ||
| 392 | + .gap(px(1.)) | ||
| 393 | + .p(px(8.)) | ||
| 394 | + .child(plate("OUT", out_label)) | ||
| 395 | + .child(plate("IN", in_label)), | ||
| 396 | + ) | ||
| 397 | + } | ||
| 398 | + | ||
| 313 | /// What is decoding the picture right now, for the transport line: the | 399 | /// What is decoding the picture right now, for the transport line: the |
| 314 | /// backend is the running worker's own (it is written where a hardware | 400 | /// backend is the running worker's own (it is written where a hardware |
| 315 | /// session falls back to software, so this follows reality), and the codec | 401 | /// session falls back to software, so this follows reality), and the codec |
crates/app/src/ui/stance.rsmodified+133 -54
| @@ -8,6 +8,7 @@ | |||
| 8 | //! later steps in DESIGN §12's package attach. | 8 | //! later steps in DESIGN §12's package attach. |
| 9 | 9 | ||
| 10 | use crate::*; | 10 | use crate::*; |
| 11 | +use crate::ui::dock_stance; | ||
| 11 | 12 | ||
| 12 | /// Left rail, full height (DESIGN §5). | 13 | /// Left rail, full height (DESIGN §5). |
| 13 | const SPINE_W: f32 = 56.; | 14 | const SPINE_W: f32 = 56.; |
| @@ -33,9 +34,34 @@ fn section_head(label: &str) -> impl IntoElement { | |||
| 33 | .child(label.to_uppercase()) | 34 | .child(label.to_uppercase()) |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | -/// The spine: 56px, left, full height. Every command as ghost glyph + chord | 37 | +/// A ghost command (DESIGN §4): borderless glyph (`ink2`) + dim chord |
| 37 | -/// lands here later, grouped by task frequency (DESIGN §5). | 38 | +/// (`ink3`), read live off the keymap so a rebind can never leave the spine |
| 38 | -fn spine() -> impl IntoElement { | 39 | +/// showing a stroke that no longer fires it. |
| 40 | +fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { | ||
| 41 | + div() | ||
| 42 | + .flex_none() | ||
| 43 | + .flex() | ||
| 44 | + .flex_col() | ||
| 45 | + .items_center() | ||
| 46 | + .gap(px(2.)) | ||
| 47 | + .py(px(6.)) | ||
| 48 | + .rounded(px(3.)) | ||
| 49 | + .text_size(px(13.)) | ||
| 50 | + .text_color(rgb(INK2())) | ||
| 51 | + .child(glyph.to_string()) | ||
| 52 | + .child( | ||
| 53 | + div() | ||
| 54 | + .text_size(px(9.5)) | ||
| 55 | + .text_color(rgb(INK3())) | ||
| 56 | + .child(player.keymap.display(action)), | ||
| 57 | + ) | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +/// The spine: 56px, left, full height. Every command as ghost glyph + chord, | ||
| 61 | +/// grouped by task frequency (DESIGN §5) -- transport first (every second), | ||
| 62 | +/// then the cut machinery (DESIGN §6, every cut), then the split and the one | ||
| 63 | +/// boxed exception is left to the time band, which is where Export lives. | ||
| 64 | +fn spine(player: &Player) -> impl IntoElement { | ||
| 39 | div() | 65 | div() |
| 40 | .id("stance-spine") | 66 | .id("stance-spine") |
| 41 | .flex_none() | 67 | .flex_none() |
| @@ -48,30 +74,53 @@ fn spine() -> impl IntoElement { | |||
| 48 | .flex_col() | 74 | .flex_col() |
| 49 | .items_center() | 75 | .items_center() |
| 50 | .py(px(8.)) | 76 | .py(px(8.)) |
| 77 | + .gap(px(4.)) | ||
| 51 | .child(section_head("spine")) | 78 | .child(section_head("spine")) |
| 52 | - // hook: §12 step 3 -- ghost glyph + chord per command, task-frequency order. | 79 | + .child(ghost(player, "▶", ActionId::Play)) |
| 80 | + .child(ghost(player, "‹", ActionId::WalkCutPrev)) | ||
| 81 | + .child(ghost(player, "›", ActionId::WalkCutNext)) | ||
| 82 | + .child(ghost(player, "[", ActionId::TrimIn)) | ||
| 83 | + .child(ghost(player, "]", ActionId::TrimOut)) | ||
| 84 | + .child(ghost(player, "↻", ActionId::LoopTrim)) | ||
| 85 | + .child(ghost(player, "✂", ActionId::Cut)) | ||
| 53 | } | 86 | } |
| 54 | 87 | ||
| 55 | /// The picture region: top of the centre column, takes the remaining space, | 88 | /// The picture region: top of the centre column, takes the remaining space, |
| 56 | -/// never occluded (DESIGN §5). | 89 | +/// never occluded (DESIGN §5). Reuses [`Player::picture_area`] rather than a |
| 57 | -fn screen() -> impl IntoElement { | 90 | +/// second image element -- the darkroom draws the same picture the legacy |
| 91 | +/// tree does -- and layers the two-up OUT|IN judging over it at rest on a | ||
| 92 | +/// cut (DESIGN §6). | ||
| 93 | +fn screen(player: &mut Player, position: f64, window: &mut Window, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 58 | div() | 94 | div() |
| 59 | .id("stance-screen") | 95 | .id("stance-screen") |
| 60 | .flex_1() | 96 | .flex_1() |
| 61 | .min_h(px(0.)) | 97 | .min_h(px(0.)) |
| 98 | + .relative() | ||
| 62 | // §4: room chrome takes 0 radius. | 99 | // §4: room chrome takes 0 radius. |
| 63 | .rounded(px(0.)) | 100 | .rounded(px(0.)) |
| 64 | .bg(rgb(DARK_CANVAS())) | 101 | .bg(rgb(DARK_CANVAS())) |
| 65 | - .flex() | 102 | + .child(player.picture_area(position, window, cx)) |
| 66 | - .items_center() | 103 | + .children(player.two_up()) |
| 67 | - .justify_center() | ||
| 68 | - .child(section_head("screen")) | ||
| 69 | - // hook: §12 step 3 -- the picture, and two-up OUT|IN judging at rest on a cut. | ||
| 70 | } | 104 | } |
| 71 | 105 | ||
| 72 | /// Fixed-height strip under the screen: timecode leads, ghost transport, cut | 106 | /// Fixed-height strip under the screen: timecode leads, ghost transport, cut |
| 73 | /// readout, the contact strip, boxed Export at the end (DESIGN §5). | 107 | /// readout, the contact strip, boxed Export at the end (DESIGN §5). |
| 74 | -fn time_band() -> impl IntoElement { | 108 | +fn time_band(player: &Player) -> impl IntoElement { |
| 109 | + let position = player.active_session().map_or(0., PlaybackSession::now); | ||
| 110 | + let tc = timecode(position, player.active_fps()); | ||
| 111 | + // The odometer (DESIGN §6): the subject cut's own place among its | ||
| 112 | + // lane's, or an empty readout with nothing marked -- a plate that reads | ||
| 113 | + // blank rather than one that lies about a cut zero. | ||
| 114 | + let readout = player | ||
| 115 | + .selected | ||
| 116 | + .anchor() | ||
| 117 | + .and_then(|(lane, idx)| { | ||
| 118 | + player | ||
| 119 | + .session | ||
| 120 | + .as_ref() | ||
| 121 | + .map(|s| format!("{}/{}", idx + 1, s.lane_clips(lane).len())) | ||
| 122 | + }) | ||
| 123 | + .unwrap_or_else(|| "—/—".to_string()); | ||
| 75 | div() | 124 | div() |
| 76 | .id("stance-time-band") | 125 | .id("stance-time-band") |
| 77 | .flex_none() | 126 | .flex_none() |
| @@ -81,9 +130,46 @@ fn time_band() -> impl IntoElement { | |||
| 81 | .border_color(rgb(DARK_SEAM())) | 130 | .border_color(rgb(DARK_SEAM())) |
| 82 | .flex() | 131 | .flex() |
| 83 | .items_center() | 132 | .items_center() |
| 133 | + .gap(px(16.)) | ||
| 84 | .px(px(12.)) | 134 | .px(px(12.)) |
| 85 | - .child(section_head("time band")) | 135 | + // The most-read element anchors its region (DESIGN §5): the |
| 86 | - // hook: §12 step 3 -- timecode, ghost transport, cut readout, contact strip, Export. | 136 | + // timecode leads, 13px hero, 700, colons in `ink3`. |
| 137 | + .child( | ||
| 138 | + div() | ||
| 139 | + .text_size(px(13.)) | ||
| 140 | + .text_color(rgb(INK1())) | ||
| 141 | + .child(tc), | ||
| 142 | + ) | ||
| 143 | + .child(ghost(player, if player.transport().is_playing() { "❚❚" } else { "▶" }, ActionId::Play)) | ||
| 144 | + // The cut readout: a plate, mono, the odometer DESIGN §6 asks for. | ||
| 145 | + .child( | ||
| 146 | + div() | ||
| 147 | + .flex_none() | ||
| 148 | + .px(px(8.)) | ||
| 149 | + .py(px(4.)) | ||
| 150 | + .rounded(px(2.)) | ||
| 151 | + .bg(rgb(DARK_CANVAS())) | ||
| 152 | + .text_size(px(10.5)) | ||
| 153 | + .text_color(rgb(INK1())) | ||
| 154 | + .child(readout), | ||
| 155 | + ) | ||
| 156 | + .child(div().flex_1()) | ||
| 157 | + // Boxed Export: the one bordered control on the surface (DESIGN §4). | ||
| 158 | + .child( | ||
| 159 | + div() | ||
| 160 | + .id("stance-export") | ||
| 161 | + .flex_none() | ||
| 162 | + .px(px(10.)) | ||
| 163 | + .py(px(6.)) | ||
| 164 | + .rounded(px(3.)) | ||
| 165 | + .border_1() | ||
| 166 | + .border_color(rgb(DARK_HAIRLINE())) | ||
| 167 | + .bg(rgb(DARK_RAISED())) | ||
| 168 | + .text_size(px(10.5)) | ||
| 169 | + .text_color(rgb(INK1())) | ||
| 170 | + .cursor_pointer() | ||
| 171 | + .child(format!("Export ({})", player.keymap.display(ActionId::Export))), | ||
| 172 | + ) | ||
| 87 | } | 173 | } |
| 88 | 174 | ||
| 89 | /// Lanes, under the time band. `canvas` is the bench background too (DESIGN | 175 | /// Lanes, under the time band. `canvas` is the bench background too (DESIGN |
| @@ -122,22 +208,10 @@ fn ledger() -> impl IntoElement { | |||
| 122 | // hook: §12 step 7 -- project identity/state, last action, export progress, notices. | 208 | // hook: §12 step 7 -- project identity/state, last action, export progress, notices. |
| 123 | } | 209 | } |
| 124 | 210 | ||
| 125 | -/// One tab of the dock's Src/Clip pair -- a plate (2px radius), `ink1` when | ||
| 126 | -/// active and `ink2` at rest, never a hue (DESIGN §4). | ||
| 127 | -fn dock_tab(label: &str, active: bool) -> impl IntoElement { | ||
| 128 | - div() | ||
| 129 | - .flex_1() | ||
| 130 | - .rounded(px(2.)) | ||
| 131 | - .py(px(6.)) | ||
| 132 | - .text_size(px(10.5)) | ||
| 133 | - .text_color(rgb(if active { INK1() } else { INK2() })) | ||
| 134 | - .bg(rgb(if active { DARK_RAISED() } else { DARK_PANEL() })) | ||
| 135 | - .child(label.to_string()) | ||
| 136 | -} | ||
| 137 | - | ||
| 138 | /// The dock: the only side panel, right, fixed width, carrying the Src/Clip | 211 | /// The dock: the only side panel, right, fixed width, carrying the Src/Clip |
| 139 | -/// tab pair (DESIGN §5). | 212 | +/// tab pair (DESIGN §5). The frame is drawn here; `dock_stance.rs` owns the |
| 140 | -fn dock() -> impl IntoElement { | 213 | +/// tab row and both tabs' content (DESIGN §12 step 4). |
| 214 | +fn dock(player: &Player, window_h: Pixels, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 141 | div() | 215 | div() |
| 142 | .id("stance-dock") | 216 | .id("stance-dock") |
| 143 | .flex_none() | 217 | .flex_none() |
| @@ -148,38 +222,43 @@ fn dock() -> impl IntoElement { | |||
| 148 | .border_color(rgb(DARK_SEAM())) | 222 | .border_color(rgb(DARK_SEAM())) |
| 149 | .flex() | 223 | .flex() |
| 150 | .flex_col() | 224 | .flex_col() |
| 151 | - .child( | 225 | + .child(dock_stance::render(player, DOCK_W, window_h, cx)) |
| 152 | - div() | ||
| 153 | - .id("stance-dock-tabs") | ||
| 154 | - .flex_none() | ||
| 155 | - .flex() | ||
| 156 | - .gap(px(4.)) | ||
| 157 | - .p(px(8.)) | ||
| 158 | - .border_b_1() | ||
| 159 | - .border_color(rgb(DARK_HAIRLINE())) | ||
| 160 | - .child(dock_tab("Src", true)) | ||
| 161 | - .child(dock_tab("Clip", false)), | ||
| 162 | - ) | ||
| 163 | - .child(section_head("dock")) | ||
| 164 | - // hook: §12 step 4 -- Sources assembly (filter, usage chips, import) / Clip verbs | ||
| 165 | - // (Speed / Colour / Transform / EQ as ghost verbs over param rows). | ||
| 166 | } | 226 | } |
| 167 | 227 | ||
| 168 | /// The whole stance: spine, screen, time band, bench, ledger, dock, in the | 228 | /// The whole stance: spine, screen, time band, bench, ledger, dock, in the |
| 169 | -/// order DESIGN §5 draws them. `player` and the window/context pair are | 229 | +/// order DESIGN §5 draws them, over the same key handler the legacy tree |
| 170 | -/// unread by this skeleton -- later steps in the §12 package are what fill | 230 | +/// uses (DESIGN §12 step 3): the darkroom draws its own regions but answers |
| 171 | -/// each region from live state (cut position, dock tab, lane contents). | 231 | +/// to the one keymap, `shift` threaded through for the odometer's stride |
| 232 | +/// ([`Player::walk_shift`]) since [`ActionId`] carries no modifier of its | ||
| 233 | +/// own. | ||
| 172 | pub(crate) fn render( | 234 | pub(crate) fn render( |
| 173 | - _player: &mut Player, | 235 | + player: &mut Player, |
| 174 | - _window: &mut Window, | 236 | + window: &mut Window, |
| 175 | - _cx: &mut Context<Player>, | 237 | + cx: &mut Context<Player>, |
| 176 | ) -> impl IntoElement { | 238 | ) -> impl IntoElement { |
| 239 | + let window_h = window.viewport_size().height; | ||
| 240 | + let position = player.playhead(player.drawn_duration()); | ||
| 177 | div() | 241 | div() |
| 178 | .id("stance-room") | 242 | .id("stance-room") |
| 243 | + .track_focus(&player.focus) | ||
| 244 | + .on_key_down(cx.listener(|this, event: &KeyDownEvent, window, cx| { | ||
| 245 | + let key = event.keystroke.key.as_str(); | ||
| 246 | + let ctrl = event.keystroke.modifiers.control; | ||
| 247 | + if event.is_held && !repeats(this.repeat_scope(), key, this.keymap.lookup(key, ctrl)) { | ||
| 248 | + return; | ||
| 249 | + } | ||
| 250 | + if this.dismiss_notice() { | ||
| 251 | + cx.notify(); | ||
| 252 | + } | ||
| 253 | + this.walk_shift = event.keystroke.modifiers.shift; | ||
| 254 | + if let Some(action) = this.keymap.lookup(key, ctrl) { | ||
| 255 | + this.act(action, window, cx); | ||
| 256 | + } | ||
| 257 | + })) | ||
| 179 | .size_full() | 258 | .size_full() |
| 180 | .flex() | 259 | .flex() |
| 181 | .bg(rgb(DARK_CANVAS())) | 260 | .bg(rgb(DARK_CANVAS())) |
| 182 | - .child(spine()) | 261 | + .child(spine(player)) |
| 183 | .child( | 262 | .child( |
| 184 | div() | 263 | div() |
| 185 | .id("stance-centre") | 264 | .id("stance-centre") |
| @@ -187,10 +266,10 @@ pub(crate) fn render( | |||
| 187 | .min_w(px(0.)) | 266 | .min_w(px(0.)) |
| 188 | .flex() | 267 | .flex() |
| 189 | .flex_col() | 268 | .flex_col() |
| 190 | - .child(screen()) | 269 | + .child(screen(player, position, window, cx)) |
| 191 | - .child(time_band()) | 270 | + .child(time_band(player)) |
| 192 | .child(bench()) | 271 | .child(bench()) |
| 193 | .child(ledger()), | 272 | .child(ledger()), |
| 194 | ) | 273 | ) |
| 195 | - .child(dock()) | 274 | + .child(dock(player, window_h, cx)) |
| 196 | } | 275 | } |