The strip shows the film and the transport answers the mouse
Browse files at this commit420fdc8f93c242f88fcdd9e8b5c93f1c2ab85bbbParent: d5dd5fc- style
- the strip shows the film and the transport answers the mouse
4 changed files +317 -46
- crates/app/src/ui/dock_stance.rs +7 -1
- crates/app/src/ui/spine_stance.rs +83 -25
- crates/app/src/ui/stance.rs +102 -1
- crates/app/src/ui/timeband_stance.rs +125 -19
crates/app/src/ui/dock_stance.rsmodified+7 -1
| @@ -468,9 +468,15 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 468 | )), | 468 | )), |
| 469 | ) | 469 | ) |
| 470 | .child({ | 470 | .child({ |
| 471 | - let style = mono(9., FontWeight::MEDIUM); | 471 | + // FAULT 2: metadata, not a row -- DESIGN §3's 9.5-10px band via |
| 472 | + // the named constant (a bespoke 9px literal was neither the | ||
| 473 | + // metadata size nor any other named role), and the quietest text | ||
| 474 | + // in the dock: ink3, tight leading so it never competes with the | ||
| 475 | + // 10.5px source rows above it. | ||
| 476 | + let style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); | ||
| 472 | div() | 477 | div() |
| 473 | .flex_none() | 478 | .flex_none() |
| 479 | + .line_height(relative(1.25)) | ||
| 474 | .font(style.font) | 480 | .font(style.font) |
| 475 | .text_size(style.size) | 481 | .text_size(style.size) |
| 476 | .text_color(rgb(INK3())) | 482 | .text_color(rgb(INK3())) |
crates/app/src/ui/spine_stance.rsmodified+83 -25
| @@ -21,7 +21,8 @@ const GLYPH_SIZE: f32 = 13.; | |||
| 21 | fn group_head(label: &str) -> impl IntoElement { | 21 | fn group_head(label: &str) -> impl IntoElement { |
| 22 | div() | 22 | div() |
| 23 | .flex_none() | 23 | .flex_none() |
| 24 | - .pt(px(10.)) | 24 | + .pt(px(6.)) |
| 25 | + .line_height(relative(1.1)) | ||
| 25 | .type_style(type_scale::head()) | 26 | .type_style(type_scale::head()) |
| 26 | .text_color(rgb(INK3())) | 27 | .text_color(rgb(INK3())) |
| 27 | .child(label.to_uppercase()) | 28 | .child(label.to_uppercase()) |
| @@ -63,26 +64,30 @@ fn glyph( | |||
| 63 | .items_center() | 64 | .items_center() |
| 64 | .gap(px(1.)) | 65 | .gap(px(1.)) |
| 65 | .px(px(4.)) | 66 | .px(px(4.)) |
| 66 | - .py(px(2.)) | 67 | + .py(px(1.)) |
| 67 | .rounded(px(3.)) | 68 | .rounded(px(3.)) |
| 68 | .when(active, |d| d.bg(rgb(DARK_RAISED()))) | 69 | .when(active, |d| d.bg(rgb(DARK_RAISED()))) |
| 69 | .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) | 70 | .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) |
| 70 | .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) | 71 | .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) |
| 71 | .when(on, |d| { | 72 | .when(on, |d| { |
| 72 | d.cursor_pointer() | 73 | d.cursor_pointer() |
| 73 | - .hover(|s| s.bg(rgb(DARK_RAISED()))) | 74 | + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) |
| 74 | .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { | 75 | .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { |
| 75 | this.act(action, window, cx) | 76 | this.act(action, window, cx) |
| 76 | })) | 77 | })) |
| 77 | }) | 78 | }) |
| 78 | .child( | 79 | .child( |
| 79 | div() | 80 | div() |
| 80 | - .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::MEDIUM)) | 81 | + .line_height(relative(1.05)) |
| 82 | + // FAULT 1: the glyph is the loudest thing in its row -- BOLD, | ||
| 83 | + // not the MEDIUM weight the chord beneath it also wears. | ||
| 84 | + .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::BOLD)) | ||
| 81 | .text_color(rgb(if active { INK1() } else { INK2() })) | 85 | .text_color(rgb(if active { INK1() } else { INK2() })) |
| 82 | .child(glyph), | 86 | .child(glyph), |
| 83 | ) | 87 | ) |
| 84 | .child( | 88 | .child( |
| 85 | div() | 89 | div() |
| 90 | + .line_height(relative(1.05)) | ||
| 86 | .type_style(type_scale::mono( | 91 | .type_style(type_scale::mono( |
| 87 | type_scale::CHORD_METADATA_MIN_PX, | 92 | type_scale::CHORD_METADATA_MIN_PX, |
| 88 | gpui::FontWeight::MEDIUM, | 93 | gpui::FontWeight::MEDIUM, |
| @@ -92,6 +97,74 @@ fn glyph( | |||
| 92 | ) | 97 | ) |
| 93 | } | 98 | } |
| 94 | 99 | ||
| 100 | +/// The trim control (MOCK-SPEC "Spine"): one row read as ONE control with | ||
| 101 | +/// two strokes, not two identical `±1` boxes each carrying its own `[`/`]` | ||
| 102 | +/// chord underneath (the shipped defect this replaces). `−1`/`+1` distinguish | ||
| 103 | +/// the two strokes visually where a doubled `±1` couldn't; the chord line | ||
| 104 | +/// beneath is shared and shows both strokes together (`[ ]`), the way the | ||
| 105 | +/// mock's single `±1` / `[ ]` pair reads as one thing, not two. | ||
| 106 | +fn trim_control(active: bool, player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 107 | + let half = |id: &'static str, txt: &'static str, action: ActionId, cx: &mut Context<Player>| { | ||
| 108 | + let enabled = player.enable(action, None); | ||
| 109 | + let full = player.keymap.display(action); | ||
| 110 | + let say: SharedString = match enabled.why() { | ||
| 111 | + Some(why) => format!("{full} — {why}"), | ||
| 112 | + None => format!("{full} — {}", action.label()), | ||
| 113 | + } | ||
| 114 | + .into(); | ||
| 115 | + let on = enabled.yes(); | ||
| 116 | + div() | ||
| 117 | + .id(id) | ||
| 118 | + .flex_none() | ||
| 119 | + .px(px(2.)) | ||
| 120 | + .rounded(px(3.)) | ||
| 121 | + .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) | ||
| 122 | + .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) | ||
| 123 | + .when(on, |d| { | ||
| 124 | + d.cursor_pointer() | ||
| 125 | + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) | ||
| 126 | + .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { | ||
| 127 | + this.act(action, window, cx) | ||
| 128 | + })) | ||
| 129 | + }) | ||
| 130 | + .child( | ||
| 131 | + div() | ||
| 132 | + .line_height(relative(1.05)) | ||
| 133 | + .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::BOLD)) | ||
| 134 | + .text_color(rgb(if active { INK1() } else { INK2() })) | ||
| 135 | + .child(txt), | ||
| 136 | + ) | ||
| 137 | + }; | ||
| 138 | + div() | ||
| 139 | + .flex_none() | ||
| 140 | + .flex() | ||
| 141 | + .flex_col() | ||
| 142 | + .items_center() | ||
| 143 | + .gap(px(1.)) | ||
| 144 | + .px(px(4.)) | ||
| 145 | + .py(px(1.)) | ||
| 146 | + .rounded(px(3.)) | ||
| 147 | + .when(active, |d| d.bg(rgb(DARK_RAISED()))) | ||
| 148 | + .child( | ||
| 149 | + div() | ||
| 150 | + .flex() | ||
| 151 | + .items_center() | ||
| 152 | + .gap(px(2.)) | ||
| 153 | + .child(half("spine-trim-in", "−1", ActionId::TrimIn, cx)) | ||
| 154 | + .child(half("spine-trim-out", "+1", ActionId::TrimOut, cx)), | ||
| 155 | + ) | ||
| 156 | + .child( | ||
| 157 | + div() | ||
| 158 | + .line_height(relative(1.05)) | ||
| 159 | + .type_style(type_scale::mono( | ||
| 160 | + type_scale::CHORD_METADATA_MIN_PX, | ||
| 161 | + gpui::FontWeight::MEDIUM, | ||
| 162 | + )) | ||
| 163 | + .text_color(rgb(INK3())) | ||
| 164 | + .child("[ ]"), | ||
| 165 | + ) | ||
| 166 | +} | ||
| 167 | + | ||
| 95 | /// Two commands side by side in one row -- the opposite-direction pairs | 168 | /// Two commands side by side in one row -- the opposite-direction pairs |
| 96 | /// (walk cuts, no-aim trim) that share a row in the mock rather than each | 169 | /// (walk cuts, no-aim trim) that share a row in the mock rather than each |
| 97 | /// eating a full row of the spine's own height. | 170 | /// eating a full row of the spine's own height. |
| @@ -128,10 +201,12 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | |||
| 128 | .flex() | 201 | .flex() |
| 129 | .flex_col() | 202 | .flex_col() |
| 130 | .items_center() | 203 | .items_center() |
| 131 | - // FAULT 2: rows close under their group head, real space (the group | 204 | + // FAULT 1: rows close under their group head, real space (the group |
| 132 | // head's own `pt`) only between one group and the next -- not one | 205 | // head's own `pt`) only between one group and the next -- not one |
| 133 | - // uniform gap stretching every row down the window. | 206 | + // uniform gap stretching every row down the window. The gap itself |
| 134 | - .gap(px(2.)) | 207 | + // is now the smallest gpui will draw (1px) rather than the 2px that |
| 208 | + // still read as "spread" against the mock's tight top-third rail. | ||
| 209 | + .gap(px(1.)) | ||
| 135 | .overflow_y_scroll() | 210 | .overflow_y_scroll() |
| 136 | .child(group_head("edit")) | 211 | .child(group_head("edit")) |
| 137 | .child(glyph("spine-split", "||", ActionId::Cut, false, player, cx)) | 212 | .child(glyph("spine-split", "||", ActionId::Cut, false, player, cx)) |
| @@ -142,24 +217,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | |||
| 142 | glyph("spine-cut-prev", "‹", ActionId::WalkCutPrev, false, player, cx), | 217 | glyph("spine-cut-prev", "‹", ActionId::WalkCutPrev, false, player, cx), |
| 143 | glyph("spine-cut-next", "›", ActionId::WalkCutNext, false, player, cx), | 218 | glyph("spine-cut-next", "›", ActionId::WalkCutNext, false, player, cx), |
| 144 | )) | 219 | )) |
| 145 | - .child(pair( | 220 | + .child(trim_control(player.loop_trim.is_some(), player, cx)) |
| 146 | - glyph( | ||
| 147 | - "spine-trim-in", | ||
| 148 | - "±1", | ||
| 149 | - ActionId::TrimIn, | ||
| 150 | - player.loop_trim.is_some(), | ||
| 151 | - player, | ||
| 152 | - cx, | ||
| 153 | - ), | ||
| 154 | - glyph( | ||
| 155 | - "spine-trim-out", | ||
| 156 | - "±1", | ||
| 157 | - ActionId::TrimOut, | ||
| 158 | - player.loop_trim.is_some(), | ||
| 159 | - player, | ||
| 160 | - cx, | ||
| 161 | - ), | ||
| 162 | - )) | ||
| 163 | .child(glyph( | 221 | .child(glyph( |
| 164 | "spine-loop-trim", | 222 | "spine-loop-trim", |
| 165 | "↻", | 223 | "↻", |
crates/app/src/ui/stance.rsmodified+102 -1
| @@ -31,6 +31,93 @@ const LEDGER_H: f32 = 28.; | |||
| 31 | /// Right side panel, fixed width, carrying the Src/Clip tab pair. | 31 | /// Right side panel, fixed width, carrying the Src/Clip tab pair. |
| 32 | const DOCK_W: f32 = 280.; | 32 | const DOCK_W: f32 = 280.; |
| 33 | 33 | ||
| 34 | +thread_local! { | ||
| 35 | + // FAULT 3: the picture region's own laid-out box, measured each frame by | ||
| 36 | + // a [`bounds_probe`] the same shape `timeband_stance`'s contact strip | ||
| 37 | + // keeps (`STRIP_BOUNDS`) -- the scale plate needs the box the picture was | ||
| 38 | + // fitted into, which nothing upstream of paint knows. | ||
| 39 | + static PICTURE_BOUNDS: Rc<Cell<Bounds<Pixels>>> = Rc::new(Cell::new(Bounds::default())); | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +/// The pure half of [`picture_scale`]: given a box and the image's native | ||
| 43 | +/// size, its `Contain` fit factor -- gpui's own tested `get_bounds` math | ||
| 44 | +/// ([`letterboxed_image`] fits the picture the same way), not a ratio | ||
| 45 | +/// reimplemented here. Split out from `picture_scale` so this arithmetic has | ||
| 46 | +/// a runnable check with no `Player`/window to stand up. | ||
| 47 | +fn fit_scale(bounds: Bounds<Pixels>, native: gpui::Size<gpui::DevicePixels>) -> Option<f32> { | ||
| 48 | + if bounds.size.width <= px(0.) || bounds.size.height <= px(0.) || native.width.0 <= 0 || native.height.0 <= 0 { | ||
| 49 | + return None; | ||
| 50 | + } | ||
| 51 | + let fitted = gpui::ObjectFit::Contain.get_bounds(bounds, native); | ||
| 52 | + Some(f32::from(fitted.size.width) / native.width.0 as f32) | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +/// The picture's own fit factor against its native size, read off the last | ||
| 56 | +/// frame's measured box (see [`PICTURE_BOUNDS`]). `None` with nothing open | ||
| 57 | +/// or before the first paint has measured anything. | ||
| 58 | +fn picture_scale(player: &Player) -> Option<f32> { | ||
| 59 | + let image = player.image.clone()?; | ||
| 60 | + fit_scale(PICTURE_BOUNDS.with(Rc::clone).get(), image.size(0)) | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +#[cfg(test)] | ||
| 64 | +mod tests { | ||
| 65 | + use super::*; | ||
| 66 | + | ||
| 67 | + /// A 400x100 source fit into a 200x100 box: width-bound (bounds_ratio | ||
| 68 | + /// 2 < image_ratio 4), so the picture lands at half its native width -- | ||
| 69 | + /// the number the scale plate would read as `scale 0.50`. | ||
| 70 | + #[test] | ||
| 71 | + fn the_scale_plate_reads_contains_own_fit_factor() { | ||
| 72 | + let bounds = Bounds { | ||
| 73 | + origin: point(px(0.), px(0.)), | ||
| 74 | + size: size(px(200.), px(100.)), | ||
| 75 | + }; | ||
| 76 | + let native = size(gpui::DevicePixels(400), gpui::DevicePixels(100)); | ||
| 77 | + assert!((fit_scale(bounds, native).unwrap() - 0.5).abs() < 0.001); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /// A degenerate (zero-size) box never divides by zero -- it says "no | ||
| 81 | + /// reading yet" instead of NaN or a panic, the same guard every other | ||
| 82 | + /// `bounds_probe`-fed measurement in this file makes before its first | ||
| 83 | + /// paint. | ||
| 84 | + #[test] | ||
| 85 | + fn an_unmeasured_box_reads_no_scale_rather_than_nan() { | ||
| 86 | + let bounds = Bounds { | ||
| 87 | + origin: point(px(0.), px(0.)), | ||
| 88 | + size: size(px(0.), px(0.)), | ||
| 89 | + }; | ||
| 90 | + let native = size(gpui::DevicePixels(400), gpui::DevicePixels(100)); | ||
| 91 | + assert_eq!(fit_scale(bounds, native), None); | ||
| 92 | + } | ||
| 93 | +} | ||
| 94 | + | ||
| 95 | +/// The scale plate (MOCK-SPEC.md "Screen": `scale 1.12`, label `ink3`, value | ||
| 96 | +/// in ink): a readout, so a plate (DESIGN §4), never a chip. Lives in the | ||
| 97 | +/// screen region's own margin row above the picture -- a flex sibling, not | ||
| 98 | +/// an overlay, so it can never cover a picture pixel (§11 check 6) whatever | ||
| 99 | +/// the source's aspect ratio does to the letterbox. | ||
| 100 | +fn scale_plate(player: &Player) -> impl IntoElement { | ||
| 101 | + let value = picture_scale(player) | ||
| 102 | + .map(|s| format!("{s:.2}")) | ||
| 103 | + .unwrap_or_else(|| "--".to_string()); | ||
| 104 | + let style = type_scale::mono(type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM); | ||
| 105 | + div() | ||
| 106 | + .id("stance-scale-plate") | ||
| 107 | + .flex_none() | ||
| 108 | + .flex() | ||
| 109 | + .items_center() | ||
| 110 | + .gap(px(4.)) | ||
| 111 | + .px(px(6.)) | ||
| 112 | + .py(px(2.)) | ||
| 113 | + .rounded(px(2.)) | ||
| 114 | + .bg(rgb(DARK_CANVAS())) | ||
| 115 | + .font(style.font) | ||
| 116 | + .text_size(style.size) | ||
| 117 | + .child(div().text_color(rgb(INK3())).child("scale")) | ||
| 118 | + .child(div().text_color(rgb(INK1())).child(value)) | ||
| 119 | +} | ||
| 120 | + | ||
| 34 | /// A section head: 9px, uppercase, `ink3` -- DESIGN §3's scale for the label | 121 | /// A section head: 9px, uppercase, `ink3` -- DESIGN §3's scale for the label |
| 35 | /// that names a region before anything else lives in it. | 122 | /// that names a region before anything else lives in it. |
| 36 | fn section_head(label: &str) -> impl IntoElement { | 123 | fn section_head(label: &str) -> impl IntoElement { |
| @@ -220,6 +307,19 @@ fn screen(player: &mut Player, position: f64, window: &mut Window, cx: &mut Cont | |||
| 220 | // §4: room chrome takes 0 radius. | 307 | // §4: room chrome takes 0 radius. |
| 221 | .rounded(px(0.)) | 308 | .rounded(px(0.)) |
| 222 | .bg(rgb(DARK_CANVAS())) | 309 | .bg(rgb(DARK_CANVAS())) |
| 310 | + // FAULT 3: the scale plate's own margin row, above the picture -- | ||
| 311 | + // a flex sibling shrinks the picture's `flex_1` to make room for it | ||
| 312 | + // exactly as `two_up` already does below, so it is never drawn over | ||
| 313 | + // real picture pixels. | ||
| 314 | + .child( | ||
| 315 | + div() | ||
| 316 | + .flex_none() | ||
| 317 | + .flex() | ||
| 318 | + .justify_end() | ||
| 319 | + .px(px(6.)) | ||
| 320 | + .pt(px(4.)) | ||
| 321 | + .child(scale_plate(player)), | ||
| 322 | + ) | ||
| 223 | .child( | 323 | .child( |
| 224 | div() | 324 | div() |
| 225 | .id("stance-picture") | 325 | .id("stance-picture") |
| @@ -227,7 +327,8 @@ fn screen(player: &mut Player, position: f64, window: &mut Window, cx: &mut Cont | |||
| 227 | .min_h(px(0.)) | 327 | .min_h(px(0.)) |
| 228 | .flex() | 328 | .flex() |
| 229 | .relative() | 329 | .relative() |
| 230 | - .child(player.picture_area(position, window, cx)), | 330 | + .child(player.picture_area(position, window, cx)) |
| 331 | + .child(bounds_probe(PICTURE_BOUNDS.with(Rc::clone))), | ||
| 231 | ) | 332 | ) |
| 232 | .children(two_up) | 333 | .children(two_up) |
| 233 | } | 334 | } |
crates/app/src/ui/timeband_stance.rsmodified+125 -19
| @@ -32,17 +32,35 @@ thread_local! { | |||
| 32 | /// so a rebind can never leave the band showing a stroke that no longer | 32 | /// so a rebind can never leave the band showing a stroke that no longer |
| 33 | /// fires it -- the same shape `stance::ghost` draws for the spine, kept local | 33 | /// fires it -- the same shape `stance::ghost` draws for the spine, kept local |
| 34 | /// here so this module owns its own region end to end. | 34 | /// here so this module owns its own region end to end. |
| 35 | -fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { | 35 | +/// |
| 36 | +/// FAULT 2 fix: this used to read [`Keymap::display`], the full-sentence | ||
| 37 | +/// form (`ctrl+left`) meant for the keys overlay's own list -- MOCK-SPEC's | ||
| 38 | +/// band wants the compact badge (`J`, `spc`, `L`) the spine already reads | ||
| 39 | +/// via [`Keymap::chord`] (`stance::ghost`). Switched to `chord` here so every | ||
| 40 | +/// badge in the band matches that same compact grammar. | ||
| 41 | +/// | ||
| 42 | +/// Also FAULT 2: this glyph drew no `on_click` at all -- a badge that names | ||
| 43 | +/// a stroke but does not fire it on a click is the same "glyph, badge and | ||
| 44 | +/// what fires must agree" defect the chord text was, so it now dispatches | ||
| 45 | +/// `action` through [`Player::act`] the same way `stance::ghost` (spine) and | ||
| 46 | +/// `spine_stance`'s own ghost already do, `id` making the three transport | ||
| 47 | +/// ghosts distinct elements gpui can track. | ||
| 48 | +fn ghost(id: &'static str, player: &Player, glyph: &str, action: ActionId, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 36 | let glyph_style = label(type_scale::HERO_TIMECODE_PX, FontWeight::MEDIUM); | 49 | let glyph_style = label(type_scale::HERO_TIMECODE_PX, FontWeight::MEDIUM); |
| 37 | // The chord names a key, so DESIGN §3's mono rule ("if a string is about | 50 | // The chord names a key, so DESIGN §3's mono rule ("if a string is about |
| 38 | // ... a key, it is mono") applies here same as everywhere else in the band. | 51 | // ... a key, it is mono") applies here same as everywhere else in the band. |
| 39 | let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); | 52 | let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); |
| 40 | div() | 53 | div() |
| 54 | + .id(id) | ||
| 41 | .flex_none() | 55 | .flex_none() |
| 42 | .flex() | 56 | .flex() |
| 43 | .flex_col() | 57 | .flex_col() |
| 44 | .items_center() | 58 | .items_center() |
| 45 | .gap(px(1.)) | 59 | .gap(px(1.)) |
| 60 | + .cursor_pointer() | ||
| 61 | + .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { | ||
| 62 | + this.act(action, window, cx); | ||
| 63 | + })) | ||
| 46 | .font(glyph_style.font) | 64 | .font(glyph_style.font) |
| 47 | .text_size(glyph_style.size) | 65 | .text_size(glyph_style.size) |
| 48 | .text_color(rgb(INK2())) | 66 | .text_color(rgb(INK2())) |
| @@ -52,7 +70,7 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { | |||
| 52 | .font(chord_style.font) | 70 | .font(chord_style.font) |
| 53 | .text_size(chord_style.size) | 71 | .text_size(chord_style.size) |
| 54 | .text_color(rgb(INK3())) | 72 | .text_color(rgb(INK3())) |
| 55 | - .child(player.keymap.display(action)), | 73 | + .child(player.keymap.chord(action)), |
| 56 | ) | 74 | ) |
| 57 | } | 75 | } |
| 58 | 76 | ||
| @@ -142,12 +160,13 @@ fn cut_readout(player: &Player) -> impl IntoElement { | |||
| 142 | /// where the bench's own window sits. Click jumps the playhead; drag pans | 160 | /// where the bench's own window sits. Click jumps the playhead; drag pans |
| 143 | /// the bench window. | 161 | /// the bench window. |
| 144 | /// | 162 | /// |
| 145 | -/// hook: the trace itself is splice positions (real clip boundaries, from | 163 | +/// The trace is real audio, not a placeholder: [`Player::waves`] already |
| 146 | -/// [`PlaybackSession::lanes`]/`lane_clips` -- data the app already has), not | 164 | +/// caches each source's peaks for the bench's own waveform clips |
| 147 | -/// a motion or audio trace -- that needs a per-frame decode of the whole | 165 | +/// ([`bench_stance`]'s `clip_box`), so every audio-lane clip draws its own |
| 148 | -/// film this task did not budget for. What would make it real: a cached | 166 | +/// stretch of that same envelope here, positioned by its timeline fraction |
| 149 | -/// low-res luma/RMS pass over each source at import, sampled here instead of | 167 | +/// instead of `bench_stance`'s per-lane pixel scale -- the cheapest honest |
| 150 | -/// clip boundaries. | 168 | +/// whole-film trace this app can draw without a new decode pass. Splice |
| 169 | +/// ticks (video-lane clip boundaries) still mark cut points on top of it. | ||
| 151 | fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | 170 | fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { |
| 152 | let duration = player.drawn_duration(); | 171 | let duration = player.drawn_duration(); |
| 153 | let view = player.view(); | 172 | let view = player.view(); |
| @@ -160,6 +179,7 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 160 | (0., 1.) | 179 | (0., 1.) |
| 161 | }; | 180 | }; |
| 162 | let fps = player.active_fps(); | 181 | let fps = player.active_fps(); |
| 182 | + let frac = |f: u32| ((f64::from(f) / fps) / duration).clamp(0., 1.) as f32; | ||
| 163 | let ticks: Vec<f32> = player | 183 | let ticks: Vec<f32> = player |
| 164 | .session | 184 | .session |
| 165 | .as_ref() | 185 | .as_ref() |
| @@ -173,8 +193,28 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 173 | .unwrap_or_default() | 193 | .unwrap_or_default() |
| 174 | .into_iter() | 194 | .into_iter() |
| 175 | .filter(|_| duration > 0.) | 195 | .filter(|_| duration > 0.) |
| 176 | - .map(|f| ((f64::from(f) / fps) / duration).clamp(0., 1.) as f32) | 196 | + .map(frac) |
| 177 | .collect(); | 197 | .collect(); |
| 198 | + let traces: Vec<(f32, f32, Arc<Vec<(f32, f32)>>, f64, f64, u32)> = player | ||
| 199 | + .session | ||
| 200 | + .as_ref() | ||
| 201 | + .filter(|_| duration > 0.) | ||
| 202 | + .map(|s| { | ||
| 203 | + s.lanes() | ||
| 204 | + .into_iter() | ||
| 205 | + .filter(|l| l.kind == LaneKind::Audio) | ||
| 206 | + .flat_map(|l| s.lane_clips(l).to_vec()) | ||
| 207 | + .filter_map(|clip| { | ||
| 208 | + let source = player.sources().get(clip.source)?; | ||
| 209 | + let Wave::Peaks(peaks) = player.waves.get(&(source.path.clone(), source.audio_stream))?.clone() else { | ||
| 210 | + return None; | ||
| 211 | + }; | ||
| 212 | + let (in_f, out_f) = (f64::from(clip.in_frame) / fps, f64::from(clip.out_frame) / fps); | ||
| 213 | + Some((frac(clip.start), frac(clip.end()), peaks, in_f, out_f, source_tint(clip.source))) | ||
| 214 | + }) | ||
| 215 | + .collect() | ||
| 216 | + }) | ||
| 217 | + .unwrap_or_default(); | ||
| 178 | let strip_bounds = STRIP_BOUNDS.with(Rc::clone); | 218 | let strip_bounds = STRIP_BOUNDS.with(Rc::clone); |
| 179 | div() | 219 | div() |
| 180 | .id("stance-contact-strip") | 220 | .id("stance-contact-strip") |
| @@ -228,7 +268,8 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 228 | cx.listener(|_, _, _, _| PAN_ANCHOR.with(|a| a.set(None))), | 268 | cx.listener(|_, _, _, _| PAN_ANCHOR.with(|a| a.set(None))), |
| 229 | ) | 269 | ) |
| 230 | .child(bounds_probe(strip_bounds)) | 270 | .child(bounds_probe(strip_bounds)) |
| 231 | - // The baseline trace (see the `hook:` above). | 271 | + // Baseline: a quiet hairline under the real traces below it, so an |
| 272 | + // audio-free stretch of film still reads as film rather than gap. | ||
| 232 | .child( | 273 | .child( |
| 233 | div() | 274 | div() |
| 234 | .absolute() | 275 | .absolute() |
| @@ -238,18 +279,34 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 238 | .h(px(2.)) | 279 | .h(px(2.)) |
| 239 | .bg(rgb(DARK_HAIRLINE())), | 280 | .bg(rgb(DARK_HAIRLINE())), |
| 240 | ) | 281 | ) |
| 282 | + // The real trace: each audio-lane clip's own envelope, in the | ||
| 283 | + // source's ink, positioned by timeline fraction (see the fn doc | ||
| 284 | + // above) -- the whole-film minimap MOCK-SPEC asks for, not a | ||
| 285 | + // placeholder line. | ||
| 286 | + .children(traces.into_iter().map(|(from, to, peaks, in_f, out_f, ink)| { | ||
| 287 | + div() | ||
| 288 | + .absolute() | ||
| 289 | + .left(relative(from)) | ||
| 290 | + .top(px(4.)) | ||
| 291 | + .bottom(px(4.)) | ||
| 292 | + .w(relative((to - from).max(0.002))) | ||
| 293 | + .child(waveform_ink(peaks, in_f, out_f, ink)) | ||
| 294 | + })) | ||
| 241 | .children(ticks.into_iter().map(|frac| { | 295 | .children(ticks.into_iter().map(|frac| { |
| 242 | div() | 296 | div() |
| 243 | .absolute() | 297 | .absolute() |
| 244 | .left(relative(frac)) | 298 | .left(relative(frac)) |
| 245 | - .top(px(9.)) | 299 | + .top(px(2.)) |
| 246 | .w(px(1.)) | 300 | .w(px(1.)) |
| 247 | - .h(px(10.)) | 301 | + .h(px(24.)) |
| 248 | .bg(rgb(LAMP_WHITE())) | 302 | .bg(rgb(LAMP_WHITE())) |
| 249 | })) | 303 | })) |
| 250 | - // The viewport bracket: the bench window's own span, with grip | 304 | + // The viewport bracket (MOCK-SPEC: "1px viewport bracket (with grip |
| 251 | - // notches at each edge (MOCK-SPEC: "1px viewport bracket (with grip | 305 | + // notches)"): FAULT 1's box fix -- DESIGN §4 reserves the full |
| 252 | - // notches)"). | 306 | + // bordered rectangle for the room's one commit chip (Export), so this |
| 307 | + // draws only the two edges (left/right verticals + corner notches), | ||
| 308 | + // never a closed box, and stays visually distinct from the trace it | ||
| 309 | + // sits over (ink1 lines/notches vs the trace's film ink fills). | ||
| 253 | .child( | 310 | .child( |
| 254 | div() | 311 | div() |
| 255 | .absolute() | 312 | .absolute() |
| @@ -257,7 +314,8 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 257 | .top_0() | 314 | .top_0() |
| 258 | .h_full() | 315 | .h_full() |
| 259 | .w(relative(width_frac.max(0.01))) | 316 | .w(relative(width_frac.max(0.01))) |
| 260 | - .border_1() | 317 | + .border_l_1() |
| 318 | + .border_r_1() | ||
| 261 | .border_color(rgb(INK1())) | 319 | .border_color(rgb(INK1())) |
| 262 | .child( | 320 | .child( |
| 263 | div() | 321 | div() |
| @@ -268,6 +326,24 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 268 | .h(px(6.)) | 326 | .h(px(6.)) |
| 269 | .bg(rgb(INK1())), | 327 | .bg(rgb(INK1())), |
| 270 | ) | 328 | ) |
| 329 | + .child( | ||
| 330 | + div() | ||
| 331 | + .absolute() | ||
| 332 | + .left_0() | ||
| 333 | + .bottom_0() | ||
| 334 | + .w(px(2.)) | ||
| 335 | + .h(px(6.)) | ||
| 336 | + .bg(rgb(INK1())), | ||
| 337 | + ) | ||
| 338 | + .child( | ||
| 339 | + div() | ||
| 340 | + .absolute() | ||
| 341 | + .right_0() | ||
| 342 | + .top_0() | ||
| 343 | + .w(px(2.)) | ||
| 344 | + .h(px(6.)) | ||
| 345 | + .bg(rgb(INK1())), | ||
| 346 | + ) | ||
| 271 | .child( | 347 | .child( |
| 272 | div() | 348 | div() |
| 273 | .absolute() | 349 | .absolute() |
| @@ -327,7 +403,9 @@ fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 327 | .font(chord_style.font) | 403 | .font(chord_style.font) |
| 328 | .text_size(chord_style.size) | 404 | .text_size(chord_style.size) |
| 329 | .text_color(rgb(INK3())) | 405 | .text_color(rgb(INK3())) |
| 330 | - .child(player.keymap.display(ActionId::Export)), | 406 | + // FAULT 2: compact badge everywhere in the band, same fix as |
| 407 | + // `ghost` above (`Export ^e`, not `Export ctrl+e`). | ||
| 408 | + .child(player.keymap.chord(ActionId::Export)), | ||
| 331 | ) | 409 | ) |
| 332 | } | 410 | } |
| 333 | 411 | ||
| @@ -353,19 +431,47 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player | |||
| 353 | // The most-read element anchors its region (DESIGN §5): the | 431 | // The most-read element anchors its region (DESIGN §5): the |
| 354 | // timecode leads. | 432 | // timecode leads. |
| 355 | .child(hero_timecode(&tc)) | 433 | .child(hero_timecode(&tc)) |
| 434 | + // FAULT 2, the J/K/L question: MOCK-SPEC reads this row's chords as | ||
| 435 | + // `J`/`spc`/`L`, which DESIGN §6 names as the shuttle. No shuttle | ||
| 436 | + // action exists anywhere in this codebase (grepped -- `keymap.rs`, | ||
| 437 | + // `player/actions.rs`, the engine: nothing), and `j`/`k`/`l` are | ||
| 438 | + // already bound to Speed/Color/Lift (`keymap.rs`'s Clip-verb group), | ||
| 439 | + // not to this row -- rebinding them here would silently steal those, | ||
| 440 | + // and `keymap.rs` is not this task's file to make that call in. So | ||
| 441 | + // the glyphs below stay wired to what actually exists and already | ||
| 442 | + // fires correctly (`JumpBack`/`Play`/`JumpForward`, real one-second | ||
| 443 | + // stepping): each badge now reads that action's own compact chord | ||
| 444 | + // (`^←`/`spc`/`^→`) instead of the mismatched mock label, which is | ||
| 445 | + // what keeps glyph, badge and action honestly in agreement per this | ||
| 446 | + // task's own rule -- the mock's `J`/`L` reading stays unimplemented | ||
| 447 | + // and is named here rather than faked. | ||
| 356 | .child( | 448 | .child( |
| 357 | div() | 449 | div() |
| 358 | .flex_none() | 450 | .flex_none() |
| 359 | .flex() | 451 | .flex() |
| 360 | .items_center() | 452 | .items_center() |
| 361 | .gap(px(10.)) | 453 | .gap(px(10.)) |
| 362 | - .child(ghost(player, "◀◀", ActionId::JumpBack)) | ||
| 363 | .child(ghost( | 454 | .child(ghost( |
| 455 | + "stance-tb-jumpback", | ||
| 456 | + player, | ||
| 457 | + "◀◀", | ||
| 458 | + ActionId::JumpBack, | ||
| 459 | + cx, | ||
| 460 | + )) | ||
| 461 | + .child(ghost( | ||
| 462 | + "stance-tb-play", | ||
| 364 | player, | 463 | player, |
| 365 | if player.transport().is_playing() { "❚❚" } else { "▶" }, | 464 | if player.transport().is_playing() { "❚❚" } else { "▶" }, |
| 366 | ActionId::Play, | 465 | ActionId::Play, |
| 466 | + cx, | ||
| 367 | )) | 467 | )) |
| 368 | - .child(ghost(player, "▶▶", ActionId::JumpForward)), | 468 | + .child(ghost( |
| 469 | + "stance-tb-jumpforward", | ||
| 470 | + player, | ||
| 471 | + "▶▶", | ||
| 472 | + ActionId::JumpForward, | ||
| 473 | + cx, | ||
| 474 | + )), | ||
| 369 | ) | 475 | ) |
| 370 | .child(cut_readout(player)) | 476 | .child(cut_readout(player)) |
| 371 | .child(contact_strip(player, cx)) | 477 | .child(contact_strip(player, cx)) |