T01 primitives: image, divider, backdrop, focus, pressable, measure, tooltip

Ely-built primitives plus gallery demos for every chapter-one entry,
including gpui natives. The gallery now scripts real input by posting
NSEvents to its own queue and shoots each interaction in both modes.
Codex gpt-6-astra (max): three rounds; the last finding, a two-line
doc comment, was fixed after the three-review cap.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-25 00:39:06 -04:00
1 parent abf4cbcfc6
commit a13343c2a5
38 files changed
+2165 -157

No files matched your search

+6
View File
@@ -96,6 +96,8 @@ mixable!(
info_subtle: Hsla,
backdrop: Hsla,
shadow: Hsla,
tooltip_bg: Hsla,
tooltip_fg: Hsla,
chart: [Hsla; 8],
ansi: [Hsla; 16],
syntax: Syntax,
@@ -141,6 +143,8 @@ impl Palette {
info_subtle: c(0xebf4ff),
backdrop: rgba(0x18161352).into(),
shadow: c(0x181613),
tooltip_bg: c(0x181613),
tooltip_fg: c(0xfcfaf7),
chart: c8([
0x5182c1, 0x009589, 0xaa732b, 0xb8636b, 0x8572bb, 0x539156, 0xb66946, 0x138db1,
]),
@@ -203,6 +207,8 @@ impl Palette {
info_subtle: c(0x19273a),
backdrop: rgba(0x00000080).into(),
shadow: c(0x000000),
tooltip_bg: c(0x373533),
tooltip_fg: c(0xf3f1f0),
chart: c8([
0x79a7e2, 0x4eb9ad, 0xcd995c, 0xdc8a90, 0xa998dd, 0x7cb57d, 0xd9906f, 0x56b2d4,
]),
+9 -9
View File
@@ -101,6 +101,15 @@ impl Theme {
px_to_rems(base * self.font_scale)
}
/// Gap between the pointer and a tooltip.
pub fn cursor_offset(&self) -> Rems {
px_to_rems(18.0)
}
pub fn tooltip_max_width(&self) -> Rems {
px_to_rems(256.0)
}
pub fn text_size(&self, size: TextSize) -> Rems {
let base = match size {
TextSize::Xs => 11.0,
@@ -140,15 +149,6 @@ impl Theme {
.map(|&(y, blur, alpha)| shadow(self.colors.shadow.alpha(alpha), y, blur))
.collect()
}
pub fn focus_ring(&self) -> Vec<BoxShadow> {
vec![BoxShadow {
color: self.colors.focus.alpha(0.45),
offset: point(px(0.0), px(0.0)),
blur_radius: px(0.0),
spread_radius: px(2.0),
}]
}
}
fn shadow(color: Hsla, y: f32, blur: f32) -> BoxShadow {