DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge #408: Align panel: add objdistribute-* icons, reuse upstream objalign-*
aionggb4e2e553e54e
diff --cc crates/ui-egui/src/icons.rsindex eac798497,3287ebf15..56a8404bb--- a/crates/ui-egui/src/icons.rs+++ b/crates/ui-egui/src/icons.rs@@@ -925,19 -861,24 +943,40 @@@ mod testsassert_ne!(drawn[1], drawn[2], "Scale and Shear draw alike");}+ /// Whether the arrow icon `name` paints is filled, from the fill of its one path shape.+ fn arrow_filled(name: &str) -> bool {+ let ctx = egui::Context::default();+ let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {+ paint(ui.painter(), Rect::from_min_size(pos2(0.0, 0.0), vec2(20.0, 20.0)), name, Color32::WHITE);+ });+ out.textures_delta.clear();+ out.shapes.iter().any(|s| matches!(&s.shape, Shape::Path(p) if p.fill != Color32::TRANSPARENT))+ }++ #[test]+ fn selection_arrow_is_filled_and_direct_selection_hollow() {+ assert!(arrow_filled("tool-selection"), "Selection draws a hollow arrow");+ assert!(!arrow_filled("tool-direct"), "Direct Selection draws a filled arrow");+ }+++ #[test]+ fn distribute_icons_are_distinct_from_align_and_each_other() {+ // `objalign-*` ship upstream and back the Properties Align row; only the+ // two `objdistribute-*` icons are new here, so they must be real glyphs and+ // must not collide with any `objalign-*` (one glyph per command).+ let distribute = ["objdistribute-h", "objdistribute-v"];+ let align = ["objalign-left", "objalign-hcenter", "objalign-right", "objalign-top", "objalign-vcenter", "objalign-bottom"];+ let unknown = drawing("no-such-icon");+ let d: Vec<String> = distribute.iter().map(|n| drawing(n)).collect();+ for (n, g) in distribute.iter().zip(&d) {+ assert_ne!(*g, unknown, "{n} falls back to the placeholder");+ }+ assert_ne!(d[0], d[1], "objdistribute-h and objdistribute-v draw alike");+ for dn in &d {+ for an in &align {+ let ag = drawing(an);+ assert_ne!(*dn, ag, "distribute icon draws like {an}");+ }+ }+ }}