forge
Explore
Log in

Don't you dare go Hollow

The room speaks in its own type and its badges get terse

Browse files at this commit

d5dd5fc620e93082b78dc4abb467abec59db1b1aAhmet Kaan GümüşParent: 25a08e3
  • style
    • the room speaks in its own type and its badges get terse
Show full message
💄 style(ui): the room speaks in its own type and its badges get terse

Every chord badge read like a sentence — "x or delete", "z or ctrl+z" —
stacked under a glyph the width of two characters, so the spine had to
stretch down the whole window to fit. A badge shows the primary stroke,
compact: x, z, del, ^o. The overlay still tells the whole truth, which is
where alternatives belong. With the badges short the groups close up to the
rhythm the mock draws.

The type the last commit bundled was never actually asked for: most text
carried no family or size at all, so the room rendered in whatever the
toolkit defaults to, which is why the import verbs came out twice their
size. Every string in the stance now asks the type scale for its role —
Archivo for what the room says, mono for what the film says.

The contact strip could not span the band because the band's own row
refused to claim the width, so the strip's flex had nothing to grow into.
It fills the space between the readout and the chip now.
crates/app/src/keymap.rsmodified+48 -0
@@ -877,6 +877,26 @@ impl Chord {
877 }877 }
878 }878 }
879 879
880+ /// The spelling a badge with room for one token reads (MOCK-SPEC.md
881+ /// "Spine": `del`, `z`, not `x or delete`, `ctrl+z`): `^` in place of
882+ /// `ctrl+`, and the handful of key names whose everyday short form isn't
883+ /// gpui's own (`delete` -> `del`, `escape` -> `esc`, `space` -> `spc`).
884+ /// [`Chord::pretty`] stays the keys overlay's own spelling -- this is for
885+ /// a glyph badge, not the full truth.
886+ pub fn compact(&self) -> String {
887+ let key = match self.key.as_str() {
888+ "escape" => "esc",
889+ "delete" => "del",
890+ "space" => "spc",
891+ other => other,
892+ };
893+ if self.ctrl {
894+ format!("^{key}")
895+ } else {
896+ key.to_string()
897+ }
898+ }
899+
880 /// Whether the file can carry this stroke and read it back as itself. gpui900 /// Whether the file can carry this stroke and read it back as itself. gpui
881 /// reports strokes this format cannot spell -- shift+= arrives as the key901 /// reports strokes this format cannot spell -- shift+= arrives as the key
882 /// `"+"`, which is the chord grammar's own separator -- and binding one902 /// `"+"`, which is the chord grammar's own separator -- and binding one
@@ -1215,6 +1235,20 @@ impl Keymap {
1215 }1235 }
1216 }1236 }
1217 1237
1238+ /// The primary chord for `action`, compact ([`Chord::compact`]) -- a
1239+ /// badge that has room for one token, not [`Keymap::display`]'s sentence.
1240+ /// The first bound stroke wins (`defaults`' own insertion order, and
1241+ /// `rebind_action`'s "makes `chord` the whole of what reaches `action`"
1242+ /// leaves at most one anyway); an action with no stroke reads `--`
1243+ /// rather than the unbound sentence, since a badge is not a warning.
1244+ pub fn chord(&self, action: ActionId) -> String {
1245+ self.bindings
1246+ .iter()
1247+ .find(|b| b.action == action)
1248+ .map(|b| b.chord.compact())
1249+ .unwrap_or_else(|| "--".to_string())
1250+ }
1251+
1218 /// Every binding, in display order.1252 /// Every binding, in display order.
1219 pub fn entries(&self) -> &[Binding] {1253 pub fn entries(&self) -> &[Binding] {
1220 &self.bindings1254 &self.bindings
@@ -1742,6 +1776,20 @@ mod tests {
1742 assert_eq!(k.display(ActionId::ZoomIn), "ctrl+=");1776 assert_eq!(k.display(ActionId::ZoomIn), "ctrl+=");
1743 }1777 }
1744 1778
1779+ /// [`Keymap::chord`] is the badge's one token, not [`Keymap::display`]'s
1780+ /// sentence: the primary (first-bound) stroke only, `^` for ctrl, and the
1781+ /// short names a glyph badge actually has room for.
1782+ #[test]
1783+ fn chord_is_the_primary_stroke_compact() {
1784+ let k = Keymap::defaults();
1785+ assert_eq!(k.chord(ActionId::Delete), "x");
1786+ assert_eq!(k.chord(ActionId::Undo), "z");
1787+ assert_eq!(k.chord(ActionId::AddFiles), "^o");
1788+ assert_eq!(k.chord(ActionId::CancelExport), "^esc");
1789+ assert_eq!(k.chord(ActionId::Play), "spc");
1790+ assert_eq!(whole("edith-keys 1\n").chord(ActionId::Cut), "--");
1791+ }
1792+
1745 /// The one row of [`FIXED`] that speaks for a whole table elsewhere: it1793 /// The one row of [`FIXED`] that speaks for a whole table elsewhere: it
1746 /// named six keys for seven codecs, and OGG's `o` was a stroke the card1794 /// named six keys for seven codecs, and OGG's `o` was a stroke the card
1747 /// never mentioned. The chord is generated from `FORMATS` now, and this1795 /// never mentioned. The chord is generated from `FORMATS` now, and this
crates/app/src/ui/bench_stance.rsmodified+27 -6
@@ -28,6 +28,7 @@
28 //! answer for.28 //! answer for.
29 29
30 use crate::*;30 use crate::*;
31+use crate::ui::type_scale::{self, Typeset};
31 32
32 /// The pinned ruler's own height, above the lane stack -- tall enough for a33 /// The pinned ruler's own height, above the lane stack -- tall enough for a
33 /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with34 /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with
@@ -275,12 +276,22 @@ fn clip_box(
275 .gap(px(4.))276 .gap(px(4.))
276 .bg(rgba(DARK_SEAM()))277 .bg(rgba(DARK_SEAM()))
277 .when_some(label, |d, label| {278 .when_some(label, |d, label| {
278- d.child(div().min_w(px(0.)).truncate().text_size(px(9.5)).text_color(rgb(INK1())).child(label))279+ d.child(
280+ div()
281+ .min_w(px(0.))
282+ .truncate()
283+ .type_style(type_scale::mono(
284+ type_scale::CHORD_METADATA_MIN_PX,
285+ gpui::FontWeight::MEDIUM,
286+ ))
287+ .text_color(rgb(INK1()))
288+ .child(label),
289+ )
279 })290 })
280 .child(291 .child(
281 div()292 div()
282 .flex_none()293 .flex_none()
283- .text_size(px(9.))294+ .type_style(type_scale::mono(9., gpui::FontWeight::MEDIUM))
284 .text_color(rgb(INK3()))295 .text_color(rgb(INK3()))
285 .child(readout),296 .child(readout),
286 ),297 ),
@@ -296,7 +307,7 @@ fn clip_box(
296 .right_0()307 .right_0()
297 .px(px(3.))308 .px(px(3.))
298 .bg(rgb(DARK_RAISED()))309 .bg(rgb(DARK_RAISED()))
299- .text_size(px(9.))310+ .type_style(type_scale::mono(9., gpui::FontWeight::MEDIUM))
300 .text_color(rgb(INK2()))311 .text_color(rgb(INK2()))
301 .child(format!("{speed}")),312 .child(format!("{speed}")),
302 )313 )
@@ -360,7 +371,11 @@ fn lane_row(
360 .justify_center()371 .justify_center()
361 .gap(px(2.))372 .gap(px(2.))
362 .bg(rgb(DARK_PANEL()))373 .bg(rgb(DARK_PANEL()))
363- .text_size(px(9.5))374+ // MOCK-SPEC.md "Bench": "V1, A1 in mono".
375+ .type_style(type_scale::mono(
376+ type_scale::CHORD_METADATA_MIN_PX,
377+ gpui::FontWeight::MEDIUM,
378+ ))
364 .text_color(rgb(INK2()))379 .text_color(rgb(INK2()))
365 .child(lane.label())380 .child(lane.label())
366 .child(div().flex_none().w(px(4.)).h(px(4.)).rounded(px(2.)).bg(rgb(dot))),381 .child(div().flex_none().w(px(4.)).h(px(4.)).rounded(px(2.)).bg(rgb(dot))),
@@ -462,7 +477,10 @@ pub(crate) fn render(player: &mut Player, box_h: f32, cx: &mut Context<Player>)
462 .child(div().w(px(1.)).h(px(4.)).bg(rgb(INK3())))477 .child(div().w(px(1.)).h(px(4.)).bg(rgb(INK3())))
463 .child(478 .child(
464 div()479 div()
465- .text_size(px(8.))480+ .type_style(type_scale::mono(
481+ type_scale::FLOOR_PX,
482+ gpui::FontWeight::MEDIUM,
483+ ))
466 .text_color(rgb(INK3()))484 .text_color(rgb(INK3()))
467 .child(label),485 .child(label),
468 ),486 ),
@@ -492,7 +510,10 @@ pub(crate) fn render(player: &mut Player, box_h: f32, cx: &mut Context<Player>)
492 .items_center()510 .items_center()
493 .px(px(4.))511 .px(px(4.))
494 .bg(rgb(DARK_CANVAS()))512 .bg(rgb(DARK_CANVAS()))
495- .text_size(px(10.))513+ .type_style(type_scale::mono(
514+ type_scale::CHORD_METADATA_MAX_PX,
515+ gpui::FontWeight::MEDIUM,
516+ ))
496 .text_color(rgb(INK1()))517 .text_color(rgb(INK1()))
497 .child(playhead_tc),518 .child(playhead_tc),
498 ),519 ),
crates/app/src/ui/dock_stance.rsmodified+61 -33
@@ -12,6 +12,8 @@
12 //! [`clip_middle`]...), only the anatomy around them is new.12 //! [`clip_middle`]...), only the anatomy around them is new.
13 13
14 use crate::*;14 use crate::*;
15+use crate::ui::type_scale::{self, head, label, mono};
16+use gpui::FontWeight;
15 17
16 /// Where the dock tab pick lives: one word beside the theme and the18 /// Where the dock tab pick lives: one word beside the theme and the
17 /// keybindings (`ui::theme::config_path`/`save`/`load` is the exact pattern19 /// keybindings (`ui::theme::config_path`/`save`/`load` is the exact pattern
@@ -73,7 +75,7 @@ impl DockSort {
73 /// hover instead of disappearing (§8).75 /// hover instead of disappearing (§8).
74 fn ghost_verb(76 fn ghost_verb(
75 id: &'static str,77 id: &'static str,
76- label: &'static str,78+ verb_label: &'static str,
77 action: ActionId,79 action: ActionId,
78 active: bool,80 active: bool,
79 hint: &str,81 hint: &str,
@@ -88,6 +90,8 @@ fn ghost_verb(
88 }90 }
89 .into();91 .into();
90 let on = enabled.yes();92 let on = enabled.yes();
93+ let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
94+ let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM);
91 div()95 div()
92 .id(id)96 .id(id)
93 .flex_none()97 .flex_none()
@@ -98,7 +102,6 @@ fn ghost_verb(
98 .px(px(8.))102 .px(px(8.))
99 .rounded(px(3.))103 .rounded(px(3.))
100 .when(active, |d| d.bg(rgb(DARK_RAISED())))104 .when(active, |d| d.bg(rgb(DARK_RAISED())))
101- .text_color(rgb(if active { INK1() } else { INK2() }))
102 .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into())105 .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into())
103 .when(!on, |d| d.opacity(0.4).cursor_not_allowed())106 .when(!on, |d| d.opacity(0.4).cursor_not_allowed())
104 .when(on, |d| {107 .when(on, |d| {
@@ -106,11 +109,18 @@ fn ghost_verb(
106 .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))109 .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))
107 .on_click(on_click)110 .on_click(on_click)
108 })111 })
109- .child(label)112+ .child(
113+ div()
114+ .font(label_style.font)
115+ .text_size(label_style.size)
116+ .text_color(rgb(if active { INK1() } else { INK2() }))
117+ .child(verb_label),
118+ )
110 .child(119 .child(
111 div()120 div()
112 .flex_none()121 .flex_none()
113- .text_size(px(9.5))122+ .font(chord_style.font)
123+ .text_size(chord_style.size)
114 .text_color(rgb(if active { INK1() } else { INK3() }))124 .text_color(rgb(if active { INK1() } else { INK3() }))
115 .child(key),125 .child(key),
116 )126 )
@@ -124,7 +134,8 @@ fn ghost_verb(
124 /// DESIGN §11's frequency check puts a lift and a mark far ahead of a tab134 /// DESIGN §11's frequency check puts a lift and a mark far ahead of a tab
125 /// switch -- wearing a chord this room does not answer to would be exactly135 /// switch -- wearing a chord this room does not answer to would be exactly
126 /// the lie DESIGN §4 forbids, so the letters go instead.136 /// the lie DESIGN §4 forbids, so the letters go instead.
127-fn dock_tab(id: &'static str, label: &'static str, active: bool, cx: &mut Context<Player>) -> impl IntoElement {137+fn dock_tab(id: &'static str, label_text: &'static str, active: bool, cx: &mut Context<Player>) -> impl IntoElement {
138+ let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
128 div()139 div()
129 .id(id)140 .id(id)
130 .flex_1()141 .flex_1()
@@ -135,27 +146,28 @@ fn dock_tab(id: &'static str, label: &'static str, active: bool, cx: &mut Contex
135 .pt(px(6.))146 .pt(px(6.))
136 .pb(px(6.))147 .pb(px(6.))
137 .when(active, |d| d.border_t_1().border_color(rgb(INK1())))148 .when(active, |d| d.border_t_1().border_color(rgb(INK1())))
138- .text_size(px(10.5))
139- .text_color(rgb(if active { INK1() } else { INK3() }))
140 .cursor_pointer()149 .cursor_pointer()
141 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {150 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
142- this.dock_src_active = label == "SOURCES";151+ this.dock_src_active = label_text == "SOURCES";
143 save(this.dock_src_active);152 save(this.dock_src_active);
144 cx.notify();153 cx.notify();
145 }))154 }))
146 .child(155 .child(
147 div()156 div()
148- .text_size(px(10.5))157+ .font(style.font)
158+ .text_size(style.size)
149 .text_color(rgb(if active { INK1() } else { INK3() }))159 .text_color(rgb(if active { INK1() } else { INK3() }))
150- .child(label),160+ .child(label_text),
151 )161 )
152 }162 }
153 163
154 /// A 9px uppercase Archivo section head, `ink3` (DESIGN §3).164 /// A 9px uppercase Archivo section head, `ink3` (DESIGN §3).
155 fn section_head(text: impl Into<SharedString>) -> impl IntoElement {165 fn section_head(text: impl Into<SharedString>) -> impl IntoElement {
166+ let style = head();
156 div()167 div()
157 .flex_none()168 .flex_none()
158- .text_size(px(9.))169+ .font(style.font)
170+ .text_size(style.size)
159 .text_color(rgb(INK3()))171 .text_color(rgb(INK3()))
160 .child(text.into())172 .child(text.into())
161 }173 }
@@ -271,31 +283,37 @@ fn source_row(player: &Player, i: usize, row: &Row, placed: usize, picked: bool,
271 )283 )
272 }),284 }),
273 )285 )
274- .child(286+ .child({
287+ let style = mono(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
275 div()288 div()
276 .flex_1()289 .flex_1()
277 .min_w(px(0.))290 .min_w(px(0.))
278 .truncate()291 .truncate()
279- .text_size(px(10.5))292+ .font(style.font)
293+ .text_size(style.size)
280 .text_color(rgb(INK1()))294 .text_color(rgb(INK1()))
281- .child(name),295+ .child(name)
282- )296+ })
283- .child(297+ .child({
298+ let style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM);
284 div()299 div()
285 .flex_none()300 .flex_none()
286- .text_size(px(9.5))301+ .font(style.font)
302+ .text_size(style.size)
287 .text_color(rgb(INK3()))303 .text_color(rgb(INK3()))
288- .child(usage),304+ .child(usage)
289- ),305+ }),
290 )306 )
291- .child(307+ .child({
308+ let style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM);
292 div()309 div()
293 .pl(px(14.))310 .pl(px(14.))
294 .truncate()311 .truncate()
295- .text_size(px(9.5))312+ .font(style.font)
313+ .text_size(style.size)
296 .text_color(rgb(INK3()))314 .text_color(rgb(INK3()))
297- .child(under),315+ .child(under)
298- )316+ })
299 }317 }
300 318
301 /// The Sources tab, built off MOCK-SPEC.md's "Dock" section: count line,319 /// The Sources tab, built off MOCK-SPEC.md's "Dock" section: count line,
@@ -345,12 +363,14 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
345 .p(px(8.))363 .p(px(8.))
346 .overflow_y_scroll()364 .overflow_y_scroll()
347 .child(section_head(format!("SOURCES · {total} · {unused_count} UNUSED")))365 .child(section_head(format!("SOURCES · {total} · {unused_count} UNUSED")))
348- .child(366+ .child({
367+ let style = mono(type_scale::CHORD_METADATA_MAX_PX, FontWeight::MEDIUM);
349 div()368 div()
350 .id("dock-filter")369 .id("dock-filter")
351 .flex_none()370 .flex_none()
352 .cursor_text()371 .cursor_text()
353- .text_size(px(10.))372+ .font(style.font)
373+ .text_size(style.size)
354 .text_color(rgb(if player.dock_filter_edit { INK1() } else { INK3() }))374 .text_color(rgb(if player.dock_filter_edit { INK1() } else { INK3() }))
355 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {375 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
356 this.dock_filter_edit = true;376 this.dock_filter_edit = true;
@@ -359,8 +379,8 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
359 .child(match player.dock_filter.is_empty() {379 .child(match player.dock_filter.is_empty() {
360 true => "⌕ type to filter — name, codec, unused…".to_string(),380 true => "⌕ type to filter — name, codec, unused…".to_string(),
361 false => format!("⌕ {filter_text}"),381 false => format!("⌕ {filter_text}"),
362- }),382+ })
363- )383+ })
364 .child(384 .child(
365 div()385 div()
366 .flex_none()386 .flex_none()
@@ -368,13 +388,15 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
368 .gap(px(4.))388 .gap(px(4.))
369 .children(DockSort::ALL.map(|sort| {389 .children(DockSort::ALL.map(|sort| {
370 let on = sort == player.dock_sort;390 let on = sort == player.dock_sort;
391+ let style = label(9.5, FontWeight::MEDIUM);
371 div()392 div()
372 .id(("dock-sort", sort as usize))393 .id(("dock-sort", sort as usize))
373 .flex_none()394 .flex_none()
374 .px(px(6.))395 .px(px(6.))
375 .py(px(2.))396 .py(px(2.))
376 .rounded(px(3.))397 .rounded(px(3.))
377- .text_size(px(9.5))398+ .font(style.font)
399+ .text_size(style.size)
378 .when(on, |d| d.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))400 .when(on, |d| d.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))
379 .when(!on, |d| d.text_color(rgb(INK3())))401 .when(!on, |d| d.text_color(rgb(INK3())))
380 .cursor_pointer()402 .cursor_pointer()
@@ -396,9 +418,11 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
396 .gap(px(2.))418 .gap(px(2.))
397 .overflow_y_scroll()419 .overflow_y_scroll()
398 .when(rows.is_empty(), |d| {420 .when(rows.is_empty(), |d| {
421+ let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
399 d.child(422 d.child(
400 div()423 div()
401- .text_size(px(10.5))424+ .font(style.font)
425+ .text_size(style.size)
402 .text_color(rgb(INK3()))426 .text_color(rgb(INK3()))
403 .child(match player.dock_filter.is_empty() {427 .child(match player.dock_filter.is_empty() {
404 true => "No sources yet — Add files, or drop one on the window".to_string(),428 true => "No sources yet — Add files, or drop one on the window".to_string(),
@@ -443,16 +467,18 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
443 cx.listener(|this, _: &ClickEvent, _, cx| this.paste_file_path(cx)),467 cx.listener(|this, _: &ClickEvent, _, cx| this.paste_file_path(cx)),
444 )),468 )),
445 )469 )
446- .child(470+ .child({
471+ let style = mono(9., FontWeight::MEDIUM);
447 div()472 div()
448 .flex_none()473 .flex_none()
449- .text_size(px(9.))474+ .font(style.font)
475+ .text_size(style.size)
450 .text_color(rgb(INK3()))476 .text_color(rgb(INK3()))
451 .child(477 .child(
452 "drag a row to a lane · ↵ add at playhead · double-click plays in screen · \478 "drag a row to a lane · ↵ add at playhead · double-click plays in screen · \
453 right-click the dot to re-ink a source (rare — lives out of the way)",479 right-click the dot to re-ink a source (rare — lives out of the way)",
454- ),
455 )480 )
481+ })
456 }482 }
457 483
458 /// The Clip tab: the four verbs DESIGN §5 names, as ghosts, over whichever484 /// The Clip tab: the four verbs DESIGN §5 names, as ghosts, over whichever
@@ -534,12 +560,14 @@ fn clip_tab(player: &Player, width: f32, window_h: Pixels, cx: &mut Context<Play
534 // A plate, not bare space: DESIGN §11's "states" checklist --560 // A plate, not bare space: DESIGN §11's "states" checklist --
535 // nothing picked reads as a hint, not as a hole in the panel.561 // nothing picked reads as a hint, not as a hole in the panel.
536 .when(none_open, |d| {562 .when(none_open, |d| {
563+ let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
537 d.child(564 d.child(
538 div()565 div()
539 .rounded(px(2.))566 .rounded(px(2.))
540 .bg(rgb(DARK_CANVAS()))567 .bg(rgb(DARK_CANVAS()))
541 .p(px(8.))568 .p(px(8.))
542- .text_size(px(10.5))569+ .font(style.font)
570+ .text_size(style.size)
543 .text_color(rgb(INK3()))571 .text_color(rgb(INK3()))
544 .child("pick a verb above"),572 .child("pick a verb above"),
545 )573 )
crates/app/src/ui/spine_stance.rsmodified+31 -23
@@ -3,29 +3,26 @@
3 //! not the flat ungrouped list of glyph-beside-chord rows the shipped room3 //! not the flat ungrouped list of glyph-beside-chord rows the shipped room
4 //! drew. `stance.rs::spine()` keeps the panel frame (width, surface,4 //! drew. `stance.rs::spine()` keeps the panel frame (width, surface,
5 //! border); this module owns the rows inside it.5 //! border); this module owns the rows inside it.
6-//!
7-//! corner-cut: sizes below are plain `px()` literals matching DESIGN §3's
8-//! scale (13px glyph, 9.5px chord, 9px head) rather than calls into a
9-//! `ui::type_scale` API -- that module had not landed in this tree at the
10-//! time this was written. Ceiling: swap these three constants for its
11-//! tokens once it lands; nothing else here would change.
12 6
13 use crate::*;7 use crate::*;
8+use crate::ui::type_scale::{self, Typeset};
14 9
10+/// The glyph icon itself: DESIGN §3 names no separate role for it, so this
11+/// keeps the size the module has always drawn it at (13px, the same number
12+/// as the hero timecode by coincidence, not by role) and routes only the
13+/// font family through [`type_scale`] (Archivo -- the glyph is a verb, the
14+/// room's voice, not something the film says).
15 const GLYPH_SIZE: f32 = 13.;15 const GLYPH_SIZE: f32 = 13.;
16-const CHORD_SIZE: f32 = 9.5;
17-const HEAD_SIZE: f32 = 9.;
18 16
19-/// A group head: 9px uppercase Archivo 700(-weight token, same as every17+/// A group head: 9px uppercase Archivo 700 in `ink3`, +0.14em tracking
20-/// other section head in the stance) in `ink3`, +0.14em tracking (DESIGN18+/// (DESIGN §3) -- reused as its own small fn rather than `stance::section_head`
21-/// §3) -- reused as its own small fn rather than `stance::section_head`
22 /// because that one is private to its module and carries a different19 /// because that one is private to its module and carries a different
23 /// vertical rhythm (a region label, not a spine group head).20 /// vertical rhythm (a region label, not a spine group head).
24 fn group_head(label: &str) -> impl IntoElement {21 fn group_head(label: &str) -> impl IntoElement {
25 div()22 div()
26 .flex_none()23 .flex_none()
27- .pt(px(6.))24+ .pt(px(10.))
28- .text_size(px(HEAD_SIZE))25+ .type_style(type_scale::head())
29 .text_color(rgb(INK3()))26 .text_color(rgb(INK3()))
30 .child(label.to_uppercase())27 .child(label.to_uppercase())
31 }28 }
@@ -46,12 +43,17 @@ fn glyph(
46 cx: &mut Context<Player>,43 cx: &mut Context<Player>,
47 ) -> impl IntoElement + use<> {44 ) -> impl IntoElement + use<> {
48 let enabled = player.enable(action, None);45 let enabled = player.enable(action, None);
49- let key = player.keymap.display(action);46+ // The badge shows the primary chord only (FAULT 1: a chord badge is a
47+ // compact token, not a sentence); the tooltip keeps every stroke an
48+ // action answers to, and the keys overlay ([`crate::ui::stance`]) is
49+ // still where the full truth lives.
50+ let full = player.keymap.display(action);
50 let say: SharedString = match enabled.why() {51 let say: SharedString = match enabled.why() {
51- Some(why) => format!("{key} — {why}"),52+ Some(why) => format!("{full} — {why}"),
52- None => format!("{key} — {}", action.label()),53+ None => format!("{full} — {}", action.label()),
53 }54 }
54 .into();55 .into();
56+ let compact = player.keymap.chord(action);
55 let on = enabled.yes();57 let on = enabled.yes();
56 div()58 div()
57 .id(id)59 .id(id)
@@ -59,9 +61,9 @@ fn glyph(
59 .flex()61 .flex()
60 .flex_col()62 .flex_col()
61 .items_center()63 .items_center()
62- .gap(px(2.))64+ .gap(px(1.))
63 .px(px(4.))65 .px(px(4.))
64- .py(px(4.))66+ .py(px(2.))
65 .rounded(px(3.))67 .rounded(px(3.))
66 .when(active, |d| d.bg(rgb(DARK_RAISED())))68 .when(active, |d| d.bg(rgb(DARK_RAISED())))
67 .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into())69 .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into())
@@ -75,15 +77,18 @@ fn glyph(
75 })77 })
76 .child(78 .child(
77 div()79 div()
78- .text_size(px(GLYPH_SIZE))80+ .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::MEDIUM))
79 .text_color(rgb(if active { INK1() } else { INK2() }))81 .text_color(rgb(if active { INK1() } else { INK2() }))
80 .child(glyph),82 .child(glyph),
81 )83 )
82 .child(84 .child(
83 div()85 div()
84- .text_size(px(CHORD_SIZE))86+ .type_style(type_scale::mono(
87+ type_scale::CHORD_METADATA_MIN_PX,
88+ gpui::FontWeight::MEDIUM,
89+ ))
85 .text_color(rgb(INK3()))90 .text_color(rgb(INK3()))
86- .child(key),91+ .child(compact),
87 )92 )
88 }93 }
89 94
@@ -96,7 +101,7 @@ fn pair(left: impl IntoElement, right: impl IntoElement) -> impl IntoElement {
96 .flex()101 .flex()
97 .items_center()102 .items_center()
98 .justify_center()103 .justify_center()
99- .gap(px(10.))104+ .gap(px(6.))
100 .child(left)105 .child(left)
101 .child(right)106 .child(right)
102 }107 }
@@ -123,7 +128,10 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
123 .flex()128 .flex()
124 .flex_col()129 .flex_col()
125 .items_center()130 .items_center()
126- .gap(px(10.))131+ // FAULT 2: rows close under their group head, real space (the group
132+ // head's own `pt`) only between one group and the next -- not one
133+ // uniform gap stretching every row down the window.
134+ .gap(px(2.))
127 .overflow_y_scroll()135 .overflow_y_scroll()
128 .child(group_head("edit"))136 .child(group_head("edit"))
129 .child(glyph("spine-split", "||", ActionId::Cut, false, player, cx))137 .child(glyph("spine-split", "||", ActionId::Cut, false, player, cx))
crates/app/src/ui/stance.rsmodified+86 -16
@@ -13,6 +13,7 @@ use crate::ui::bench_stance;
13 use crate::ui::dock_stance;13 use crate::ui::dock_stance;
14 use crate::ui::timeband_stance;14 use crate::ui::timeband_stance;
15 use crate::ui::spine_stance;15 use crate::ui::spine_stance;
16+use crate::ui::type_scale::{self, Typeset};
16 17
17 /// Left rail, full height (DESIGN §5).18 /// Left rail, full height (DESIGN §5).
18 const SPINE_W: f32 = 56.;19 const SPINE_W: f32 = 56.;
@@ -35,7 +36,7 @@ const DOCK_W: f32 = 280.;
35 fn section_head(label: &str) -> impl IntoElement {36 fn section_head(label: &str) -> impl IntoElement {
36 div()37 div()
37 .flex_none()38 .flex_none()
38- .text_size(px(9.))39+ .type_style(type_scale::head())
39 .text_color(rgb(INK3()))40 .text_color(rgb(INK3()))
40 .child(label.to_uppercase())41 .child(label.to_uppercase())
41 }42 }
@@ -52,14 +53,19 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {
52 .gap(px(2.))53 .gap(px(2.))
53 .py(px(6.))54 .py(px(6.))
54 .rounded(px(3.))55 .rounded(px(3.))
55- .text_size(px(13.))56+ .type_style(type_scale::label(13., gpui::FontWeight::MEDIUM))
56 .text_color(rgb(INK2()))57 .text_color(rgb(INK2()))
57 .child(glyph.to_string())58 .child(glyph.to_string())
58 .child(59 .child(
59 div()60 div()
60- .text_size(px(9.5))61+ .type_style(type_scale::mono(
62+ type_scale::CHORD_METADATA_MIN_PX,
63+ gpui::FontWeight::MEDIUM,
64+ ))
61 .text_color(rgb(INK3()))65 .text_color(rgb(INK3()))
62- .child(player.keymap.display(action)),66+ // FAULT 1: the badge shows the primary chord, compact --
67+ // same rule as every glyph in `spine_stance`.
68+ .child(player.keymap.chord(action)),
63 )69 )
64 }70 }
65 71
@@ -112,7 +118,7 @@ fn keys_overlay(player: &Player) -> impl IntoElement {
112 KeyRow::Head(category) => div()118 KeyRow::Head(category) => div()
113 .flex_none()119 .flex_none()
114 .pt(px(4.))120 .pt(px(4.))
115- .text_size(px(9.))121+ .type_style(type_scale::head())
116 .text_color(rgb(INK3()))122 .text_color(rgb(INK3()))
117 .child(category.label().to_uppercase())123 .child(category.label().to_uppercase())
118 .into_any_element(),124 .into_any_element(),
@@ -120,9 +126,27 @@ fn keys_overlay(player: &Player) -> impl IntoElement {
120 .flex()126 .flex()
121 .justify_between()127 .justify_between()
122 .gap(px(12.))128 .gap(px(12.))
123- .text_size(px(9.5))129+ .child(
124- .child(div().text_color(rgb(INK2())).child(action.label()))130+ div()
125- .child(div().text_color(rgb(INK3())).child(player.keymap.display(action)))131+ .type_style(type_scale::label(
132+ type_scale::CHORD_METADATA_MIN_PX,
133+ gpui::FontWeight::MEDIUM,
134+ ))
135+ .text_color(rgb(INK2()))
136+ .child(action.label()),
137+ )
138+ .child(
139+ div()
140+ .type_style(type_scale::mono(
141+ type_scale::CHORD_METADATA_MIN_PX,
142+ gpui::FontWeight::MEDIUM,
143+ ))
144+ .text_color(rgb(INK3()))
145+ // The keys overlay is the full-truth surface
146+ // (FAULT 1): every chord an action answers to,
147+ // not the badge's primary-only compact form.
148+ .child(player.keymap.display(action)),
149+ )
126 .into_any_element(),150 .into_any_element(),
127 KeyRow::Fixed(i) => {151 KeyRow::Fixed(i) => {
128 let f = &keymap::FIXED[i];152 let f = &keymap::FIXED[i];
@@ -130,9 +154,24 @@ fn keys_overlay(player: &Player) -> impl IntoElement {
130 .flex()154 .flex()
131 .justify_between()155 .justify_between()
132 .gap(px(12.))156 .gap(px(12.))
133- .text_size(px(9.5))157+ .child(
134- .child(div().text_color(rgb(INK2())).child(f.label))158+ div()
135- .child(div().text_color(rgb(INK3())).child(f.chord.clone()))159+ .type_style(type_scale::label(
160+ type_scale::CHORD_METADATA_MIN_PX,
161+ gpui::FontWeight::MEDIUM,
162+ ))
163+ .text_color(rgb(INK2()))
164+ .child(f.label),
165+ )
166+ .child(
167+ div()
168+ .type_style(type_scale::mono(
169+ type_scale::CHORD_METADATA_MIN_PX,
170+ gpui::FontWeight::MEDIUM,
171+ ))
172+ .text_color(rgb(INK3()))
173+ .child(f.chord.clone()),
174+ )
136 .into_any_element()175 .into_any_element()
137 }176 }
138 })),177 })),
@@ -278,7 +317,7 @@ fn notice_plate(message: SharedString) -> impl IntoElement {
278 // shape as the legacy notice bar's own tone stripe (`notice_bar`).317 // shape as the legacy notice bar's own tone stripe (`notice_bar`).
279 .border_l(px(3.))318 .border_l(px(3.))
280 .border_color(rgb(notice_severity(&message)))319 .border_color(rgb(notice_severity(&message)))
281- .text_size(px(10.))320+ .type_style(type_scale::label(10., gpui::FontWeight::MEDIUM))
282 .text_color(rgb(INK1()))321 .text_color(rgb(INK1()))
283 .child(message)322 .child(message)
284 }323 }
@@ -308,18 +347,49 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement {
308 .gap(px(14.))347 .gap(px(14.))
309 .px(px(12.))348 .px(px(12.))
310 .child(section_head("ledger"))349 .child(section_head("ledger"))
311- .child(div().text_size(px(9.5)).text_color(rgb(INK1())).child(identity))350+ // MOCK-SPEC.md "Ledger": "All mono" -- project identity, last
351+ // action, export progress and position are all what the film/project
352+ // says, not the room's own voice.
353+ .child(
354+ div()
355+ .type_style(type_scale::mono(
356+ type_scale::CHORD_METADATA_MIN_PX,
357+ gpui::FontWeight::MEDIUM,
358+ ))
359+ .text_color(rgb(INK1()))
360+ .child(identity),
361+ )
312 .child(362 .child(
313 div()363 div()
314 .flex_1()364 .flex_1()
315 .min_w(px(0.))365 .min_w(px(0.))
316 .truncate()366 .truncate()
317- .text_size(px(9.5))367+ .type_style(type_scale::mono(
368+ type_scale::CHORD_METADATA_MIN_PX,
369+ gpui::FontWeight::MEDIUM,
370+ ))
318 .text_color(rgb(INK3()))371 .text_color(rgb(INK3()))
319 .child(last_action),372 .child(last_action),
320 )373 )
321- .children(export.map(|e| div().text_size(px(9.5)).text_color(rgb(INK2())).child(e)))374+ .children(export.map(|e| {
322- .child(div().flex_none().text_size(px(9.5)).text_color(rgb(INK2())).child(tc))375+ div()
376+ .type_style(type_scale::mono(
377+ type_scale::CHORD_METADATA_MIN_PX,
378+ gpui::FontWeight::MEDIUM,
379+ ))
380+ .text_color(rgb(INK2()))
381+ .child(e)
382+ }))
383+ .child(
384+ div()
385+ .flex_none()
386+ .type_style(type_scale::mono(
387+ type_scale::CHORD_METADATA_MIN_PX,
388+ gpui::FontWeight::MEDIUM,
389+ ))
390+ .text_color(rgb(INK2()))
391+ .child(tc),
392+ )
323 }393 }
324 394
325 /// The dock: the only side panel, right, fixed width, carrying the Src/Clip395 /// The dock: the only side panel, right, fixed width, carrying the Src/Clip
crates/app/src/ui/timeband_stance.rsmodified+44 -13
@@ -8,9 +8,12 @@
8 //! (MOCK-SPEC.md) reads closer to ~20px. Kept at 13px here -- the binding8 //! (MOCK-SPEC.md) reads closer to ~20px. Kept at 13px here -- the binding
9 //! contract's own number, already what `stance.rs::time_band()` shipped --9 //! contract's own number, already what `stance.rs::time_band()` shipped --
10 //! rather than silently picking the mock's, and named here per this task's10 //! rather than silently picking the mock's, and named here per this task's
11-//! own instruction to say so when the two disagree.11+//! own instruction to say so when the two disagree. Every size in this
12+//! module now comes from `ui::type_scale` (role, not a bare `px()` literal).
12 13
13 use crate::*;14 use crate::*;
15+use crate::ui::type_scale::{self, label, mono};
16+use gpui::FontWeight;
14 17
15 thread_local! {18 thread_local! {
16 // corner-cut: every other drag surface in this codebase (the bench19 // corner-cut: every other drag surface in this codebase (the bench
@@ -30,18 +33,24 @@ thread_local! {
30 /// fires it -- the same shape `stance::ghost` draws for the spine, kept local33 /// fires it -- the same shape `stance::ghost` draws for the spine, kept local
31 /// here so this module owns its own region end to end.34 /// here so this module owns its own region end to end.
32 fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {35 fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {
36+ 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
38+ // ... 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);
33 div()40 div()
34 .flex_none()41 .flex_none()
35 .flex()42 .flex()
36 .flex_col()43 .flex_col()
37 .items_center()44 .items_center()
38 .gap(px(1.))45 .gap(px(1.))
39- .text_size(px(13.))46+ .font(glyph_style.font)
47+ .text_size(glyph_style.size)
40 .text_color(rgb(INK2()))48 .text_color(rgb(INK2()))
41 .child(glyph.to_string())49 .child(glyph.to_string())
42 .child(50 .child(
43 div()51 div()
44- .text_size(px(9.))52+ .font(chord_style.font)
53+ .text_size(chord_style.size)
45 .text_color(rgb(INK3()))54 .text_color(rgb(INK3()))
46 .child(player.keymap.display(action)),55 .child(player.keymap.display(action)),
47 )56 )
@@ -52,10 +61,12 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {
52 /// rather than painted whole, so the colons can read a shade quieter than61 /// rather than painted whole, so the colons can read a shade quieter than
53 /// the numbers either side of them.62 /// the numbers either side of them.
54 fn hero_timecode(tc: &str) -> impl IntoElement {63 fn hero_timecode(tc: &str) -> impl IntoElement {
64+ let style = mono(type_scale::HERO_TIMECODE_PX, FontWeight::BOLD);
55 div()65 div()
56 .flex_none()66 .flex_none()
57 .flex()67 .flex()
58- .text_size(px(13.))68+ .font(style.font)
69+ .text_size(style.size)
59 .children(tc.chars().map(|c| {70 .children(tc.chars().map(|c| {
60 let ink = if c == ':' { INK3() } else { INK1() };71 let ink = if c == ':' { INK3() } else { INK1() };
61 div().text_color(rgb(ink)).child(c.to_string())72 div().text_color(rgb(ink)).child(c.to_string())
@@ -99,6 +110,7 @@ fn cut_readout(player: &Player) -> impl IntoElement {
99 ))110 ))
100 });111 });
101 let roll_on = player.loop_trim.is_some();112 let roll_on = player.loop_trim.is_some();
113+ let style = mono(type_scale::CHORD_METADATA_MAX_PX, FontWeight::MEDIUM);
102 div()114 div()
103 .id("stance-cut-readout")115 .id("stance-cut-readout")
104 .flex_none()116 .flex_none()
@@ -108,7 +120,8 @@ fn cut_readout(player: &Player) -> impl IntoElement {
108 .py(px(4.))120 .py(px(4.))
109 .rounded(px(2.))121 .rounded(px(2.))
110 .bg(rgb(DARK_CANVAS()))122 .bg(rgb(DARK_CANVAS()))
111- .text_size(px(10.5))123+ .font(style.font)
124+ .text_size(style.size)
112 .child(val(odometer))125 .child(val(odometer))
113 .when_some(deltas, |el, (in_d, out_d)| {126 .when_some(deltas, |el, (in_d, out_d)| {
114 el.child(sep())127 el.child(sep())
@@ -278,16 +291,20 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement
278 /// by [`super::stance::render`] the same way the keys overlay is.291 /// by [`super::stance::render`] the same way the keys overlay is.
279 fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {292 fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
280 let exporting = player.exporting().is_some();293 let exporting = player.exporting().is_some();
294+ let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
295+ let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM);
281 div()296 div()
282 .id("stance-export")297 .id("stance-export")
283 .flex_none()298 .flex_none()
299+ .flex()
300+ .items_center()
301+ .gap(px(6.))
284 .px(px(10.))302 .px(px(10.))
285 .py(px(6.))303 .py(px(6.))
286 .rounded(px(3.))304 .rounded(px(3.))
287 .border_1()305 .border_1()
288 .border_color(rgb(DARK_HAIRLINE()))306 .border_color(rgb(DARK_HAIRLINE()))
289 .bg(rgb(DARK_RAISED()))307 .bg(rgb(DARK_RAISED()))
290- .text_size(px(10.5))
291 .text_color(rgb(INK1()))308 .text_color(rgb(INK1()))
292 .cursor_pointer()309 .cursor_pointer()
293 .hover(|s| s.bg(rgb(DARK_PANEL())))310 .hover(|s| s.bg(rgb(DARK_PANEL())))
@@ -299,11 +316,19 @@ fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
299 }316 }
300 cx.notify();317 cx.notify();
301 }))318 }))
302- .child(format!(319+ .child(
303- "{} {}",320+ div()
304- if exporting { "Exporting" } else { "Export" },321+ .font(label_style.font)
305- player.keymap.display(ActionId::Export)322+ .text_size(label_style.size)
306- ))323+ .child(if exporting { "Exporting" } else { "Export" }),
324+ )
325+ .child(
326+ div()
327+ .font(chord_style.font)
328+ .text_size(chord_style.size)
329+ .text_color(rgb(INK3()))
330+ .child(player.keymap.display(ActionId::Export)),
331+ )
307 }332 }
308 333
309 /// The whole band, left to right per MOCK-SPEC: hero timecode, ghost334 /// The whole band, left to right per MOCK-SPEC: hero timecode, ghost
@@ -312,8 +337,14 @@ fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
312 pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player>) -> impl IntoElement {337 pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player>) -> impl IntoElement {
313 let tc = timecode(position, player.active_fps());338 let tc = timecode(position, player.active_fps());
314 div()339 div()
315- .id("stance-time-band")340+ .id("stance-time-band-row")
316- .flex_none()341+ // FAULT 1 fix: this div used to be `flex_none`, which sized it to its
342+ // own content inside `stance.rs::time_band()`'s row -- leaving the
343+ // contact strip's `flex_1` nothing to grow into (its "free space" was
344+ // zero, since the parent itself never claimed the band's full width).
345+ // `flex_1` here is what actually lets the strip fill the band.
346+ .flex_1()
347+ .min_w(px(0.))
317 .h_full()348 .h_full()
318 .flex()349 .flex()
319 .items_center()350 .items_center()
crates/app/src/ui/type_scale.rsmodified+13 -1
@@ -27,7 +27,7 @@
27 // crate's only caller of the public API is `main.rs`'s `register`.27 // crate's only caller of the public API is `main.rs`'s `register`.
28 #![allow(dead_code)]28 #![allow(dead_code)]
29 29
30-use gpui::{App, Font, FontFeatures, FontWeight, Pixels, SharedString, font, px};30+use gpui::{App, Font, FontFeatures, FontWeight, Pixels, SharedString, Styled, font, px};
31 use std::borrow::Cow;31 use std::borrow::Cow;
32 32
33 /// Archivo: labels, verbs, section heads.33 /// Archivo: labels, verbs, section heads.
@@ -113,6 +113,18 @@ pub fn head() -> TypeStyle {
113 label(SECTION_HEAD_PX, FontWeight::BOLD)113 label(SECTION_HEAD_PX, FontWeight::BOLD)
114 }114 }
115 115
116+/// Applies a [`TypeStyle`] to any styled element in one call --
117+/// `div().type_style(mono(9.5, FontWeight::MEDIUM))` instead of the
118+/// `.font(style.font).text_size(style.size)` pair spelled out at every call
119+/// site. Blanket-implemented over `Styled` so every element in the room gets
120+/// it for free.
121+pub trait Typeset: Styled + Sized {
122+ fn type_style(self, style: TypeStyle) -> Self {
123+ self.font(style.font).text_size(style.size)
124+ }
125+}
126+impl<T: Styled> Typeset for T {}
127+
116 /// One face's worth of TTFs to embed, `(bytes, name)` for the doc comment128 /// One face's worth of TTFs to embed, `(bytes, name)` for the doc comment
117 /// above `register` to explain if a load ever fails.129 /// above `register` to explain if a load ever fails.
118 const EMBEDDED: &[(&[u8], &str)] = &[130 const EMBEDDED: &[(&[u8], &str)] = &[