forge
Explore
Log in

Don't you dare go Hollow

The spine's pairs fit its rail, the keys plate says one noun

Browse files at this commit

60a04f2a3864610ae5dbf0682a1968ca17518e56Ahmet Kaan GümüşParent: 2bf7f4a
  • style
    • the spine's pairs fit its rail, the keys plate says one noun
Show full message
🎨 style(app): the spine's pairs fit its rail, the keys plate says one noun

The paired glyphs (`‹10 10›`, `+V +A`, `+S −S`, ±1 trim) laid out at
negative x against the 56px rail -- `‹10` was cut at the window's own
left edge (hitmap x=-5 w=31). Subtraction, not a wider spine: a paired
half draws one step down the §3 scale (13px) with 1px sides, the row gap
is 3px, and the narrowest rect now starts at x=3.

The keys plate said `ALL COMMANDS · HOLD ? · RELEASE TO CLOSE` while
sitting latched open after a click on the spine `?` -- instructional
copy (§8) that was also a lie. Heading is the noun `KEYS`, the way out
is an `esc` chord on its right, and the plate's inset moved onto the
scrim so its bottom border ends inside the window. The spine `?` wears
its own chord like every other ghost (§4).
crates/app/src/tests/layout.rsmodified+80 -0
@@ -2814,3 +2814,83 @@ fn the_lane_bed_clips_its_clips_at_the_pinned_heads() {
2814 pinned lane heads: {bed}"2814 pinned lane heads: {bed}"
2815 );2815 );
2816 }2816 }
2817+
2818+/// The spine is 56px and every pair must fit inside it. Measured at
2819+/// 1280x720 the full-size halves did not: hitmap `action.WalkCutPrev10
2820+/// x=-5 w=31`, `action.AddVideoLane x=-2 w=28` -- the `‹10` glyph was cut
2821+/// at the window's own left edge. Fixed by subtraction (13px + 1px padding
2822+/// for the paired halves, 3px row gap), so this scan is what keeps a new
2823+/// pair from being written at the full row size again.
2824+#[test]
2825+fn every_paired_spine_glyph_is_drawn_at_the_narrow_size() {
2826+ let src = src_text("ui/spine_stance.rs");
2827+ // Inside every `pair(...)` call, both halves come from `small`.
2828+ let mut rest = src.as_str();
2829+ let mut pairs = 0;
2830+ while let Some(at) = rest.find("pair(") {
2831+ let after = &rest[at..];
2832+ // The definition and the doc comments are not call sites.
2833+ if rest[..at].ends_with("fn ") || rest[..at].ends_with('`') {
2834+ rest = &after[5..];
2835+ continue;
2836+ }
2837+ let mut depth = 0i32;
2838+ let mut end = after.len();
2839+ for (i, c) in after.char_indices() {
2840+ match c {
2841+ '(' => depth += 1,
2842+ ')' => {
2843+ depth -= 1;
2844+ if depth == 0 {
2845+ end = i;
2846+ break;
2847+ }
2848+ }
2849+ _ => {}
2850+ }
2851+ }
2852+ let body = &after[..end];
2853+ assert!(
2854+ !body.contains("glyph("),
2855+ "a spine pair draws a full-size glyph, which lays out past the \
2856+ 56px rail: {}",
2857+ &body[..body.len().min(120)]
2858+ );
2859+ pairs += 1;
2860+ rest = &after[end..];
2861+ }
2862+ assert!(pairs >= 8, "the spine's pairs went missing ({pairs} found)");
2863+ // And `small` is the narrow one: one step down the §3 scale, 1px sides.
2864+ assert!(
2865+ src.contains("type_scale::CHORD_METADATA_MIN_PX")
2866+ && src.contains("let pad = if paired { 1. } else { 3. };"),
2867+ "the paired size/padding subtraction is gone from spine_stance"
2868+ );
2869+ assert!(
2870+ src.contains(".gap(px(3.))\n .child(left)"),
2871+ "the pair row's own gap grew again"
2872+ );
2873+}
2874+
2875+/// DESIGN §8 (no instructional copy) and §9: the keys plate's heading is one
2876+/// noun, its way out is a chord like every other row, and its bottom edge is
2877+/// inside the window -- the shipped plate said `ALL COMMANDS · HOLD ? ·
2878+/// RELEASE TO CLOSE` while sitting there latched after a click, with its last
2879+/// rows cut off below y=720.
2880+#[test]
2881+fn the_keys_plate_says_one_noun_and_ends_inside_the_window() {
2882+ let src = src_text("ui/stance.rs");
2883+ let lower = src.to_lowercase();
2884+ assert!(
2885+ !lower.contains("hold ? · release to close") && !lower.contains("all commands"),
2886+ "the keys plate still tells the hand what to do"
2887+ );
2888+ assert!(
2889+ src.contains("section_head(\"keys\")") && src.contains(".child(\"esc\")"),
2890+ "the keys plate lost its noun or its escape chord"
2891+ );
2892+ assert!(
2893+ src.contains(".h(px((bench_h + LEDGER_H - 16.).max(0.)))"),
2894+ "the keys plate is no longer capped inside the bench+ledger footprint"
2895+ );
2896+}
crates/app/src/ui/spine_stance.rsmodified+63 -28
@@ -47,6 +47,44 @@ fn glyph(
47 player: &Player,47 player: &Player,
48 cx: &mut Context<Player>,48 cx: &mut Context<Player>,
49 ) -> impl IntoElement + use<> {49 ) -> impl IntoElement + use<> {
50+ glyph_sized(false, id, glyph, action, active, quiet, player, cx)
51+}
52+
53+/// The paired half of [`glyph`]: same control, one step down the §3 scale
54+/// (13px, the chord size) and 1px of side padding instead of 3. Two
55+/// full-size halves plus their padding measured 66px against a 56px rail
56+/// and laid out at negative x -- `‹10` was cut at the window's own left
57+/// edge (hitmap `action.WalkCutPrev10 x=-5 w=31`). Subtraction, not a wider
58+/// spine: the pair now fits inside the column with room on both sides.
59+fn small(
60+ id: &'static str,
61+ glyph: &'static str,
62+ action: ActionId,
63+ active: bool,
64+ quiet: bool,
65+ player: &Player,
66+ cx: &mut Context<Player>,
67+) -> impl IntoElement + use<> {
68+ glyph_sized(true, id, glyph, action, active, quiet, player, cx)
69+}
70+
71+#[allow(clippy::too_many_arguments)]
72+fn glyph_sized(
73+ paired: bool,
74+ id: &'static str,
75+ glyph: &'static str,
76+ action: ActionId,
77+ active: bool,
78+ quiet: bool,
79+ player: &Player,
80+ cx: &mut Context<Player>,
81+) -> impl IntoElement + use<> {
82+ let size = if paired {
83+ type_scale::CHORD_METADATA_MIN_PX
84+ } else {
85+ type_scale::LABEL_ROW_PX
86+ };
87+ let pad = if paired { 1. } else { 3. };
50 let enabled = player.enable(action, None);88 let enabled = player.enable(action, None);
51 // The badge shows the primary chord only (FAULT 1: a chord badge is a89 // The badge shows the primary chord only (FAULT 1: a chord badge is a
52 // compact token, not a sentence); the tooltip keeps every stroke an90 // compact token, not a sentence); the tooltip keeps every stroke an
@@ -67,7 +105,7 @@ fn glyph(
67 .flex_col()105 .flex_col()
68 .items_center()106 .items_center()
69 .gap(px(1.))107 .gap(px(1.))
70- .px(px(3.))108+ .px(px(pad))
71 .py(px(1.))109 .py(px(1.))
72 .rounded(px(3.))110 .rounded(px(3.))
73 .when(active, |d| d.bg(rgb(DARK_RAISED())))111 .when(active, |d| d.bg(rgb(DARK_RAISED())))
@@ -88,10 +126,7 @@ fn glyph(
88 .line_height(relative(1.05))126 .line_height(relative(1.05))
89 // FAULT 1: the glyph is the loudest thing in its row -- BOLD,127 // FAULT 1: the glyph is the loudest thing in its row -- BOLD,
90 // not the MEDIUM weight the chord beneath it also wears.128 // not the MEDIUM weight the chord beneath it also wears.
91- .type_style(type_scale::label(129+ .type_style(type_scale::label(size, gpui::FontWeight::BOLD))
92- type_scale::LABEL_ROW_PX,
93- gpui::FontWeight::BOLD,
94- ))
95 .text_color(rgb(if active {130 .text_color(rgb(if active {
96 INK1()131 INK1()
97 } else if quiet {132 } else if quiet {
@@ -132,7 +167,7 @@ fn trim_control(active: bool, player: &Player, cx: &mut Context<Player>) -> impl
132 div()167 div()
133 .id(id)168 .id(id)
134 .flex_none()169 .flex_none()
135- .px(px(2.))170+ .px(px(1.))
136 .rounded(px(3.))171 .rounded(px(3.))
137 .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into())172 .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into())
138 .when(!on, |d| d.opacity(0.4).cursor_not_allowed())173 .when(!on, |d| d.opacity(0.4).cursor_not_allowed())
@@ -147,8 +182,9 @@ fn trim_control(active: bool, player: &Player, cx: &mut Context<Player>) -> impl
147 .child(182 .child(
148 div()183 div()
149 .line_height(relative(1.05))184 .line_height(relative(1.05))
185+ // Paired, so the same step down the scale `small` takes.
150 .type_style(type_scale::label(186 .type_style(type_scale::label(
151- type_scale::LABEL_ROW_PX,187+ type_scale::CHORD_METADATA_MIN_PX,
152 gpui::FontWeight::BOLD,188 gpui::FontWeight::BOLD,
153 ))189 ))
154 .text_color(rgb(if active { INK1() } else { INK2() }))190 .text_color(rgb(if active { INK1() } else { INK2() }))
@@ -213,11 +249,10 @@ fn pair(left: impl IntoElement, right: impl IntoElement) -> impl IntoElement {
213 .w_full()249 .w_full()
214 .items_center()250 .items_center()
215 .justify_center()251 .justify_center()
216- // 4px, not 6: two two-glyph halves plus their own padding used to252+ // 3px, and both halves come from `small` (13px, 1px padding): two
217- // measure wider than the 56px rail and bled past its left edge253+ // full-size halves plus 4px measured 66px against the 56px rail and
218- // (measured at 1280x720: the `AP`/`FS` row started at x=0, outside254+ // laid out at negative x (hitmap `action.AddVideoLane x=-2 w=28`).
219- // the spine's own surface).255+ .gap(px(3.))
220- .gap(px(4.))
221 .child(left)256 .child(left)
222 .child(right)257 .child(right)
223 }258 }
@@ -271,16 +306,16 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
271 cx,306 cx,
272 ))307 ))
273 .child(pair(308 .child(pair(
274- glyph("spine-undo", "↺", ActionId::Undo, false, false, player, cx),309+ small("spine-undo", "↺", ActionId::Undo, false, false, player, cx),
275 // Redo had a legacy toolbar button (`toolbar.rs:347`) but no310 // Redo had a legacy toolbar button (`toolbar.rs:347`) but no
276 // darkroom home -- Undo got a glyph here and Redo did not.311 // darkroom home -- Undo got a glyph here and Redo did not.
277 // Same row, same door (`this.act`), the pair anatomy the312 // Same row, same door (`this.act`), the pair anatomy the
278 // cut-prev/cut-next row below already uses.313 // cut-prev/cut-next row below already uses.
279- glyph("spine-redo", "⟳", ActionId::Redo, false, false, player, cx),314+ small("spine-redo", "⟳", ActionId::Redo, false, false, player, cx),
280 ))315 ))
281 .child(group_head("cut"))316 .child(group_head("cut"))
282 .child(pair(317 .child(pair(
283- glyph(318+ small(
284 "spine-cut-prev",319 "spine-cut-prev",
285 "‹",320 "‹",
286 ActionId::WalkCutPrev,321 ActionId::WalkCutPrev,
@@ -289,7 +324,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
289 player,324 player,
290 cx,325 cx,
291 ),326 ),
292- glyph(327+ small(
293 "spine-cut-next",328 "spine-cut-next",
294 "›",329 "›",
295 ActionId::WalkCutNext,330 ActionId::WalkCutNext,
@@ -312,7 +347,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
312 .items_center()347 .items_center()
313 .gap(px(1.))348 .gap(px(1.))
314 .child(pair(349 .child(pair(
315- glyph(350+ small(
316 "spine-cut-prev-ten",351 "spine-cut-prev-ten",
317 "‹10",352 "‹10",
318 ActionId::WalkCutPrev10,353 ActionId::WalkCutPrev10,
@@ -321,7 +356,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
321 player,356 player,
322 cx,357 cx,
323 ),358 ),
324- glyph(359+ small(
325 "spine-cut-next-ten",360 "spine-cut-next-ten",
326 "10›",361 "10›",
327 ActionId::WalkCutNext10,362 ActionId::WalkCutNext10,
@@ -336,7 +371,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
336 // Trim-to-playhead (debt #42): the keyboard's own version371 // Trim-to-playhead (debt #42): the keyboard's own version
337 // of the pointer's drag-to-a-spot trim, beside the nudge372 // of the pointer's drag-to-a-spot trim, beside the nudge
338 // pair it shares its primitive with.373 // pair it shares its primitive with.
339- glyph(374+ small(
340 "spine-trim-in-playhead",375 "spine-trim-in-playhead",
341 "[▮",376 "[▮",
342 ActionId::TrimInToPlayhead,377 ActionId::TrimInToPlayhead,
@@ -345,7 +380,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
345 player,380 player,
346 cx,381 cx,
347 ),382 ),
348- glyph(383+ small(
349 "spine-trim-out-playhead",384 "spine-trim-out-playhead",
350 "▮]",385 "▮]",
351 ActionId::TrimOutToPlayhead,386 ActionId::TrimOutToPlayhead,
@@ -379,7 +414,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
379 .items_center()414 .items_center()
380 .gap(px(1.))415 .gap(px(1.))
381 .child(pair(416 .child(pair(
382- glyph(417+ small(
383 "spine-zoom-out",418 "spine-zoom-out",
384 "−",419 "−",
385 ActionId::ZoomOut,420 ActionId::ZoomOut,
@@ -388,7 +423,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
388 player,423 player,
389 cx,424 cx,
390 ),425 ),
391- glyph(426+ small(
392 "spine-zoom-in",427 "spine-zoom-in",
393 "+",428 "+",
394 ActionId::ZoomIn,429 ActionId::ZoomIn,
@@ -431,7 +466,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
431 .items_center()466 .items_center()
432 .gap(px(1.))467 .gap(px(1.))
433 .child(pair(468 .child(pair(
434- glyph(469+ small(
435 "spine-add-video",470 "spine-add-video",
436 "+V",471 "+V",
437 ActionId::AddVideoLane,472 ActionId::AddVideoLane,
@@ -440,7 +475,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
440 player,475 player,
441 cx,476 cx,
442 ),477 ),
443- glyph(478+ small(
444 "spine-add-audio",479 "spine-add-audio",
445 "+A",480 "+A",
446 ActionId::AddAudioLane,481 ActionId::AddAudioLane,
@@ -457,7 +492,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
457 // beside "Add files" (`dock_stance`), where an editor492 // beside "Add files" (`dock_stance`), where an editor
458 // already goes to bring a file into the room.493 // already goes to bring a file into the room.
459 .child(pair(494 .child(pair(
460- glyph(495+ small(
461 "spine-add-subtitle",496 "spine-add-subtitle",
462 "+S",497 "+S",
463 ActionId::AddSubtitleLane,498 ActionId::AddSubtitleLane,
@@ -466,7 +501,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
466 player,501 player,
467 cx,502 cx,
468 ),503 ),
469- glyph(504+ small(
470 "spine-remove-subtitle",505 "spine-remove-subtitle",
471 "−S",506 "−S",
472 ActionId::RemoveSubtitleLane,507 ActionId::RemoveSubtitleLane,
@@ -500,7 +535,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
500 .items_center()535 .items_center()
501 .gap(px(1.))536 .gap(px(1.))
502 .child(pair(537 .child(pair(
503- glyph(538+ small(
504 "spine-settings",539 "spine-settings",
505 "St",540 "St",
506 ActionId::Settings,541 ActionId::Settings,
@@ -509,7 +544,7 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
509 player,544 player,
510 cx,545 cx,
511 ),546 ),
512- glyph(547+ small(
513 "spine-screenshot",548 "spine-screenshot",
514 "Sh",549 "Sh",
515 ActionId::Screenshot,550 ActionId::Screenshot,
crates/app/src/ui/stance.rsmodified+39 -11
@@ -407,11 +407,11 @@ fn ghost(
407 ))407 ))
408 .text_color(rgb(INK2()))408 .text_color(rgb(INK2()))
409 .child(glyph.to_string())409 .child(glyph.to_string())
410- // The badge is skipped when the stroke IS the glyph: `?` over `?`410+ // Every command wears its chord (DESIGN §4) -- including the one
411- // drew as two identical rows stacked at the foot of the rail and read411+ // whose glyph IS its stroke: `?` reads as `?` over a dimmer `?`,
412- // as a duplicated control rather than as one command wearing its own412+ // the same glyph-over-chord anatomy every other spine ghost draws,
413- // chord.413+ // rather than as the one control on the rail with nothing under it.
414- .children((player.keymap.chord(action) != glyph).then(|| {414+ .child(
415 div()415 div()
416 .type_style(type_scale::mono(416 .type_style(type_scale::mono(
417 type_scale::CHORD_METADATA_MIN_PX,417 type_scale::CHORD_METADATA_MIN_PX,
@@ -420,8 +420,8 @@ fn ghost(
420 .text_color(rgb(INK3()))420 .text_color(rgb(INK3()))
421 // FAULT 1: the badge shows the primary chord, compact --421 // FAULT 1: the badge shows the primary chord, compact --
422 // same rule as every glyph in `spine_stance`.422 // same rule as every glyph in `spine_stance`.
423- .child(player.keymap.chord(action))423+ .child(player.keymap.chord(action)),
424- }))424+ )
425 }425 }
426 426
427 /// The keys overlay (DESIGN §9, §12 step 7): every bound command, sectioned427 /// 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<Player>) -> impl
460 .h(px(bench_h + LEDGER_H))460 .h(px(bench_h + LEDGER_H))
461 .bg(rgba(SCRIM()))461 .bg(rgba(SCRIM()))
462 .flex()462 .flex()
463+ // The plate's inset lives on the scrim, not on the plate's own
464+ // margins: a margin under a fixed `h()` left the list flush with the
465+ // window's bottom edge and its last rows cut over the ledger. Padding
466+ // here takes the room off the footprint before the plate is measured.
467+ .pl(px(12.))
468+ .pt(px(8.))
469+ .pb(px(8.))
463 // Bottom-left, not centred: the `?` control that opens this lives at470 // Bottom-left, not centred: the `?` control that opens this lives at
464 // the foot of the spine ([`spine`]'s last child), and this overlay471 // the foot of the spine ([`spine`]'s last child), and this overlay
465 // mounts inside the *centre* column next to it -- anchoring the list472 // 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<Player>) -> impl
482 .child(489 .child(
483 div()490 div()
484 .id("stance-keys-list")491 .id("stance-keys-list")
485- .ml(px(12.))492+ // Capped to the bench+ledger footprint less the scrim's own
486- .mb(px(12.))493+ // inset, so the bottom border is on screen and the rows
487- .h(px((bench_h + LEDGER_H - 24.).max(0.)))494+ // scroll inside it (DESIGN §9).
495+ .h(px((bench_h + LEDGER_H - 16.).max(0.)))
488 .w(px(460.))496 .w(px(460.))
489 .overflow_y_scroll()497 .overflow_y_scroll()
490 .p(px(10.))498 .p(px(10.))
@@ -496,7 +504,27 @@ fn keys_overlay(player: &Player, bench_h: f32, cx: &mut Context<Player>) -> impl
496 .flex()504 .flex()
497 .flex_col()505 .flex_col()
498 .gap(px(3.))506 .gap(px(3.))
499- .child(section_head("all commands · hold ? · release to close"))507+ // DESIGN §8, no instructional copy: the heading is the
508+ // single noun, and the way out is a chord on the right like
509+ // every other row here -- not a sentence that lied anyway
510+ // (a click-opened plate does not close on a release).
511+ .child(
512+ div()
513+ .flex_none()
514+ .flex()
515+ .justify_between()
516+ .gap(px(12.))
517+ .child(section_head("keys"))
518+ .child(
519+ div()
520+ .type_style(type_scale::mono(
521+ type_scale::CHORD_METADATA_MIN_PX,
522+ gpui::FontWeight::MEDIUM,
523+ ))
524+ .text_color(rgb(INK3()))
525+ .child("esc"),
526+ ),
527+ )
500 .children(keys_rows().into_iter().map(|row| {528 .children(keys_rows().into_iter().map(|row| {
501 match row {529 match row {
502 KeyRow::Head(category) => div()530 KeyRow::Head(category) => div()