mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 18:25:34 +01:00
Merge pull request #10102 from dotCooCoo/fix/new-document-card-tiles
New Document: preset cards rest on a tile
This commit is contained in:
2 files changed
+34
-2
No files matched your search
@@ -814,8 +814,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.
|
||||
|
||||
@@ -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::<Vec<_>>()
|
||||
);
|
||||
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]
|
||||
|
||||
Reference in new issue
Block a user