DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
rustfmt
moppeeeraed32a85058d
diff --git a/crates/ui-egui/src/dialogs/tests.rs b/crates/ui-egui/src/dialogs/tests.rsindex 1cfd51abb..333cdab6a 100644--- a/crates/ui-egui/src/dialogs/tests.rs+++ b/crates/ui-egui/src/dialogs/tests.rs@@ -3551,8 +3551,7 @@ fn paragraph_border_sides_and_corners_link_as_indesigns() {use egui_kittest::kittest::Queryable;let (app, _) = ruled_paragraph();let mut h = crate::test_window::open(app, egui::vec2(1400.0, 900.0));- h.state_mut().app.ui.dialog =- Some(Dialog::new("paragraphStyleOptions", json!({"name": "Ruled Child", "section": "border", "p.borderOn": true})));+ h.state_mut().app.ui.dialog = Some(Dialog::new("paragraphStyleOptions", json!({"name": "Ruled Child", "section": "border", "p.borderOn": true})));h.run_steps(4);let field = |h: &egui_kittest::Harness<'static, crate::test_window::Window>, key: &str| {h.state().app.ui.dialog.as_ref().and_then(|d| d.fields.get(&format!("p.{key}")).cloned()).unwrap_or_default()diff --git a/crates/ui-egui/src/panels/properties/tests.rs b/crates/ui-egui/src/panels/properties/tests.rsindex 7bb88cc2c..5c9feea47 100644--- a/crates/ui-egui/src/panels/properties/tests.rs+++ b/crates/ui-egui/src/panels/properties/tests.rs@@ -710,55 +710,55 @@ fn several_shapes_show_pathfinder_and_intersect_combines_them() {assert!((r.x0 - 200.0).abs() < 0.5 && (r.y1 - 200.0).abs() < 0.5 && (r.x1 - 300.0).abs() < 0.5, "{r:?}");}- /// A row is as wide as its translated name needs: a long one isn't cut at a fixed width.- #[test]- fn preview_rows_fit_long_translated_names() {- let ctx = egui::Context::default();- let long = "Скругленный прямоугольник с обратным углом";- let mut widths = (0.0, 0.0);- let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {- egui::Area::new(egui::Id::new("rows")).show(ui.ctx(), |ui| {- ui.set_max_width(10.0);- let r = preview_row(ui, false, long, 40.0, |_, _, _| {});- let text = ui.fonts_mut(|f| f.layout_no_wrap(long.to_string(), egui::FontId::proportional(12.0), egui::Color32::WHITE).size().x);- widths = (r.rect.width(), 40.0 + 12.0 + text);- });+/// A row is as wide as its translated name needs: a long one isn't cut at a fixed width.+#[test]+fn preview_rows_fit_long_translated_names() {+ let ctx = egui::Context::default();+ let long = "Скругленный прямоугольник с обратным углом";+ let mut widths = (0.0, 0.0);+ let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {+ egui::Area::new(egui::Id::new("rows")).show(ui.ctx(), |ui| {+ ui.set_max_width(10.0);+ let r = preview_row(ui, false, long, 40.0, |_, _, _| {});+ let text = ui.fonts_mut(|f| f.layout_no_wrap(long.to_string(), egui::FontId::proportional(12.0), egui::Color32::WHITE).size().x);+ widths = (r.rect.width(), 40.0 + 12.0 + text);});- out.textures_delta.clear();- assert!(widths.0 >= widths.1, "{widths:?}");- }+ });+ out.textures_delta.clear();+ assert!(widths.0 >= widths.1, "{widths:?}");+}- /// The corner shape list shows each shape's glyph beside its name, as InDesign's; a row picks- /// the shape and the current one is marked.- #[test]- fn the_corner_shape_list_has_glyph_rows_and_picks_a_shape() {- let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());- app.run("file.new", json!({})).unwrap();- let id = app.run("frame.create", json!({"rect": [72, 72, 300, 200], "shape": "rectangle"})).unwrap()["id"].as_u64().unwrap();- app.run("selection.set", json!({"ids": [id]})).unwrap();- let mut h = panel(app);- h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Corner Shape").click();- h.run_steps(3);- let rows = ["None", "Fancy", "Bevel", "Inset", "Inverse Rounded", "Rounded"];- for r in rows {- let _ = h.get_by_role_and_label(egui::accesskit::Role::Button, r);- }- h.get_by_role_and_label(egui::accesskit::Role::Button, "Bevel").click();- h.run_steps(3);- let it = h.state().session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().clone();- assert!(it.corners.corners.iter().all(|c| c.shape == designcraft_geom::corners::CornerShape::Bevel), "{:?}", it.corners);- h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Corner Shape").click();- h.run_steps(3);- use egui_kittest::kittest::NodeT;- let n = h.get_by_role_and_label(egui::accesskit::Role::Button, "Bevel");- assert_eq!(n.accesskit_node().toggled(), Some(egui::accesskit::Toggled::True), "the current shape is marked");- // The stroke type list has the same rows, by name.- h.key_press(egui::Key::Escape);- h.run_steps(2);- h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Stroke Type").click();- h.run_steps(3);- let _ = h.get_by_role_and_label(egui::accesskit::Role::Button, "Thick - Thin");+/// The corner shape list shows each shape's glyph beside its name, as InDesign's; a row picks+/// the shape and the current one is marked.+#[test]+fn the_corner_shape_list_has_glyph_rows_and_picks_a_shape() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let id = app.run("frame.create", json!({"rect": [72, 72, 300, 200], "shape": "rectangle"})).unwrap()["id"].as_u64().unwrap();+ app.run("selection.set", json!({"ids": [id]})).unwrap();+ let mut h = panel(app);+ h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Corner Shape").click();+ h.run_steps(3);+ let rows = ["None", "Fancy", "Bevel", "Inset", "Inverse Rounded", "Rounded"];+ for r in rows {+ let _ = h.get_by_role_and_label(egui::accesskit::Role::Button, r);}+ h.get_by_role_and_label(egui::accesskit::Role::Button, "Bevel").click();+ h.run_steps(3);+ let it = h.state().session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().clone();+ assert!(it.corners.corners.iter().all(|c| c.shape == designcraft_geom::corners::CornerShape::Bevel), "{:?}", it.corners);+ h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Corner Shape").click();+ h.run_steps(3);+ use egui_kittest::kittest::NodeT;+ let n = h.get_by_role_and_label(egui::accesskit::Role::Button, "Bevel");+ assert_eq!(n.accesskit_node().toggled(), Some(egui::accesskit::Toggled::True), "the current shape is marked");+ // The stroke type list has the same rows, by name.+ h.key_press(egui::Key::Escape);+ h.run_steps(2);+ h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Stroke Type").click();+ h.run_steps(3);+ let _ = h.get_by_role_and_label(egui::accesskit::Role::Button, "Thick - Thin");+}const CYAN: &str = "C=100 M=0 Y=0 K=0";