Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Merge #575: Effects panel: the level row, Isolate Blending and Knockout Group

aiongg1f69461ff539
diff --cc ROADMAP.md
index 175a78328,269454de7..ffba7dc3c
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -128,55 -129,12 +128,56 @@@ list) · [roadmap.md](docs/roadmap.md)
Newest first.
+ - **2026-10-12** · The Effects panel shows the level its settings apply to ("Group: Color Dodge 100%") and, as in InDesign, Isolate Blending and Knockout Group for a selected group. No readiness percentage change.
+- **2026-10-12** · Edit › Step and Repeat has its InDesign dialog: Repeat (Count, or Rows and Columns with Create as a grid), Offset (Vertical, Horizontal, in ruler units) and Preview, which shows the copies while the dialog is open; Cancel takes them away and OK makes them as one undo step. No readiness percentage change.
+- **2026-10-12** · Load Styles: the Paragraph Styles and Character Styles panels load styles from another DesignCraft document or an IDML file, with the styles, swatches and lists they name; a dialog picks the styles and what happens to one the document defines differently (`style.load`). No readiness percentage change.
+- **2026-10-12** · On screen, blend modes blend with the objects below and not with the paper, as in InDesign and in PDF export: a Color Dodge or Screen object over blank paper shows as it is. No readiness percentage change.
+- **2026-10-12** · Text threads by hand: click a selected text frame's in or out port to load
+ the text cursor, then click a frame to thread it, click empty space for a column-wide frame or
+ drag one (it snaps like frame drawing); Shift-click autoflows, Alt-click stays loaded on the
+ frame just added; click the linked frame or double-click a port to break the thread.
+ `text.thread`, `text.unthread`, `text.removeFromThread` with undo; locked frames and layers
+ refuse threads. The alpha gate now waits only on the Primary Text Frame page fixes (#165). No
+ readiness percentage change.
+- **2026-10-12** · Properties › Transform shows rotation, shear and X/Y scale, and Rotate 90° and Flip Horizontal/Vertical buttons, as InDesign's does. No readiness percentage change.
+- **2026-10-12** · Underlines and strikethroughs are drawn as one bar per stretch of text on screen, as in PDF export: a bar per letter left faint seams between the letters. No readiness percentage change.
+- **2026-10-12** · The section marker character shows its section's marker text on document pages (nothing when the section has none) instead of the word "Section", which stays on parent pages; editing the marker recomposes (#556). No readiness percentage change.
+- **2026-10-12** · IDML import keeps a font family name exactly as written, trailing spaces included, and font lookup falls back to the name without surrounding spaces; `FontStyle="Nothing"` leaves the style to the paragraph (#558). No readiness percentage change.
+- **2026-10-12** · Clipping paths saved with images in IDML (Detect Edges, Alpha Channel, Photoshop Path, User-Modified Path, inverted or not) clip the image on screen and in PDF and survive IDML export; `object.clippingPathOptions` reports, inverts or removes one (#450). No readiness percentage change.
+- **2026-10-12** · Anchored objects with text wrap push text aside: other stories' text under them and the lines of their own story after the anchor's line (#557). No readiness percentage change.
- **2026-10-12** · Words in capitals hyphenate like capitalized words (FERRUM COM-MODI), as in InDesign; Hyphenate Capitalized Words off keeps them whole. No readiness percentage change.
+- **2026-10-12** · Load Swatches refuses an `.ase` file with more than 100,000 colors, and `swatch.load` merges a file of 100,000 colors in under 0.1 s (it took 9.6 s of CPU in a test build). No readiness percentage change.
+- **2026-10-11 (printing):** `file.printers` and `file.print` use craft-libs/craft-print for CUPS and Windows. DesignCraft retains PDF export, page selection, spreads, marks and bleed; dry runs create no temporary PDF or print job. Windows selects matching or default driver paper and shrinks oversized sheets without enlarging smaller ones; queue duplex defaults are preserved. Headless tests exercise exported bytes, job settings, dry runs and refusals; shared native Windows CI passes, including paused-queue submission and cleanup. PostScript, production print controls and physical output validation remain open. No readiness percentage change.
+- **2026-10-11** · The View menu follows InDesign's: proofing first, then zoom, Rotate Spread, Screen Mode, Display Performance, rulers, Extras, Grids & Guides and Structure; the view items that sat at the end of the Type menu moved there. No readiness percentage change.
+- **2026-10-11** · Properties › Appearance's Fill and Stroke menus gain InDesign's Tint field and, for a text frame, Apply To: Frame / Text. No readiness percentage change.
+- **2026-10-11** · `story.replaceRange`, `story.setText`, notes, footnotes, endnotes, type on a path and table cells read `\r` and `\r\n` as paragraph returns, as `frame.create` and `text.insert` already did. No readiness percentage change.
+- **2026-10-11** · Corner Options keep curved sides curved and round every corner point, including where an arc meets a line (a Pathfinder quarter circle with rounded corners stayed a triangle). No readiness percentage change.
+- **2026-10-11:** Type › Justification… (Cmd+Alt+Shift+J, also in the Paragraph panel menu) sets word and letter spacing, glyph scaling and the composer on the selected paragraphs, sharing the Paragraph Style Options section (#531). No readiness percentage change.
+- **2026-10-11** · Properties gains InDesign's Pathfinder section (Add, Subtract, Intersect, Exclude Overlap, Minus Back) with several objects selected; section titles and icon buttons have accessible names. No readiness percentage change.
- **2026-10-11** · `transform.move {copy}`, Edit › Duplicate and Step and Repeat return the copies' ids, so a script can go on with them. No readiness percentage change.
- **2026-10-11** · `object.fill` and `object.stroke` refuse a swatch name the document doesn't have (it painted nothing) and suggest the name meant (`Paper` → `[Paper]`). No readiness percentage change.
-- **2026-10-11 (printing):** `file.printers` and `file.print` use craft-libs/craft-print for CUPS and Windows. DesignCraft retains PDF export, page selection, spreads, marks and bleed; dry runs create no temporary PDF or print job. Windows selects matching or default driver paper and shrinks oversized sheets without enlarging smaller ones; queue duplex defaults are preserved. Headless tests exercise exported bytes, job settings, dry runs and refusals; shared native Windows CI passes, including paused-queue submission and cleanup. PostScript, production print controls and physical output validation remain open. No readiness percentage change.
-
+- **2026-10-11** · Japanese captions now cover print ranges, imported style handling and table
+ row/column movement, including row-height distribution. Existing translation and RTL helpers
+ handle the display; command IDs, stored option values and user-defined style names are unchanged.
+- **2026-10-11** · Moving a sheared and rotated text frame no longer leaves trails of text behind: canvas repaints cover the frame's whole text box, not just its outline. No readiness percentage change.
+- **2026-10-11** · Live corners: the yellow widget on a selected rectangle frame shows corner
+ diamonds; dragging one rounds the corners, Alt-click steps the corner shape (#186).
+- **2026-10-11** · Optical kerning (#181): pairs are spaced from their outlines (ink gap per band,
+ pulled towards the font's stem gap, bounded) instead of silently using the font's kern pairs.
+- **2026-10-11** · New Document laid out like InDesign's (#325): Recent, Saved, Print, Web and
+ Mobile preset tabs beside the preset's details; saved document presets live in the engine
+ (`file.savePreset`, `file.deletePreset`, `file.new {preset}`); `file.new` takes intent, units,
+ start page and per-edge bleed and slug.
+- **2026-10-11** · macOS: fonts that font services and managers activate (Adobe Fonts,
+ RightFont) are listed, read from the files CoreText has available (#261, #327).
+- **2026-10-11:** Document pages take their parent page's margins and columns (left or right parent page by side) and follow its changes unless they have their own; parent ruler guides draw and snap on the pages based on it. IDML import marks a page margin preference that differs from its parent as the page's own. No readiness percentage change.
+- **2026-10-11** · Document Setup laid out like InDesign's: Page Size, Margins (new: every
+ page's, `layout.documentSetup {margins}`), Bleed and Slug with links, Adjust Layout.
+- **2026-10-11** · IDML reads and writes a spread's view rotation (Rotate Spread) as the
+ rotation part of the spread transform (#484).
+- **2026-10-11** · The document grid is drawn (View ▸ Grids & Guides ▸ Show/Hide Document Grid,
+ ⌘'), on the lines Snap to Document Grid uses, behind or in front of page items (#530).
+- **2026-10-12** · Double-clicking the Fill or Stroke box in the Tools panel opens the Color Picker with the selection's colour, as in InDesign (it opened the Swatches panel). No readiness percentage change.
- **2026-10-10 (UI.4–UI.5):** Panel tabs can move into other groups, split the dock, float, resize and return to their saved locations through shared docking transactions. Layouts persist in custom workspaces; UI and control commands share the same validated action path. Shared pane geometry and widget-state theme application retain all five palettes and local fonts. Split panes send keyboard input only to the focused canvas and scope contextual toolbar IDs per pane. No readiness percentage change.
- **2026-10-10** · Version 0.6.0; releases add a Linux riscv64 tar.gz (cross-compiled, CLI
smoke-tested under QEMU).
diff --cc crates/ui-egui/src/i18n.rs
index e46bb9d33,49893ab77..4fea84763
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@@ -1092,14 -738,10 +1092,18 @@@ const TABLE: &[(&str, [&str; 5])] = &
),
("Apply Cell Style", ["Apply Cell Style", "Apply Cell Style", "Apply Cell Style", "Apply Cell Style", "应用单元格样式"]),
("Apply Color", ["Apply Color", "Apply Color", "Apply Color", "Apply Color", "应用颜色"]),
+ ("Repeat", ["Wiederholen", "Répéter", "Repetir", "繰り返し", "重复"]),
+ ("Count:", ["Anzahl:", "Nombre :", "Recuento:", "繰り返し数:", "计数:"]),
+ ("Create as a grid", ["Als Raster erstellen", "Créer en tant que grille", "Crear como cuadrícula", "グリッドとして作成", "创建为网格"]),
+ ("Rows:", ["Zeilen:", "Rangées :", "Filas:", "行:", "行:"]),
+ ("Columns:", ["Spalten:", "Colonnes :", "Columnas:", "列:", "列:"]),
+ ("Vertical:", ["Vertikal:", "Vertical :", "Vertical:", "垂直方向:", "垂直:"]),
+ ("Horizontal:", ["Horizontal:", "Horizontal :", "Horizontal:", "水平方向:", "水平:"]),
+ ("Invalid value", ["Ungültiger Wert", "Valeur non valide", "Valor no válido", "無効な値", "无效值"]),
+ ("Isolate Blending", ["Füllmethode isolieren", "Isoler le mode de fusion", "Aislar fusión", "描画モードを分離", "分离混合"]),
+ ("Knockout Group", ["Aussparungsgruppe", "Groupe de masquage", "Grupo de exclusión", "グループの抜き", "挖空组"]),
+ ("Object:", ["Objekt:", "Objet :", "Objeto:", "オブジェクト:", "对象:"]),
+ ("Group:", ["Gruppe:", "Groupe :", "Grupo:", "グループ:", "编组:"]),
("Apply Condition", ["Apply Condition", "Apply Condition", "Apply Condition", "Apply Condition", "应用条件"]),
(
"Apply Parent to Pages…",
diff --cc crates/ui-egui/src/i18n/ar.rs
index 7202f2d33,99b19cd43..5962b7250
--- a/crates/ui-egui/src/i18n/ar.rs
+++ b/crates/ui-egui/src/i18n/ar.rs
@@@ -1060,14 -1040,10 +1060,18 @@@ pub(super) const TABLE: &[(&str, &str)
("Formatting affects container (J)", "تطبيق التنسيق على الحاوية (J)"),
("Formatting affects text (J)", "تطبيق التنسيق على النص (J)"),
("Apply Color", "تطبيق اللون"),
+ ("Repeat", "تكرار"),
+ ("Count:", "العدد:"),
+ ("Create as a grid", "إنشاء كشبكة"),
+ ("Rows:", "الصفوف:"),
+ ("Columns:", "الأعمدة:"),
+ ("Vertical:", "رأسي:"),
+ ("Horizontal:", "أفقي:"),
+ ("Invalid value", "قيمة غير صالحة"),
+ ("Isolate Blending", "عزل المزج"),
+ ("Knockout Group", "مجموعة مفرغة"),
+ ("Object:", "الكائن:"),
+ ("Group:", "المجموعة:"),
("Apply None", "إزالة اللون"),
("Height Only", "الارتفاع فقط"),
("Width Only", "العرض فقط"),
diff --cc crates/ui-egui/src/i18n/it.rs
index 741085c36,aa13a5bad..abbe1cdfb
--- a/crates/ui-egui/src/i18n/it.rs
+++ b/crates/ui-egui/src/i18n/it.rs
@@@ -414,14 -411,10 +414,18 @@@ pub(super) const TABLE: &[(&str, &str)
("Apply Attributes (Eyedropper)", "Applica attributi (Contagocce)"),
("Apply Cell Style", "Applica stile di cella"),
("Apply Color", "Applica colore"),
+ ("Repeat", "Ripeti"),
+ ("Count:", "Conteggio:"),
+ ("Create as a grid", "Crea come griglia"),
+ ("Rows:", "Righe:"),
+ ("Columns:", "Colonne:"),
+ ("Vertical:", "Verticale:"),
+ ("Horizontal:", "Orizzontale:"),
+ ("Invalid value", "Valore non valido"),
+ ("Isolate Blending", "Isola fusione"),
+ ("Knockout Group", "Gruppo di foratura"),
+ ("Object:", "Oggetto:"),
+ ("Group:", "Gruppo:"),
("Apply Condition", "Applica condizione"),
("Apply Parent to Pages…", "Applica pagina mastro alle pagine…"),
("ArtCraft App Page…", "Pagina dell'app ArtCraft…"),
diff --cc crates/ui-egui/src/i18n/ja.rs
index a5829b83c,4c44fe56e..01dfb0986
--- a/crates/ui-egui/src/i18n/ja.rs
+++ b/crates/ui-egui/src/i18n/ja.rs
@@@ -532,11 -413,10 +532,15 @@@ pub(super) const TABLE: &[(&str, &str)
("Apply Attributes (Eyedropper)", "属性を適用 (スポイト)"),
("Apply Cell Style", "セルスタイルを適用"),
("Apply Color", "カラーを適用"),
+ ("Repeat", "繰り返し"),
+ ("Count:", "繰り返し数:"),
+ ("Create as a grid", "グリッドとして作成"),
+ ("Rows:", "行:"),
+ ("Invalid value", "無効な値"),
+ ("Isolate Blending", "描画モードを分離"),
+ ("Knockout Group", "グループの抜き"),
+ ("Object:", "オブジェクト:"),
+ ("Group:", "グループ:"),
("Apply Condition", "条件を適用"),
("Apply Parent to Pages…", "ページに親ページを適用…"),
("ArtCraft App Page…", "ArtCraft アプリページ…"),
diff --cc crates/ui-egui/src/i18n/pt_br.rs
index 3590fea81,cfba0c05b..eca9d10ee
--- a/crates/ui-egui/src/i18n/pt_br.rs
+++ b/crates/ui-egui/src/i18n/pt_br.rs
@@@ -1057,14 -1044,10 +1057,18 @@@ pub(super) const TABLE: &[(&str, &str)
("Formatting affects container (J)", "Formatação afeta o contêiner (J)"),
("Formatting affects text (J)", "Formatação afeta o texto (J)"),
("Apply Color", "Aplicar cor"),
+ ("Repeat", "Repetir"),
+ ("Count:", "Contagem:"),
+ ("Create as a grid", "Criar como grade"),
+ ("Rows:", "Linhas:"),
+ ("Columns:", "Colunas:"),
+ ("Vertical:", "Vertical:"),
+ ("Horizontal:", "Horizontal:"),
+ ("Invalid value", "Valor inválido"),
+ ("Isolate Blending", "Isolar mesclagem"),
+ ("Knockout Group", "Grupo de vazamento"),
+ ("Object:", "Objeto:"),
+ ("Group:", "Grupo:"),
("Apply None", "Aplicar nenhum"),
("Height Only", "Somente altura"),
("Width Only", "Somente largura"),
diff --cc crates/ui-egui/src/i18n/uk.rs
index 59d210001,21623b9cb..93d648077
--- a/crates/ui-egui/src/i18n/uk.rs
+++ b/crates/ui-egui/src/i18n/uk.rs
@@@ -415,14 -414,10 +415,18 @@@ pub(super) const TABLE: &[(&str, &str)
("Apply Attributes (Eyedropper)", "Застосувати атрибути (піпетка)"),
("Apply Cell Style", "Застосувати стиль клітинки"),
("Apply Color", "Застосувати колір"),
+ ("Repeat", "Повторення"),
+ ("Count:", "Кількість:"),
+ ("Create as a grid", "Створити як сітку"),
+ ("Rows:", "Рядки:"),
+ ("Columns:", "Стовпці:"),
+ ("Vertical:", "Вертикально:"),
+ ("Horizontal:", "Горизонтально:"),
+ ("Invalid value", "Неприпустиме значення"),
+ ("Isolate Blending", "Ізолювати змішування"),
+ ("Knockout Group", "Група вибивання"),
+ ("Object:", "Об’єкт:"),
+ ("Group:", "Група:"),
("Apply Condition", "Застосувати умову"),
("Apply Parent to Pages…", "Застосувати шаблон до сторінок…"),
("ArtCraft App Page…", "Сторінка програми ArtCraft…"),
diff --cc crates/ui-egui/src/panels/properties.rs
index 44794eb52,695bb149a..07dcc9c5f
--- a/crates/ui-egui/src/panels/properties.rs
+++ b/crates/ui-egui/src/panels/properties.rs
@@@ -2467,151 -2228,69 +2488,216 @@@ mod tests
let after = h.state().session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().fill.swatch.clone();
assert_eq!(after, name, "clicking the swatch chip applies it");
}
+
+ fn panel(app: DesignApp) -> Harness<'static, DesignApp> {
+ let mut h = Harness::builder().with_size(vec2(320.0, 1400.0)).build_ui_state(
+ |ui, app: &mut DesignApp| {
+ let id = egui::Id::new("test_fonts");
+ if ui.data(|d| d.get_temp::<bool>(id)).is_none() {
+ crate::theme::install_fonts(ui.ctx(), "");
+ ui.data_mut(|d| d.insert_temp(id, true));
+ return;
+ }
+ show(app, ui);
+ },
+ app,
+ );
+ h.run_steps(3);
+ h
+ }
+
+ #[test]
+ fn several_shapes_show_pathfinder_and_intersect_combines_them() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ let a = app.run("frame.create", json!({"rect": [100, 100, 300, 300], "shape": "ellipse"})).unwrap()["id"].clone();
+ let b = app.run("frame.create", json!({"rect": [200, 100, 300, 200]})).unwrap()["id"].clone();
+ // One shape: no Pathfinder section.
+ app.run("selection.set", json!({"ids": [a]})).unwrap();
+ let mut h = panel(app);
+ assert!(h.query_by_label("Pathfinder").is_none());
+ // Two: the section and its five buttons; Intersect leaves one shape, the ellipse's quarter.
+ h.state_mut().run("selection.set", json!({"ids": [a, b]})).unwrap();
+ h.run_steps(3);
+ assert!(h.query_by_label("Pathfinder").is_some());
+ for op in ["Add", "Subtract", "Intersect", "Exclude Overlap", "Minus Back"] {
+ assert!(h.query_by_label(op).is_some(), "{op}");
+ }
+ h.get_by_label("Intersect").click();
+ h.run_steps(3);
+ let doc = &h.state().session.active().unwrap().doc;
+ let items = &doc.spreads[0].items;
+ assert_eq!(items.len(), 1, "one shape left");
+ let r = items[0].bounds();
+ assert!((r.x0 - 200.0).abs() < 0.5 && (r.y1 - 200.0).abs() < 0.5 && (r.x1 - 300.0).abs() < 0.5, "{r:?}");
+ }
+
+ const CYAN: &str = "C=100 M=0 Y=0 K=0";
+
+ #[test]
+ fn the_fill_menu_sets_a_tint() {
+ 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]})).unwrap()["id"].as_u64().unwrap();
+ app.run("object.fill", json!({"swatch": CYAN, "ids": [id]})).unwrap();
+ app.run("selection.set", json!({"ids": [id]})).unwrap();
+ let mut h = panel(app);
+ h.get_by_label("Fill swatch").click();
+ h.run_steps(3);
+ // A frame that isn't a text frame: no Apply To.
+ assert!(h.query_by_label("Apply To:").is_none());
+ // The field on the Tint row (Opacity also reads 100%).
+ let row = h.get_by_label("Tint:").rect();
+ h.query_all_by(|n| n.role() == egui::accesskit::Role::TextInput && n.value().as_deref() == Some("100%"))
+ .find(|n| (n.rect().center().y - row.center().y).abs() < 8.0)
+ .expect("the Tint field")
+ .click();
+ h.run_steps(2);
+ h.event(egui::Event::Key { key: egui::Key::A, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::COMMAND });
+ h.event(egui::Event::Text("25".into()));
+ h.key_press(egui::Key::Enter);
+ h.run_steps(3);
+ let fill = h.state().session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().fill.clone();
+ assert_eq!((fill.swatch.as_str(), fill.tint), (CYAN, 0.25), "the tint, on the same swatch");
+ }
+
+ #[test]
+ fn a_tint_on_several_objects_keeps_each_ones_swatch() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ let a = app.run("frame.create", json!({"rect": [72, 72, 200, 200]})).unwrap()["id"].as_u64().unwrap();
+ let b = app.run("frame.create", json!({"rect": [220, 72, 300, 200]})).unwrap()["id"].as_u64().unwrap();
+ app.run("object.fill", json!({"swatch": CYAN, "ids": [a]})).unwrap();
+ app.run("object.fill", json!({"swatch": "[Black]", "ids": [b]})).unwrap();
+ app.run("selection.set", json!({"ids": [a, b]})).unwrap();
+ let mut h = panel(app);
+ h.get_by_label("Fill swatch").click();
+ h.run_steps(3);
+ let row = h.get_by_label("Tint:").rect();
+ h.query_all_by(|n| n.role() == egui::accesskit::Role::TextInput && n.value().as_deref() == Some("100%"))
+ .find(|n| (n.rect().center().y - row.center().y).abs() < 8.0)
+ .expect("the Tint field")
+ .click();
+ h.run_steps(2);
+ h.event(egui::Event::Key { key: egui::Key::A, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::COMMAND });
+ h.event(egui::Event::Text("25".into()));
+ h.key_press(egui::Key::Enter);
+ h.run_steps(3);
+ let doc = &h.state().session.active().unwrap().doc;
+ let fill = |id: u64| doc.item(designcraft_doc::ids::ItemId(id)).unwrap().fill.clone();
+ assert_eq!((fill(a).swatch.as_str(), fill(a).tint), (CYAN, 0.25));
+ assert_eq!((fill(b).swatch.as_str(), fill(b).tint), ("[Black]", 0.25), "the second keeps its own swatch");
+ }
+
+ #[test]
+ fn apply_to_text_colours_a_text_frames_text_not_the_frame() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ let r = app.run("frame.create", json!({"rect": [72, 72, 300, 200], "content": "text", "text": "Heading"})).unwrap();
+ let (id, story) = (r["id"].as_u64().unwrap(), designcraft_doc::StoryId(r["story"].as_u64().unwrap()));
+ app.run("selection.set", json!({"ids": [id]})).unwrap();
+ let mut h = panel(app);
+ h.get_by_label("Fill swatch").click();
+ h.run_steps(3);
+ h.get_by_label("Text").click();
+ h.run_steps(3);
+ h.get_by_label(CYAN).click();
+ h.run_steps(3);
+ let doc = &h.state().session.active().unwrap().doc;
+ assert_eq!(doc.story(story).unwrap().char_format_at(0).over.fill.as_deref(), Some(CYAN), "the text is cyan");
+ assert_eq!(doc.item(designcraft_doc::ids::ItemId(id)).unwrap().fill.swatch, "[None]", "the frame isn't");
+ }
+
+ #[test]
+ fn transform_flips_and_rotates_from_properties() {
+ 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]})).unwrap()["id"].as_u64().unwrap();
+ app.run("selection.set", json!({"ids": [id]})).unwrap();
+ let mut h = panel(app);
+ let xf = |h: &Harness<'_, DesignApp>| h.state().session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().xf;
+ // Flip Horizontal mirrors the frame (a negative determinant); Flip Vertical as well brings it
+ // back to a half turn, as in the tutorial's petal.
+ h.get_by_label("Flip Horizontal").click();
+ h.run_steps(3);
+ assert!(xf(&h).determinant() < 0.0, "{:?}", xf(&h));
+ h.get_by_label("Flip Vertical").click();
+ h.run_steps(3);
+ let c = xf(&h).as_coeffs();
+ assert!((c[0] + 1.0).abs() < 1e-9 && (c[3] + 1.0).abs() < 1e-9, "a half turn: {c:?}");
+ let info = h.state_mut().session.execute("transform.info", &json!({})).unwrap();
+ assert!((info["rotation"].as_f64().unwrap().abs() - 180.0).abs() < 1e-6, "{info}");
+ // A quarter turn clockwise from there.
+ h.get_by_label("Rotate 90° Clockwise").click();
+ h.run_steps(3);
+ let info = h.state_mut().session.execute("transform.info", &json!({})).unwrap();
+ assert!((info["rotation"].as_f64().unwrap() - 90.0).abs() < 1e-6, "{info}");
+ // The angle and scale fields are there.
+ assert!(h.query_by(|n| n.role() == egui::accesskit::Role::TextInput && n.value().as_deref() == Some("90°")).is_some());
+ }
}
+
+ #[cfg(test)]
+ mod effects_panel_tests {
+ use super::*;
+
+ /// One frame of the Effects panel: the text painted and where.
+ fn frame(app: &mut DesignApp, ctx: &egui::Context, events: Vec<egui::Event>) -> Vec<(String, egui::Rect)> {
+ let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(320.0, 400.0));
+ let time = ctx.input(|i| i.time) + 1.0 / 60.0;
+ let mut out =
+ ctx.run_ui(egui::RawInput { screen_rect: Some(screen), time: Some(time), events, ..Default::default() }, |ui| effects_panel(app, ui));
+ out.textures_delta.clear();
+ let mut v = Vec::new();
+ for s in out.shapes {
+ if let egui::Shape::Text(t) = s.shape {
+ v.push((t.galley.job.text.clone(), t.visual_bounding_rect()));
+ }
+ }
+ v
+ }
+
+ fn click(app: &mut DesignApp, ctx: &egui::Context, label: &str) {
+ let labels = frame(app, ctx, vec![]);
+ let pos = labels.iter().find(|(t, _)| t == label).unwrap_or_else(|| panic!("{label} is painted")).1.center();
+ for pressed in [true, false] {
+ frame(
+ app,
+ ctx,
+ vec![
+ egui::Event::PointerMoved(pos),
+ egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE },
+ ],
+ );
+ }
+ }
+
+ #[test]
+ fn the_effects_panel_shows_the_level_and_isolate_blending_and_knockout_group_for_groups() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), Default::default());
+ app.run("file.new", json!({})).unwrap();
+ let a = app.run("frame.create", json!({"rect": [72, 72, 144, 144]})).unwrap()["id"].as_u64().unwrap();
+ let b = app.run("frame.create", json!({"rect": [100, 100, 200, 200]})).unwrap()["id"].as_u64().unwrap();
+ let g = app.run("object.group", json!({"ids": [a, b]})).unwrap()["id"].as_u64().unwrap();
+ app.run("selection.set", json!({"ids": [g]})).unwrap();
+ app.run("object.opacity", json!({"opacity": 1.0, "blend": "colorDodge"})).unwrap();
+ let ctx = egui::Context::default();
+ crate::theme::install_fonts(&ctx, "en");
+ crate::theme::apply(&ctx, &Tokens::for_brightness(crate::theme::Brightness::default()));
+ let texts: Vec<String> = frame(&mut app, &ctx, vec![]).into_iter().map(|(t, _)| t).collect();
+ for expected in ["Group:", "Color Dodge 100%", "Isolate Blending", "Knockout Group"] {
+ assert!(texts.iter().any(|t| t == expected), "{expected} in {texts:?}");
+ }
+ let item = |app: &DesignApp, id: u64| app.session.doc().unwrap().doc.item(designcraft_doc::ItemId(id)).cloned().unwrap();
+ click(&mut app, &ctx, "Isolate Blending");
+ assert!(item(&app, g).isolate);
+ click(&mut app, &ctx, "Knockout Group");
+ assert!(item(&app, g).knockout);
+ // Another object: the level is Object, and the group options are greyed.
+ app.run("selection.set", json!({"ids": [a]})).unwrap();
+ let texts: Vec<String> = frame(&mut app, &ctx, vec![]).into_iter().map(|(t, _)| t).collect();
+ assert!(texts.iter().any(|t| t == "Object:"), "{texts:?}");
+ click(&mut app, &ctx, "Knockout Group");
+ assert!(!item(&app, a).knockout);
+ }
+ }