diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 9af32f8..88d708d 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -2894,3 +2894,83 @@ fn a_dock_ring_never_moves_what_it_rings() { "a dock ring lost its at-rest transparent border" ); } + +/// The spine is 56px and every pair must fit inside it. Measured at +/// 1280x720 the full-size halves did not: hitmap `action.WalkCutPrev10 +/// x=-5 w=31`, `action.AddVideoLane x=-2 w=28` -- the `‹10` glyph was cut +/// at the window's own left edge. Fixed by subtraction (13px + 1px padding +/// for the paired halves, 3px row gap), so this scan is what keeps a new +/// pair from being written at the full row size again. +#[test] +fn every_paired_spine_glyph_is_drawn_at_the_narrow_size() { + let src = src_text("ui/spine_stance.rs"); + // Inside every `pair(...)` call, both halves come from `small`. + let mut rest = src.as_str(); + let mut pairs = 0; + while let Some(at) = rest.find("pair(") { + let after = &rest[at..]; + // The definition and the doc comments are not call sites. + if rest[..at].ends_with("fn ") || rest[..at].ends_with('`') { + rest = &after[5..]; + continue; + } + let mut depth = 0i32; + let mut end = after.len(); + for (i, c) in after.char_indices() { + match c { + '(' => depth += 1, + ')' => { + depth -= 1; + if depth == 0 { + end = i; + break; + } + } + _ => {} + } + } + let body = &after[..end]; + assert!( + !body.contains("glyph("), + "a spine pair draws a full-size glyph, which lays out past the \ + 56px rail: {}", + &body[..body.len().min(120)] + ); + pairs += 1; + rest = &after[end..]; + } + assert!(pairs >= 8, "the spine's pairs went missing ({pairs} found)"); + // And `small` is the narrow one: one step down the §3 scale, 1px sides. + assert!( + src.contains("type_scale::CHORD_METADATA_MIN_PX") + && src.contains("let pad = if paired { 1. } else { 3. };"), + "the paired size/padding subtraction is gone from spine_stance" + ); + assert!( + src.contains(".gap(px(3.))\n .child(left)"), + "the pair row's own gap grew again" + ); +} + +/// DESIGN §8 (no instructional copy) and §9: the keys plate's heading is one +/// noun, its way out is a chord like every other row, and its bottom edge is +/// inside the window -- the shipped plate said `ALL COMMANDS · HOLD ? · +/// RELEASE TO CLOSE` while sitting there latched after a click, with its last +/// rows cut off below y=720. +#[test] +fn the_keys_plate_says_one_noun_and_ends_inside_the_window() { + let src = src_text("ui/stance.rs"); + let lower = src.to_lowercase(); + assert!( + !lower.contains("hold ? · release to close") && !lower.contains("all commands"), + "the keys plate still tells the hand what to do" + ); + assert!( + src.contains("section_head(\"keys\")") && src.contains(".child(\"esc\")"), + "the keys plate lost its noun or its escape chord" + ); + assert!( + src.contains(".h(px((bench_h + LEDGER_H - 16.).max(0.)))"), + "the keys plate is no longer capped inside the bench+ledger footprint" + ); +} diff --git a/crates/app/src/ui/spine_stance.rs b/crates/app/src/ui/spine_stance.rs index 2727154..3481281 100644 --- a/crates/app/src/ui/spine_stance.rs +++ b/crates/app/src/ui/spine_stance.rs @@ -47,6 +47,44 @@ fn glyph( player: &Player, cx: &mut Context, ) -> impl IntoElement + use<> { + glyph_sized(false, id, glyph, action, active, quiet, player, cx) +} + +/// The paired half of [`glyph`]: same control, one step down the §3 scale +/// (13px, the chord size) and 1px of side padding instead of 3. Two +/// full-size halves plus their padding measured 66px against a 56px rail +/// and laid out at negative x -- `‹10` was cut at the window's own left +/// edge (hitmap `action.WalkCutPrev10 x=-5 w=31`). Subtraction, not a wider +/// spine: the pair now fits inside the column with room on both sides. +fn small( + id: &'static str, + glyph: &'static str, + action: ActionId, + active: bool, + quiet: bool, + player: &Player, + cx: &mut Context, +) -> impl IntoElement + use<> { + glyph_sized(true, id, glyph, action, active, quiet, player, cx) +} + +#[allow(clippy::too_many_arguments)] +fn glyph_sized( + paired: bool, + id: &'static str, + glyph: &'static str, + action: ActionId, + active: bool, + quiet: bool, + player: &Player, + cx: &mut Context, +) -> impl IntoElement + use<> { + let size = if paired { + type_scale::CHORD_METADATA_MIN_PX + } else { + type_scale::LABEL_ROW_PX + }; + let pad = if paired { 1. } else { 3. }; let enabled = player.enable(action, None); // The badge shows the primary chord only (FAULT 1: a chord badge is a // compact token, not a sentence); the tooltip keeps every stroke an @@ -67,7 +105,7 @@ fn glyph( .flex_col() .items_center() .gap(px(1.)) - .px(px(3.)) + .px(px(pad)) .py(px(1.)) .rounded(px(3.)) .when(active, |d| d.bg(rgb(DARK_RAISED()))) @@ -88,10 +126,7 @@ fn glyph( .line_height(relative(1.05)) // FAULT 1: the glyph is the loudest thing in its row -- BOLD, // not the MEDIUM weight the chord beneath it also wears. - .type_style(type_scale::label( - type_scale::LABEL_ROW_PX, - gpui::FontWeight::BOLD, - )) + .type_style(type_scale::label(size, gpui::FontWeight::BOLD)) .text_color(rgb(if active { INK1() } else if quiet { @@ -132,7 +167,7 @@ fn trim_control(active: bool, player: &Player, cx: &mut Context) -> impl div() .id(id) .flex_none() - .px(px(2.)) + .px(px(1.)) .rounded(px(3.)) .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) @@ -147,8 +182,9 @@ fn trim_control(active: bool, player: &Player, cx: &mut Context) -> impl .child( div() .line_height(relative(1.05)) + // Paired, so the same step down the scale `small` takes. .type_style(type_scale::label( - type_scale::LABEL_ROW_PX, + type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::BOLD, )) .text_color(rgb(if active { INK1() } else { INK2() })) @@ -213,11 +249,10 @@ fn pair(left: impl IntoElement, right: impl IntoElement) -> impl IntoElement { .w_full() .items_center() .justify_center() - // 4px, not 6: two two-glyph halves plus their own padding used to - // measure wider than the 56px rail and bled past its left edge - // (measured at 1280x720: the `AP`/`FS` row started at x=0, outside - // the spine's own surface). - .gap(px(4.)) + // 3px, and both halves come from `small` (13px, 1px padding): two + // full-size halves plus 4px measured 66px against the 56px rail and + // laid out at negative x (hitmap `action.AddVideoLane x=-2 w=28`). + .gap(px(3.)) .child(left) .child(right) } @@ -271,16 +306,16 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem cx, )) .child(pair( - glyph("spine-undo", "↺", ActionId::Undo, false, false, player, cx), + small("spine-undo", "↺", ActionId::Undo, false, false, player, cx), // Redo had a legacy toolbar button (`toolbar.rs:347`) but no // darkroom home -- Undo got a glyph here and Redo did not. // Same row, same door (`this.act`), the pair anatomy the // cut-prev/cut-next row below already uses. - glyph("spine-redo", "⟳", ActionId::Redo, false, false, player, cx), + small("spine-redo", "⟳", ActionId::Redo, false, false, player, cx), )) .child(group_head("cut")) .child(pair( - glyph( + small( "spine-cut-prev", "‹", ActionId::WalkCutPrev, @@ -289,7 +324,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem player, cx, ), - glyph( + small( "spine-cut-next", "›", ActionId::WalkCutNext, @@ -312,7 +347,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem .items_center() .gap(px(1.)) .child(pair( - glyph( + small( "spine-cut-prev-ten", "‹10", ActionId::WalkCutPrev10, @@ -321,7 +356,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem player, cx, ), - glyph( + small( "spine-cut-next-ten", "10›", ActionId::WalkCutNext10, @@ -336,7 +371,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem // Trim-to-playhead (debt #42): the keyboard's own version // of the pointer's drag-to-a-spot trim, beside the nudge // pair it shares its primitive with. - glyph( + small( "spine-trim-in-playhead", "[▮", ActionId::TrimInToPlayhead, @@ -345,7 +380,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem player, cx, ), - glyph( + small( "spine-trim-out-playhead", "▮]", ActionId::TrimOutToPlayhead, @@ -379,7 +414,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem .items_center() .gap(px(1.)) .child(pair( - glyph( + small( "spine-zoom-out", "−", ActionId::ZoomOut, @@ -388,7 +423,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem player, cx, ), - glyph( + small( "spine-zoom-in", "+", ActionId::ZoomIn, @@ -431,7 +466,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem .items_center() .gap(px(1.)) .child(pair( - glyph( + small( "spine-add-video", "+V", ActionId::AddVideoLane, @@ -440,7 +475,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem player, cx, ), - glyph( + small( "spine-add-audio", "+A", ActionId::AddAudioLane, @@ -457,7 +492,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem // beside "Add files" (`dock_stance`), where an editor // already goes to bring a file into the room. .child(pair( - glyph( + small( "spine-add-subtitle", "+S", ActionId::AddSubtitleLane, @@ -466,7 +501,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem player, cx, ), - glyph( + small( "spine-remove-subtitle", "−S", ActionId::RemoveSubtitleLane, @@ -500,7 +535,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem .items_center() .gap(px(1.)) .child(pair( - glyph( + small( "spine-settings", "St", ActionId::Settings, @@ -509,7 +544,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem player, cx, ), - glyph( + small( "spine-screenshot", "Sh", ActionId::Screenshot, diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index c47a5af..7104d02 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -407,11 +407,11 @@ fn ghost( )) .text_color(rgb(INK2())) .child(glyph.to_string()) - // The badge is skipped when the stroke IS the glyph: `?` over `?` - // drew as two identical rows stacked at the foot of the rail and read - // as a duplicated control rather than as one command wearing its own - // chord. - .children((player.keymap.chord(action) != glyph).then(|| { + // Every command wears its chord (DESIGN §4) -- including the one + // whose glyph IS its stroke: `?` reads as `?` over a dimmer `?`, + // the same glyph-over-chord anatomy every other spine ghost draws, + // rather than as the one control on the rail with nothing under it. + .child( div() .type_style(type_scale::mono( type_scale::CHORD_METADATA_MIN_PX, @@ -420,8 +420,8 @@ fn ghost( .text_color(rgb(INK3())) // FAULT 1: the badge shows the primary chord, compact -- // same rule as every glyph in `spine_stance`. - .child(player.keymap.chord(action)) - })) + .child(player.keymap.chord(action)), + ) } /// The keys overlay (DESIGN §9, §12 step 7): every bound command, sectioned @@ -460,6 +460,13 @@ fn keys_overlay(player: &Player, bench_h: f32, cx: &mut Context) -> impl .h(px(bench_h + LEDGER_H)) .bg(rgba(SCRIM())) .flex() + // The plate's inset lives on the scrim, not on the plate's own + // margins: a margin under a fixed `h()` left the list flush with the + // window's bottom edge and its last rows cut over the ledger. Padding + // here takes the room off the footprint before the plate is measured. + .pl(px(12.)) + .pt(px(8.)) + .pb(px(8.)) // Bottom-left, not centred: the `?` control that opens this lives at // the foot of the spine ([`spine`]'s last child), and this overlay // mounts inside the *centre* column next to it -- anchoring the list @@ -482,9 +489,10 @@ fn keys_overlay(player: &Player, bench_h: f32, cx: &mut Context) -> impl .child( div() .id("stance-keys-list") - .ml(px(12.)) - .mb(px(12.)) - .h(px((bench_h + LEDGER_H - 24.).max(0.))) + // Capped to the bench+ledger footprint less the scrim's own + // inset, so the bottom border is on screen and the rows + // scroll inside it (DESIGN §9). + .h(px((bench_h + LEDGER_H - 16.).max(0.))) .w(px(460.)) .overflow_y_scroll() .p(px(10.)) @@ -496,7 +504,27 @@ fn keys_overlay(player: &Player, bench_h: f32, cx: &mut Context) -> impl .flex() .flex_col() .gap(px(3.)) - .child(section_head("all commands · hold ? · release to close")) + // DESIGN §8, no instructional copy: the heading is the + // single noun, and the way out is a chord on the right like + // every other row here -- not a sentence that lied anyway + // (a click-opened plate does not close on a release). + .child( + div() + .flex_none() + .flex() + .justify_between() + .gap(px(12.)) + .child(section_head("keys")) + .child( + div() + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK3())) + .child("esc"), + ), + ) .children(keys_rows().into_iter().map(|row| { match row { KeyRow::Head(category) => div()