DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge PR #1463: Paragraph rules: Type, Gap Color and Tint, Keep In Frame
aiongg19a8a7ae66fa
diff --cc ROADMAP.mdindex bf23c2c09,d0ac914b8..d0bf01ce7--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -455,7 -443,7 +455,8 @@@ Newest first- **2026-10-16** · Lock Guides and Lock Column Guides are commands in View ▸ Grids & Guides (`view.lockGuides`, ⌥⌘;, and `view.lockColumnGuides`), so the control channel and MCP reach them. Lock Column Guides is an undo step, is saved with the document, on in new ones, and read from and written to IDML's `ColumnGuideLocked`, which export always wrote as locked (#1096). No readiness percentage change.- **2026-10-16** · IDML: a page keeps column guides that were dragged off centre (InDesign's Custom columns). They were divided evenly on import, so the gutter sprang back to the middle; the imported positions now place the columns, with the canvas guides, snapping and text placement following them, and they are written back on export. Layout › Margins and Columns re-divides them evenly when the count or gutter changes, as InDesign's does. No readiness percentage change.- **2026-10-16** · IDML: custom column positions are checked before they are used (#1096). A set must give two edges per column, ascending from the left margin to the right one; any other (a wrong count, unsorted or non-numeric values, a list longer than 216 columns allow, or positions left behind by a margin or page-size change) is the even split, in the canvas, on import and on export, instead of columns drawn outside the margins. No readiness percentage change.+- **2026-10-21** · Paragraph Border and Paragraph Shading link their four sides as InDesign's: the stroke weights, offsets and corners have the "Make all settings the same" link, on when the four are the same, so a side typed in sets all four; with the link off a side is set alone (a border with only a thick left side). Found in the Learn Skills Daily course, chapter 40. No readiness percentage change.+ - **2026-10-21** · Paragraph rules have InDesign's Type (solid, thick/thin stripes, dashed, dotted, straight hash, wavy, or a stroke style of the document), Gap Color and Gap Tint, and Keep In Frame (rule above); the Paragraph Rules page is laid out as InDesign's (Weight and Type, Color and Tint, Gap Color and Gap Tint, Width and Offset, Left and Right Indent). IDML reads and writes them (`RuleAboveType`, `RuleBelowGapColor`, `KeepRuleAboveInFrame`…). Found in the Learn Skills Daily course, chapter 20. No readiness percentage change.- **2026-10-21** · Properties › Character and Paragraph: ••• (More Options) expands the section in place, as InDesign's: Character adds vertical and horizontal scale, baseline shift, skew, language and OpenType, and All Caps, Small Caps, Superscript, Subscript, Underline and Strikethrough; Paragraph adds the left, right, first line and last line indents, space before and after, the drop cap's lines and characters, Align to Baseline Grid and Hyphenate. It used to open the Character or Paragraph panel; the language field moved under ••• as in InDesign. Found in the Learn Skills Daily course, chapter 16. No readiness percentage change.- **2026-10-21** · The text Control panel has InDesign's two modes: A (Character Formatting Controls: font and style, size and leading, All Caps/Superscript/Underline and Small Caps/Subscript/Strikethrough, kerning and tracking, vertical and horizontal scale, baseline shift and skew, character style and language) and ¶ (Paragraph Formatting Controls: the nine alignments, left/first line and right/last line indents, space before and after, the drop cap's lines and characters, paragraph style, Hyphenate and Align to Baseline Grid). It used to show a fixed mix of both. Found in the Learn Skills Daily course, chapter 16. No readiness percentage change.- **2026-10-20** · With the Type tool, the Control panel's font size, leading and tracking fields have a spinner and a list of common values, as in InDesign (auto leading in parentheses). No readiness percentage change.diff --cc crates/compose/src/lib.rsindex 6c8bc1206,346ef1241..9c5767dd7--- a/crates/compose/src/lib.rs+++ b/crates/compose/src/lib.rs@@@ -5326,8 -5324,57 +5331,57 @@@ fn hyphenation_pointsout}+ /// A paragraph rule drawn in `rect` (its length and weight) with its Type: the gap colour under+ /// it, then the line, as dashes, dots, stripes, waves or hash marks. A pattern that can't be laid+ /// out along the rule draws solid.+ /// `(color, tint)` is the rule's (Text Color already resolved); `text`, the colour of the text+ /// the rule goes with, for a gap in Text Color.+ fn rule_decos(doc: &Document, r: &designcraft_doc::Rule, rect: Rect, (color, tint): (String, f32), text: &(String, f32)) -> Vec<Deco> {+ use designcraft_doc::StrokeType;+ let kind = doc.stroke_kind(&r.kind);+ let (w, len) = (rect.height(), rect.width());+ let mut out = Vec::new();+ if !matches!(kind, StrokeType::Solid) && r.gap_color != designcraft_color::swatch::NONE && w > 0.0 && len > 0.0 {+ let gap = if r.gap_color == designcraft_doc::TEXT_COLOR { text.0.clone() } else { r.gap_color.clone() };+ out.push(Deco { rect, color: gap, tint: r.gap_tint, ..Deco::default() });+ }+ let y = rect.center().y;+ let mut line = designcraft_geom::BezPath::new();+ line.move_to((rect.x0, y));+ line.line_to((rect.x1, y));+ let path = match &kind {+ StrokeType::Dashed { pattern } if StrokeType::expandable_dashes(pattern, len) => {+ let mut p = designcraft_geom::BezPath::new();+ let (mut x, mut k, mut on) = (rect.x0, 0, true);+ while x < rect.x1 {+ let step = pattern[k % pattern.len()];+ if on && step > 0.0 {+ let r = Rect::new(x, rect.y0, (x + step).min(rect.x1), rect.y1);+ p.extend(designcraft_geom::Shape::path_elements(&r, 0.1));+ }+ x += step;+ k += 1;+ on = !on;+ }+ Some(p)+ }+ StrokeType::Dotted if StrokeType::expandable_dashes(&[w, w], len) => {+ let mut p = designcraft_geom::BezPath::new();+ let mut x = rect.x0 + w / 2.0;+ while x <= rect.x1 - w / 2.0 + 1e-9 {+ p.extend(designcraft_geom::Shape::path_elements(&designcraft_geom::kurbo::Circle::new((x, y), w / 2.0), 0.1));+ x += 2.0 * w;+ }+ Some(p)+ }+ k => k.outline(&line, w, 0.05),+ };+ out.push(Deco { rect, color, tint, path, ..Deco::default() });+ out+ }+/// `spanned`: a paragraph spans the frame's columns, so the lines move together.-fn vertical_justify(ft: &mut FrameText, f: &FrameSpec, spanned: bool) {+fn vertical_justify(ft: &mut FrameText, f: &FrameSpec, spanned: bool, notes: &designcraft_doc::FootnoteOptions) {if ft.lines.is_empty() || f.opts.vertical_justification == VerticalJustification::Top {return;}diff --cc crates/ui-egui/src/dialogs/tests.rsindex 299fc6a66,3f9bbfc10..8884389b1--- a/crates/ui-egui/src/dialogs/tests.rs+++ b/crates/ui-egui/src/dialogs/tests.rs@@@ -3522,78 -3522,87 +3522,163 @@@ fn character_style_options_set_the_digiassert_eq!(char_style(&app, "Emphasis").unwrap().chars.digits, Some(designcraft_doc::Digits::Farsi));}+/// Replace the text of the field beside the `nth` label `label` (on its row, to its right) with+/// `new`, and leave the field.+fn retype_beside(h: &mut egui_kittest::Harness<'static, crate::test_window::Window>, label: &str, nth: usize, new: &str) {+ use egui_kittest::kittest::Queryable;+ let l = h.get_all_by_label(label).nth(nth).unwrap_or_else(|| panic!("no label {label} #{nth}")).rect();+ let field = h+ .get_all_by(|n| n.role() == egui::accesskit::Role::TextInput)+ .map(|n| n.rect())+ .filter(|r| r.center().x > l.max.x && (r.center().y - l.center().y).abs() < l.height().max(8.0))+ .min_by(|a, b| a.min.x.total_cmp(&b.min.x))+ .unwrap_or_else(|| panic!("no field beside {label} #{nth}"))+ .center();+ crate::test_window::click_at(h, field);+ h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A);+ h.event(egui::Event::Text(new.into()));+ h.run_steps(1);+ // Tab leaves the field (Enter would be the dialog's OK).+ h.key_press(egui::Key::Tab);+ h.run_steps(3);+}++/// The course's chapter 40: Paragraph Border's four weights are linked as InDesign's, so a+/// side typed in sets all four; with the link off ("Make all settings the same") a side is set+/// alone, as the lesson gives the border only a thick left side. The corners link the same way.+#[test]+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.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()+ };+ // The four weights start the same, so linked: Top sets them all.+ retype_beside(&mut h, "Top:", 0, "3");+ assert_eq!(field(&h, "borderWeights"), json!([3.0, 3.0, 3.0, 3.0]));+ // Unlinked, Left alone takes 10 pt.+ // The link of the weights (0), corners (1) or offsets (2), where it is now: the dialog+ // scrolls as fields take focus.+ let link = |h: &egui_kittest::Harness<'static, crate::test_window::Window>, n: usize| {+ let links: Vec<egui::Rect> = h.get_all_by_label("Make all settings the same").map(|n| n.rect()).collect();+ assert_eq!(links.len(), 3, "weights, corners and offsets each have a link");+ links[n].center()+ };+ let at = link(&h, 0);+ crate::test_window::click_at(&mut h, at);+ retype_beside(&mut h, "Left:", 0, "10");+ assert_eq!(field(&h, "borderWeights"), json!([3.0, 10.0, 3.0, 3.0]));+ // Linked again, the four take Top's weight; unlinked once more for the thick left side.+ let at = link(&h, 0);+ crate::test_window::click_at(&mut h, at);+ assert_eq!(field(&h, "borderWeights"), json!([3.0, 3.0, 3.0, 3.0]));+ let at = link(&h, 0);+ crate::test_window::click_at(&mut h, at);+ retype_beside(&mut h, "Left:", 0, "10");+ assert_eq!(field(&h, "borderWeights"), json!([3.0, 10.0, 3.0, 3.0]));+ // The corners start the same too: Top Left's size goes to all four.+ retype_beside(&mut h, "Top Left:", 0, "0p4");+ let corners = field(&h, "borderCorners");+ assert!((0..4).all(|i| corners[i]["size"] == json!(4.0)), "{corners}");+ // Unlinked, Top Right alone takes 0p8; linked again, all four take Top Left's 4 pt.+ let at = link(&h, 1);+ crate::test_window::click_at(&mut h, at);+ retype_beside(&mut h, "Top Right:", 0, "0p8");+ assert_eq!(field(&h, "borderCorners")[1]["size"], json!(8.0));+ assert_eq!(field(&h, "borderCorners")[0]["size"], json!(4.0));+ let at = link(&h, 1);+ crate::test_window::click_at(&mut h, at);+ let corners = field(&h, "borderCorners");+ assert!((0..4).all(|i| corners[i] == corners[0] && corners[i]["size"] == json!(4.0)), "{corners}");+ confirm(&mut h.state_mut().app).unwrap();+ let style = h.state().app.session.doc().unwrap().doc.styles.para("Ruled Child").cloned().unwrap();+ assert_eq!(style.para.border_weights, Some([3.0, 10.0, 3.0, 3.0]));+}+++ /// Paragraph Rules › Color offers Text Color above the swatches, so a rule set to a swatch can+ /// go back to it; Gap Color lists only swatches.+ #[test]+ fn the_rule_colour_menu_offers_text_color() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let doc = app.session.doc().unwrap().doc.clone();+ let menu = |ctx: &egui::Context, text: Option<&str>, click: Option<egui::Pos2>| {+ let mut picked = None;+ let mut labels = Vec::new();+ let mut events = Vec::new();+ if let Some(pos) = click {+ events.push(egui::Event::PointerMoved(pos));+ events.push(egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() });+ events.push(egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() });+ }+ let input =+ egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 600.0))), events, ..Default::default() };+ let mut out = ctx.run_ui(input, |ui| {+ picked = swatch_menu_with(ui, &doc, "m", "[Black]", 130.0, text);+ });+ out.textures_delta.clear();+ for s in out.shapes {+ if let egui::Shape::Text(t) = s.shape {+ labels.push((t.galley.job.text.clone(), t.visual_bounding_rect().center()));+ }+ }+ (picked, labels)+ };+ for text in [Some("Text Color"), None] {+ let ctx = egui::Context::default();+ let (_, labels) = menu(&ctx, text, None);+ let combo = labels.iter().find(|(t, _)| t == "[Black]").unwrap().1;+ menu(&ctx, text, Some(combo));+ let (_, labels) = menu(&ctx, text, None);+ let item = labels.iter().find(|(t, _)| t == "Text Color").map(|l| l.1);+ assert_eq!(item.is_some(), text.is_some(), "{labels:?}");+ if let Some(pos) = item {+ let (picked, _) = menu(&ctx, text, Some(pos));+ assert_eq!(picked.as_deref(), Some(designcraft_doc::TEXT_COLOR));+ }+ }+ }++ /// The course's chapter 20: a paragraph style's rule below becomes wavy, 3 pt, with a gap+ /// colour, from Paragraph Rules › Type and Gap Color.+ #[test]+ fn paragraph_style_rules_take_a_type_and_a_gap_colour() {+ let (mut app, _) = ruled_paragraph();+ let ctx = egui::Context::default();+ app.ui.dialog = Some(Dialog::new("paragraphStyleOptions", json!({"name": "Ruled Child", "section": "rules", "rule": "ruleBelow"})));+ draw(&mut app, &ctx);+ if let Some(d) = app.ui.dialog.as_mut() {+ d.fields.insert("p.ruleBelow.type".into(), json!({"kind": "wavy"}));+ d.fields.insert("p.ruleBelow.weight".into(), json!(3.0));+ d.fields.insert("p.ruleBelow.gapColor".into(), json!("[Paper]"));+ }+ draw(&mut app, &ctx);+ confirm(&mut app).unwrap();+ let r = app.session.doc().unwrap().doc.styles.resolve_para_style("Ruled Child").0.rule_below;+ assert_eq!((r.kind, r.weight, r.gap_color.as_str()), (designcraft_doc::StrokeType::Wavy, 3.0, "[Paper]"));+ }++ /// A rule's Gap Tint shows 100% at its default (the rule's JSON leaves a full gap tint out).+ #[test]+ fn a_rules_default_gap_tint_shows_100() {+ use egui_kittest::kittest::Queryable;+ let (mut app, _) = ruled_paragraph();+ app.run(+ "style.paragraph.edit",+ json!({"name": "Ruled Child", "para": {"ruleBelow": {"type": {"kind": "dashed", "pattern": [4.0, 2.0]}, "gapColor": "[Paper]"}}}),+ )+ .unwrap();+ 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": "rules", "rule": "ruleBelow"})));+ h.run_steps(4);+ let label = h.get_by_label("Gap Tint:").rect();+ let field = h+ .get_all_by(|n| n.role() == egui::accesskit::Role::TextInput)+ .filter(|n| n.rect().center().x > label.max.x && (n.rect().center().y - label.center().y).abs() < 8.0)+ .min_by(|a, b| a.rect().min.x.total_cmp(&b.rect().min.x))+ .and_then(|n| n.value());+ assert_eq!(field.as_deref(), Some("100%"));+ }