From d5dd5fc620e93082b78dc4abb467abec59db1b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 20 Aug 2026 15:24:13 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style(ui):=20the=20room=20speaks?= =?UTF-8?q?=20in=20its=20own=20type=20and=20its=20badges=20get=20terse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.rs | 48 +++++++++++++ crates/app/src/ui/bench_stance.rs | 33 +++++++-- crates/app/src/ui/dock_stance.rs | 96 ++++++++++++++++--------- crates/app/src/ui/spine_stance.rs | 54 ++++++++------ crates/app/src/ui/stance.rs | 102 ++++++++++++++++++++++----- crates/app/src/ui/timeband_stance.rs | 57 +++++++++++---- crates/app/src/ui/type_scale.rs | 14 +++- 7 files changed, 311 insertions(+), 93 deletions(-) diff --git a/crates/app/src/keymap.rs b/crates/app/src/keymap.rs index 14c3cf8..9e520ef 100644 --- a/crates/app/src/keymap.rs +++ b/crates/app/src/keymap.rs @@ -877,6 +877,26 @@ impl Chord { } } + /// The spelling a badge with room for one token reads (MOCK-SPEC.md + /// "Spine": `del`, `z`, not `x or delete`, `ctrl+z`): `^` in place of + /// `ctrl+`, and the handful of key names whose everyday short form isn't + /// gpui's own (`delete` -> `del`, `escape` -> `esc`, `space` -> `spc`). + /// [`Chord::pretty`] stays the keys overlay's own spelling -- this is for + /// a glyph badge, not the full truth. + pub fn compact(&self) -> String { + let key = match self.key.as_str() { + "escape" => "esc", + "delete" => "del", + "space" => "spc", + other => other, + }; + if self.ctrl { + format!("^{key}") + } else { + key.to_string() + } + } + /// Whether the file can carry this stroke and read it back as itself. gpui /// reports strokes this format cannot spell -- shift+= arrives as the key /// `"+"`, which is the chord grammar's own separator -- and binding one @@ -1215,6 +1235,20 @@ impl Keymap { } } + /// The primary chord for `action`, compact ([`Chord::compact`]) -- a + /// badge that has room for one token, not [`Keymap::display`]'s sentence. + /// The first bound stroke wins (`defaults`' own insertion order, and + /// `rebind_action`'s "makes `chord` the whole of what reaches `action`" + /// leaves at most one anyway); an action with no stroke reads `--` + /// rather than the unbound sentence, since a badge is not a warning. + pub fn chord(&self, action: ActionId) -> String { + self.bindings + .iter() + .find(|b| b.action == action) + .map(|b| b.chord.compact()) + .unwrap_or_else(|| "--".to_string()) + } + /// Every binding, in display order. pub fn entries(&self) -> &[Binding] { &self.bindings @@ -1742,6 +1776,20 @@ mod tests { assert_eq!(k.display(ActionId::ZoomIn), "ctrl+="); } + /// [`Keymap::chord`] is the badge's one token, not [`Keymap::display`]'s + /// sentence: the primary (first-bound) stroke only, `^` for ctrl, and the + /// short names a glyph badge actually has room for. + #[test] + fn chord_is_the_primary_stroke_compact() { + let k = Keymap::defaults(); + assert_eq!(k.chord(ActionId::Delete), "x"); + assert_eq!(k.chord(ActionId::Undo), "z"); + assert_eq!(k.chord(ActionId::AddFiles), "^o"); + assert_eq!(k.chord(ActionId::CancelExport), "^esc"); + assert_eq!(k.chord(ActionId::Play), "spc"); + assert_eq!(whole("edith-keys 1\n").chord(ActionId::Cut), "--"); + } + /// The one row of [`FIXED`] that speaks for a whole table elsewhere: it /// named six keys for seven codecs, and OGG's `o` was a stroke the card /// never mentioned. The chord is generated from `FORMATS` now, and this diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index 5b80a8e..42cf8df 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -28,6 +28,7 @@ //! answer for. use crate::*; +use crate::ui::type_scale::{self, Typeset}; /// The pinned ruler's own height, above the lane stack -- tall enough for a /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with @@ -275,12 +276,22 @@ fn clip_box( .gap(px(4.)) .bg(rgba(DARK_SEAM())) .when_some(label, |d, label| { - d.child(div().min_w(px(0.)).truncate().text_size(px(9.5)).text_color(rgb(INK1())).child(label)) + d.child( + div() + .min_w(px(0.)) + .truncate() + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK1())) + .child(label), + ) }) .child( div() .flex_none() - .text_size(px(9.)) + .type_style(type_scale::mono(9., gpui::FontWeight::MEDIUM)) .text_color(rgb(INK3())) .child(readout), ), @@ -296,7 +307,7 @@ fn clip_box( .right_0() .px(px(3.)) .bg(rgb(DARK_RAISED())) - .text_size(px(9.)) + .type_style(type_scale::mono(9., gpui::FontWeight::MEDIUM)) .text_color(rgb(INK2())) .child(format!("{speed}")), ) @@ -360,7 +371,11 @@ fn lane_row( .justify_center() .gap(px(2.)) .bg(rgb(DARK_PANEL())) - .text_size(px(9.5)) + // MOCK-SPEC.md "Bench": "V1, A1 in mono". + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK2())) .child(lane.label()) .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) .child(div().w(px(1.)).h(px(4.)).bg(rgb(INK3()))) .child( div() - .text_size(px(8.)) + .type_style(type_scale::mono( + type_scale::FLOOR_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) .child(label), ), @@ -492,7 +510,10 @@ pub(crate) fn render(player: &mut Player, box_h: f32, cx: &mut Context) .items_center() .px(px(4.)) .bg(rgb(DARK_CANVAS())) - .text_size(px(10.)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MAX_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK1())) .child(playhead_tc), ), diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index c6ae5ab..15de432 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -12,6 +12,8 @@ //! [`clip_middle`]...), only the anatomy around them is new. use crate::*; +use crate::ui::type_scale::{self, head, label, mono}; +use gpui::FontWeight; /// Where the dock tab pick lives: one word beside the theme and the /// keybindings (`ui::theme::config_path`/`save`/`load` is the exact pattern @@ -73,7 +75,7 @@ impl DockSort { /// hover instead of disappearing (§8). fn ghost_verb( id: &'static str, - label: &'static str, + verb_label: &'static str, action: ActionId, active: bool, hint: &str, @@ -88,6 +90,8 @@ fn ghost_verb( } .into(); let on = enabled.yes(); + let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); + let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); div() .id(id) .flex_none() @@ -98,7 +102,6 @@ fn ghost_verb( .px(px(8.)) .rounded(px(3.)) .when(active, |d| d.bg(rgb(DARK_RAISED()))) - .text_color(rgb(if active { INK1() } else { INK2() })) .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) .when(on, |d| { @@ -106,11 +109,18 @@ fn ghost_verb( .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) .on_click(on_click) }) - .child(label) + .child( + div() + .font(label_style.font) + .text_size(label_style.size) + .text_color(rgb(if active { INK1() } else { INK2() })) + .child(verb_label), + ) .child( div() .flex_none() - .text_size(px(9.5)) + .font(chord_style.font) + .text_size(chord_style.size) .text_color(rgb(if active { INK1() } else { INK3() })) .child(key), ) @@ -124,7 +134,8 @@ fn ghost_verb( /// DESIGN §11's frequency check puts a lift and a mark far ahead of a tab /// switch -- wearing a chord this room does not answer to would be exactly /// the lie DESIGN §4 forbids, so the letters go instead. -fn dock_tab(id: &'static str, label: &'static str, active: bool, cx: &mut Context) -> impl IntoElement { +fn dock_tab(id: &'static str, label_text: &'static str, active: bool, cx: &mut Context) -> impl IntoElement { + let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); div() .id(id) .flex_1() @@ -135,27 +146,28 @@ fn dock_tab(id: &'static str, label: &'static str, active: bool, cx: &mut Contex .pt(px(6.)) .pb(px(6.)) .when(active, |d| d.border_t_1().border_color(rgb(INK1()))) - .text_size(px(10.5)) - .text_color(rgb(if active { INK1() } else { INK3() })) .cursor_pointer() .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { - this.dock_src_active = label == "SOURCES"; + this.dock_src_active = label_text == "SOURCES"; save(this.dock_src_active); cx.notify(); })) .child( div() - .text_size(px(10.5)) + .font(style.font) + .text_size(style.size) .text_color(rgb(if active { INK1() } else { INK3() })) - .child(label), + .child(label_text), ) } /// A 9px uppercase Archivo section head, `ink3` (DESIGN §3). fn section_head(text: impl Into) -> impl IntoElement { + let style = head(); div() .flex_none() - .text_size(px(9.)) + .font(style.font) + .text_size(style.size) .text_color(rgb(INK3())) .child(text.into()) } @@ -271,31 +283,37 @@ fn source_row(player: &Player, i: usize, row: &Row, placed: usize, picked: bool, ) }), ) - .child( + .child({ + let style = mono(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); div() .flex_1() .min_w(px(0.)) .truncate() - .text_size(px(10.5)) + .font(style.font) + .text_size(style.size) .text_color(rgb(INK1())) - .child(name), - ) - .child( + .child(name) + }) + .child({ + let style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); div() .flex_none() - .text_size(px(9.5)) + .font(style.font) + .text_size(style.size) .text_color(rgb(INK3())) - .child(usage), - ), + .child(usage) + }), ) - .child( + .child({ + let style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); div() .pl(px(14.)) .truncate() - .text_size(px(9.5)) + .font(style.font) + .text_size(style.size) .text_color(rgb(INK3())) - .child(under), - ) + .child(under) + }) } /// 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) -> impl IntoElement { .p(px(8.)) .overflow_y_scroll() .child(section_head(format!("SOURCES · {total} · {unused_count} UNUSED"))) - .child( + .child({ + let style = mono(type_scale::CHORD_METADATA_MAX_PX, FontWeight::MEDIUM); div() .id("dock-filter") .flex_none() .cursor_text() - .text_size(px(10.)) + .font(style.font) + .text_size(style.size) .text_color(rgb(if player.dock_filter_edit { INK1() } else { INK3() })) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { this.dock_filter_edit = true; @@ -359,8 +379,8 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .child(match player.dock_filter.is_empty() { true => "⌕ type to filter — name, codec, unused…".to_string(), false => format!("⌕ {filter_text}"), - }), - ) + }) + }) .child( div() .flex_none() @@ -368,13 +388,15 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .gap(px(4.)) .children(DockSort::ALL.map(|sort| { let on = sort == player.dock_sort; + let style = label(9.5, FontWeight::MEDIUM); div() .id(("dock-sort", sort as usize)) .flex_none() .px(px(6.)) .py(px(2.)) .rounded(px(3.)) - .text_size(px(9.5)) + .font(style.font) + .text_size(style.size) .when(on, |d| d.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) .when(!on, |d| d.text_color(rgb(INK3()))) .cursor_pointer() @@ -396,9 +418,11 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .gap(px(2.)) .overflow_y_scroll() .when(rows.is_empty(), |d| { + let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); d.child( div() - .text_size(px(10.5)) + .font(style.font) + .text_size(style.size) .text_color(rgb(INK3())) .child(match player.dock_filter.is_empty() { 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) -> impl IntoElement { cx.listener(|this, _: &ClickEvent, _, cx| this.paste_file_path(cx)), )), ) - .child( + .child({ + let style = mono(9., FontWeight::MEDIUM); div() .flex_none() - .text_size(px(9.)) + .font(style.font) + .text_size(style.size) .text_color(rgb(INK3())) .child( "drag a row to a lane · ↵ add at playhead · double-click plays in screen · \ right-click the dot to re-ink a source (rare — lives out of the way)", - ), - ) + ) + }) } /// 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 impl IntoElement { div() .flex_none() - .pt(px(6.)) - .text_size(px(HEAD_SIZE)) + .pt(px(10.)) + .type_style(type_scale::head()) .text_color(rgb(INK3())) .child(label.to_uppercase()) } @@ -46,12 +43,17 @@ fn glyph( cx: &mut Context, ) -> impl IntoElement + use<> { let enabled = player.enable(action, None); - let key = player.keymap.display(action); + // 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 + // action answers to, and the keys overlay ([`crate::ui::stance`]) is + // still where the full truth lives. + let full = player.keymap.display(action); let say: SharedString = match enabled.why() { - Some(why) => format!("{key} — {why}"), - None => format!("{key} — {}", action.label()), + Some(why) => format!("{full} — {why}"), + None => format!("{full} — {}", action.label()), } .into(); + let compact = player.keymap.chord(action); let on = enabled.yes(); div() .id(id) @@ -59,9 +61,9 @@ fn glyph( .flex() .flex_col() .items_center() - .gap(px(2.)) + .gap(px(1.)) .px(px(4.)) - .py(px(4.)) + .py(px(2.)) .rounded(px(3.)) .when(active, |d| d.bg(rgb(DARK_RAISED()))) .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) @@ -75,15 +77,18 @@ fn glyph( }) .child( div() - .text_size(px(GLYPH_SIZE)) + .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::MEDIUM)) .text_color(rgb(if active { INK1() } else { INK2() })) .child(glyph), ) .child( div() - .text_size(px(CHORD_SIZE)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) - .child(key), + .child(compact), ) } @@ -96,7 +101,7 @@ fn pair(left: impl IntoElement, right: impl IntoElement) -> impl IntoElement { .flex() .items_center() .justify_center() - .gap(px(10.)) + .gap(px(6.)) .child(left) .child(right) } @@ -123,7 +128,10 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem .flex() .flex_col() .items_center() - .gap(px(10.)) + // FAULT 2: rows close under their group head, real space (the group + // head's own `pt`) only between one group and the next -- not one + // uniform gap stretching every row down the window. + .gap(px(2.)) .overflow_y_scroll() .child(group_head("edit")) .child(glyph("spine-split", "||", ActionId::Cut, false, player, cx)) diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 00ce863..b951550 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -13,6 +13,7 @@ use crate::ui::bench_stance; use crate::ui::dock_stance; use crate::ui::timeband_stance; use crate::ui::spine_stance; +use crate::ui::type_scale::{self, Typeset}; /// Left rail, full height (DESIGN §5). const SPINE_W: f32 = 56.; @@ -35,7 +36,7 @@ const DOCK_W: f32 = 280.; fn section_head(label: &str) -> impl IntoElement { div() .flex_none() - .text_size(px(9.)) + .type_style(type_scale::head()) .text_color(rgb(INK3())) .child(label.to_uppercase()) } @@ -52,14 +53,19 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { .gap(px(2.)) .py(px(6.)) .rounded(px(3.)) - .text_size(px(13.)) + .type_style(type_scale::label(13., gpui::FontWeight::MEDIUM)) .text_color(rgb(INK2())) .child(glyph.to_string()) .child( div() - .text_size(px(9.5)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) - .child(player.keymap.display(action)), + // FAULT 1: the badge shows the primary chord, compact -- + // same rule as every glyph in `spine_stance`. + .child(player.keymap.chord(action)), ) } @@ -112,7 +118,7 @@ fn keys_overlay(player: &Player) -> impl IntoElement { KeyRow::Head(category) => div() .flex_none() .pt(px(4.)) - .text_size(px(9.)) + .type_style(type_scale::head()) .text_color(rgb(INK3())) .child(category.label().to_uppercase()) .into_any_element(), @@ -120,9 +126,27 @@ fn keys_overlay(player: &Player) -> impl IntoElement { .flex() .justify_between() .gap(px(12.)) - .text_size(px(9.5)) - .child(div().text_color(rgb(INK2())).child(action.label())) - .child(div().text_color(rgb(INK3())).child(player.keymap.display(action))) + .child( + div() + .type_style(type_scale::label( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK2())) + .child(action.label()), + ) + .child( + div() + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK3())) + // The keys overlay is the full-truth surface + // (FAULT 1): every chord an action answers to, + // not the badge's primary-only compact form. + .child(player.keymap.display(action)), + ) .into_any_element(), KeyRow::Fixed(i) => { let f = &keymap::FIXED[i]; @@ -130,9 +154,24 @@ fn keys_overlay(player: &Player) -> impl IntoElement { .flex() .justify_between() .gap(px(12.)) - .text_size(px(9.5)) - .child(div().text_color(rgb(INK2())).child(f.label)) - .child(div().text_color(rgb(INK3())).child(f.chord.clone())) + .child( + div() + .type_style(type_scale::label( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK2())) + .child(f.label), + ) + .child( + div() + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK3())) + .child(f.chord.clone()), + ) .into_any_element() } })), @@ -278,7 +317,7 @@ fn notice_plate(message: SharedString) -> impl IntoElement { // shape as the legacy notice bar's own tone stripe (`notice_bar`). .border_l(px(3.)) .border_color(rgb(notice_severity(&message))) - .text_size(px(10.)) + .type_style(type_scale::label(10., gpui::FontWeight::MEDIUM)) .text_color(rgb(INK1())) .child(message) } @@ -308,18 +347,49 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement { .gap(px(14.)) .px(px(12.)) .child(section_head("ledger")) - .child(div().text_size(px(9.5)).text_color(rgb(INK1())).child(identity)) + // MOCK-SPEC.md "Ledger": "All mono" -- project identity, last + // action, export progress and position are all what the film/project + // says, not the room's own voice. + .child( + div() + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK1())) + .child(identity), + ) .child( div() .flex_1() .min_w(px(0.)) .truncate() - .text_size(px(9.5)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) .child(last_action), ) - .children(export.map(|e| div().text_size(px(9.5)).text_color(rgb(INK2())).child(e))) - .child(div().flex_none().text_size(px(9.5)).text_color(rgb(INK2())).child(tc)) + .children(export.map(|e| { + div() + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK2())) + .child(e) + })) + .child( + div() + .flex_none() + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK2())) + .child(tc), + ) } /// The dock: the only side panel, right, fixed width, carrying the Src/Clip diff --git a/crates/app/src/ui/timeband_stance.rs b/crates/app/src/ui/timeband_stance.rs index f6d5560..b8a8f3f 100644 --- a/crates/app/src/ui/timeband_stance.rs +++ b/crates/app/src/ui/timeband_stance.rs @@ -8,9 +8,12 @@ //! (MOCK-SPEC.md) reads closer to ~20px. Kept at 13px here -- the binding //! contract's own number, already what `stance.rs::time_band()` shipped -- //! rather than silently picking the mock's, and named here per this task's -//! own instruction to say so when the two disagree. +//! own instruction to say so when the two disagree. Every size in this +//! module now comes from `ui::type_scale` (role, not a bare `px()` literal). use crate::*; +use crate::ui::type_scale::{self, label, mono}; +use gpui::FontWeight; thread_local! { // corner-cut: every other drag surface in this codebase (the bench @@ -30,18 +33,24 @@ thread_local! { /// fires it -- the same shape `stance::ghost` draws for the spine, kept local /// here so this module owns its own region end to end. fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { + let glyph_style = label(type_scale::HERO_TIMECODE_PX, FontWeight::MEDIUM); + // The chord names a key, so DESIGN §3's mono rule ("if a string is about + // ... a key, it is mono") applies here same as everywhere else in the band. + let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); div() .flex_none() .flex() .flex_col() .items_center() .gap(px(1.)) - .text_size(px(13.)) + .font(glyph_style.font) + .text_size(glyph_style.size) .text_color(rgb(INK2())) .child(glyph.to_string()) .child( div() - .text_size(px(9.)) + .font(chord_style.font) + .text_size(chord_style.size) .text_color(rgb(INK3())) .child(player.keymap.display(action)), ) @@ -52,10 +61,12 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { /// rather than painted whole, so the colons can read a shade quieter than /// the numbers either side of them. fn hero_timecode(tc: &str) -> impl IntoElement { + let style = mono(type_scale::HERO_TIMECODE_PX, FontWeight::BOLD); div() .flex_none() .flex() - .text_size(px(13.)) + .font(style.font) + .text_size(style.size) .children(tc.chars().map(|c| { let ink = if c == ':' { INK3() } else { INK1() }; div().text_color(rgb(ink)).child(c.to_string()) @@ -99,6 +110,7 @@ fn cut_readout(player: &Player) -> impl IntoElement { )) }); let roll_on = player.loop_trim.is_some(); + let style = mono(type_scale::CHORD_METADATA_MAX_PX, FontWeight::MEDIUM); div() .id("stance-cut-readout") .flex_none() @@ -108,7 +120,8 @@ fn cut_readout(player: &Player) -> impl IntoElement { .py(px(4.)) .rounded(px(2.)) .bg(rgb(DARK_CANVAS())) - .text_size(px(10.5)) + .font(style.font) + .text_size(style.size) .child(val(odometer)) .when_some(deltas, |el, (in_d, out_d)| { el.child(sep()) @@ -278,16 +291,20 @@ fn contact_strip(player: &Player, cx: &mut Context) -> impl IntoElement /// by [`super::stance::render`] the same way the keys overlay is. fn export_chip(player: &Player, cx: &mut Context) -> impl IntoElement { let exporting = player.exporting().is_some(); + let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); + let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); div() .id("stance-export") .flex_none() + .flex() + .items_center() + .gap(px(6.)) .px(px(10.)) .py(px(6.)) .rounded(px(3.)) .border_1() .border_color(rgb(DARK_HAIRLINE())) .bg(rgb(DARK_RAISED())) - .text_size(px(10.5)) .text_color(rgb(INK1())) .cursor_pointer() .hover(|s| s.bg(rgb(DARK_PANEL()))) @@ -299,11 +316,19 @@ fn export_chip(player: &Player, cx: &mut Context) -> impl IntoElement { } cx.notify(); })) - .child(format!( - "{} {}", - if exporting { "Exporting" } else { "Export" }, - player.keymap.display(ActionId::Export) - )) + .child( + div() + .font(label_style.font) + .text_size(label_style.size) + .child(if exporting { "Exporting" } else { "Export" }), + ) + .child( + div() + .font(chord_style.font) + .text_size(chord_style.size) + .text_color(rgb(INK3())) + .child(player.keymap.display(ActionId::Export)), + ) } /// The whole band, left to right per MOCK-SPEC: hero timecode, ghost @@ -312,8 +337,14 @@ fn export_chip(player: &Player, cx: &mut Context) -> impl IntoElement { pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context) -> impl IntoElement { let tc = timecode(position, player.active_fps()); div() - .id("stance-time-band") - .flex_none() + .id("stance-time-band-row") + // FAULT 1 fix: this div used to be `flex_none`, which sized it to its + // own content inside `stance.rs::time_band()`'s row -- leaving the + // contact strip's `flex_1` nothing to grow into (its "free space" was + // zero, since the parent itself never claimed the band's full width). + // `flex_1` here is what actually lets the strip fill the band. + .flex_1() + .min_w(px(0.)) .h_full() .flex() .items_center() diff --git a/crates/app/src/ui/type_scale.rs b/crates/app/src/ui/type_scale.rs index 8310b50..c399e70 100644 --- a/crates/app/src/ui/type_scale.rs +++ b/crates/app/src/ui/type_scale.rs @@ -27,7 +27,7 @@ // crate's only caller of the public API is `main.rs`'s `register`. #![allow(dead_code)] -use gpui::{App, Font, FontFeatures, FontWeight, Pixels, SharedString, font, px}; +use gpui::{App, Font, FontFeatures, FontWeight, Pixels, SharedString, Styled, font, px}; use std::borrow::Cow; /// Archivo: labels, verbs, section heads. @@ -113,6 +113,18 @@ pub fn head() -> TypeStyle { label(SECTION_HEAD_PX, FontWeight::BOLD) } +/// Applies a [`TypeStyle`] to any styled element in one call -- +/// `div().type_style(mono(9.5, FontWeight::MEDIUM))` instead of the +/// `.font(style.font).text_size(style.size)` pair spelled out at every call +/// site. Blanket-implemented over `Styled` so every element in the room gets +/// it for free. +pub trait Typeset: Styled + Sized { + fn type_style(self, style: TypeStyle) -> Self { + self.font(style.font).text_size(style.size) + } +} +impl Typeset for T {} + /// One face's worth of TTFs to embed, `(bytes, name)` for the doc comment /// above `register` to explain if a load ever fails. const EMBEDDED: &[(&[u8], &str)] = &[