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

+25
View File
@@ -0,0 +1,25 @@
use std::collections::HashMap;
use ely_gpui_component::primitives::Measure;
use gpui::{App, Bounds, Global, IntoElement, ParentElement, Pixels};
/// Window bounds of named demo elements, for scripted capture.
#[derive(Default)]
pub struct Probes(HashMap<&'static str, Bounds<Pixels>>);
impl Global for Probes {}
impl Probes {
pub fn get(key: &str, cx: &App) -> Option<Bounds<Pixels>> {
cx.try_global::<Probes>()
.and_then(|probes| probes.0.get(key).copied())
}
}
/// Wraps `element` so scripts can find it by `key`.
pub fn probe(key: &'static str, element: impl IntoElement) -> Measure {
Measure::new(key, move |bounds, _, cx| {
cx.default_global::<Probes>().0.insert(key, bounds);
})
.child(element)
}