Overview: a settled card repaints its last run

Each card sits in a settling Lazy inside its row: a settled frame of the
Overview runs no card. Lazy::settles notes that a settled reader needs a
binding that stays in place between frames.
This commit is contained in:
aiongg
2026-11-12 14:32:40 +00:00
parent 3a58d2262f
commit b3bd1897a4
3 changed files with 34 additions and 7 deletions
+4
View File
@@ -66,6 +66,10 @@ impl Lazy {
/// - the frame or the one before had input other than pointer motion, the app asked for a repaint, or a given
/// value was edited: the framework cannot see which children show plain app data, so every child runs then;
/// - its last run showed an overlay or painted on another layer.
///
/// A bound value is known by where it lives, so a settled reader needs a binding that stays in place between
/// frames: a value copied into a local each frame and bound there is a new place each frame, and an edit of it
/// does not reach the reader until the next frame with input.
pub fn settles(mut self, settles: bool) -> Lazy {
self.settles = settles;
self
+12 -7
View File
@@ -143,8 +143,9 @@ pub(super) fn on_background(ui: &mut Ui, key: &str, mut add: impl FnMut(&mut Ui,
.show(ui, &mut ());
}
/// The cards in one or two columns, scrolling vertically; each row is as tall as its tallest card. A card out of view
/// does not run (`Lazy`); the card of the component `reveal` names glides to the top of the view. The selected card of
/// The cards in one or two columns, scrolling vertically; each row is as tall as its tallest card. A row out of view
/// does not run (`Lazy`), and a settled card in view repaints its last run (`Lazy::settles`); the card of the component
/// `reveal` names glides to the top of the view. The selected card of
/// `tab` is inspected while the inspector is on. The cards report into `reported`.
pub(super) fn grid(
ui: &mut Ui,
@@ -171,11 +172,15 @@ pub(super) fn grid(
Lazy::new((generation, columns, keys), estimate).reveal(revealed).show(ui, |ui| {
Grid::new(if columns == 1 { ONE } else { TWO }).gap(Gap::CardColumn).fill_width().show(ui, |ui, _| {
for (at, spec) in chunk.iter().enumerate() {
let stories = spec.card_stories();
let mut card = spec.card(&stories, format!("{}-{generation}", spec.key), room);
card.inspect = p.inspect.of(tab, spec.selected);
let events = card.show(ui, p.cells);
reported.push(Reported { spec: row * columns + at, events });
// A settled card repaints its last run; a card that does not run reports nothing, as it took
// no press and ran no command.
Lazy::new((generation, spec.key.as_str()), spec.estimate()).settles(true).show(ui, |ui| {
let stories = spec.card_stories();
let mut card = spec.card(&stories, format!("{}-{generation}", spec.key), room);
card.inspect = p.inspect.of(tab, spec.selected);
let events = card.show(ui, p.cells);
reported.push(Reported { spec: row * columns + at, events });
});
}
});
});
+18
View File
@@ -128,6 +128,24 @@ fn a_settled_form_rows_card_runs_one_pass_per_frame() {
}
}
/// A settled card repaints its last run: a settled frame of the Slider cards runs no Slider and no card chrome, and still
/// shows the Maximum story's value text.
#[trial]
fn a_settled_overview_card_runs_no_component() {
let mut gallery = gallery_filtered("Controls", "Slider");
let mut fixture = Fixture::new(move |ui| gallery.ui(ui));
fixture.room(Vec2::new(1400.0, 900.0)).settle();
for frame in 0..4 {
fixture.idle(1);
let runs = last_pass_runs(fixture.ctx());
// Type names carry their generics: the path before them names the component.
let named = |ty: &str, name: &str| ty.split('<').next().is_some_and(|path| path.ends_with(name));
let card: Vec<_> = runs.iter().filter(|(ty, _)| ["::Slider", "::Panel", "::TitleRow"].iter().any(|name| named(ty, name))).collect();
assert!(card.is_empty(), "settled frame {frame} ran the card: {card:?}");
assert!(painted(&fixture, "100.0"), "settled frame {frame} shows the Maximum story's value text");
}
}
/// The registered type name of the component listed as `name`.
fn type_of(name: &str) -> &'static str {
Catalog::linked().components.iter().find(|component| component.name == name).unwrap_or_else(|| panic!("{name} is listed")).type_name