From 599426f0756f018b52f57f92d952c7e5297a2f6b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:14:35 -0800 Subject: [PATCH] New Document: preset cards rest on a tile The app's root look now sets PresetCardLook::PageTile in place of Page, so each preset card in New Document draws on a light veil of the scrim with its paper on it. A card that is not selected now stands apart from the dialog's surface. The craft-libs pin at 186a229c8d already has the look (storytold/craft-libs#4180). The new test resting_preset_cards_stand_on_a_tile checks that a resting card is covered by a veil of the scrim and holds its white paper; it fails with the old Page look. --- crates/ui-egui/src/app.rs | 4 +-- crates/ui-egui/src/dialogs/new_document.rs | 32 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 97fca4f235..fb3c7fafa4 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -809,8 +809,8 @@ pub(crate) fn root_env(prefs: &vectorcraft_engine::Prefs, native_ppp: f32, print root.values.set(TabCloseLook::Glyph); // A collapsed panel column's icon groups stand apart by a hairline, as production drew them. root.values.set(IconGroupSeparator::Rule); - // New Document's preset cards show blank paper on a flat card, as production drew them. - root.values.set(PresetCardLook::Page); + // New Document's preset cards show blank paper on a card that rests on a tile, as production drew them. + root.values.set(PresetCardLook::PageTile); // A bare Tab on the canvas, or with nothing focused, toggles the panels (`window.dock`) instead of moving focus. root.tab_toggles_chrome = true; // Escape in a text field gives up its focus, reverting any typing, so the next keys are the window's. diff --git a/crates/ui-egui/src/dialogs/new_document.rs b/crates/ui-egui/src/dialogs/new_document.rs index efcccd932b..c20582141e 100644 --- a/crates/ui-egui/src/dialogs/new_document.rs +++ b/crates/ui-egui/src/dialogs/new_document.rs @@ -1112,6 +1112,38 @@ mod tests { assert!(inside.is_empty(), "the segments draw icons, not words: {inside:?}"); } + /// Each preset card rests on a tile, a light veil of the scrim over the dialog's surface, with its paper on it, so a + /// card that is not selected still stands apart from the dialog. + #[test] + fn resting_preset_cards_stand_on_a_tile() { + use craft::ui::runtime::env::Env; + use craft::ui::style::rgba_color; + let mut scrim = egui::Color32::TRANSPARENT; + let mut theme = + crate::testing::ui_context().run_ui(Default::default(), |ui| scrim = rgba_color(Env::of(ui).tokens.tokens().color.surface.scrim)); + // The test reads the theme; no renderer applies the frame's textures. + theme.textures_delta.clear(); + let mut app = app(); + open(&mut app); + let out = laid_out(&mut app); + let nodes = out.platform_output.accesskit_update.as_ref().map(|u| u.nodes.clone()).unwrap_or_default(); + let card = nodes + .iter() + .find(|(_, n)| n.role() == egui::accesskit::Role::ListItem && n.label().is_some_and(|l| !l.is_empty()) && n.is_selected() == Some(false)) + .and_then(|(_, n)| n.bounds()) + .map(|b| egui::Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32))) + .expect("a preset card that is not selected"); + let shapes = crate::tests_labels::flat_painted_shapes(&out.shapes); + let rects: Vec<_> = shapes.iter().filter_map(|shape| if let egui::Shape::Rect(rect) = shape { Some(rect) } else { None }).collect(); + let veil = |fill: egui::Color32| fill.a() > 0 && fill.a() < scrim.a() && fill.to_opaque() == scrim.to_opaque(); + assert!( + rects.iter().any(|rect| veil(rect.fill) && rect.rect.contains_rect(card.shrink(1.0)) && card.expand(1.0).contains_rect(rect.rect)), + "a veil of the scrim {scrim:?} covers the resting card {card:?}: {:?}", + rects.iter().filter(|rect| card.expand(1.0).contains_rect(rect.rect)).map(|rect| (rect.rect, rect.fill)).collect::>() + ); + assert!(rects.iter().any(|rect| rect.fill == egui::Color32::WHITE && card.contains_rect(rect.rect)), "the card's paper is on the tile"); + } + /// Recent shows each entry as it was made: a portrait and a landscape A3 are two documents, and /// the built-in cards turn to the picked orientation (#2860). #[test]