Skip to content

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

PR-1287: refresh against main and resolve review findings

moppeeer9112080c3090
diff --cc ROADMAP.md
index 3cb6d4d0b,0128924c0..efd28a5ab
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -348,7 -348,12 +348,15 @@@ list) · [roadmap.md](docs/roadmap.md)
Newest first.
+- **2026-10-18** · Double-clicking a section triangle in the Pages panel opens that page’s numbering options, including from parent-page editing. No readiness percentage change.
++- **2026-10-14** · The Pages panel labels spreads as ranges or separate names across a section start, marks each section’s first page with a triangle, and scrolls to the page in view (#892). No readiness percentage change.
++
+ - **2026-10-16** · Type › Reload Fonts (`font.reload`): fonts installed, edited or removed while DesignCraft runs are read again without a restart, and the open documents recompose with them (#328, #547). An edited font file is noticed by its length and modification time; bundled, added and document fonts stay as they are. InDesign does this by itself, so noticing changes automatically is still open (gap 6). No readiness percentage change.
+ - **2026-10-16** · Parents can be deleted from their Pages-panel context menu or `layout.parents.delete {id}`. Applied-page and based-on references are cleared, local override copies survive, and Undo restores the parent. Addresses the deletion portion of #956; no readiness percentage change.
+ - **2026-10-17** · File › Package writes the document's and the IDML's links relative to the package (`Links/logo.png`, `file:Links/logo.png`), so a package holds no path from the machine that made it; opening a document resolves them to the files beside it. Links › Copy Link(s) To still links by full path. (#340). No readiness percentage change.
+ - **2026-10-18** · View › Screen Mode: Bleed and Slug do what they say. Both were selectable from the toolbar, the View menu and `view.screenMode` but drew the canvas exactly as Normal did, guides and all; they are preview modes now, and what each page shows reaches the bleed box or the slug box instead of stopping at the trim. The slug guide is drawn as well, in the Slug colour from Preferences › Guides & Pasteboard, which nothing had read. No readiness percentage change.
+ - **2026-10-17** · Object strokes reject malformed types and unknown type fields before changing the document; command help lists every stroke kind and its required fields. No readiness percentage change.
+ - **2026-10-17** · Docs: documented a persistent source CLI install with Cargo, MCP-client PATH setup and bare-name server registration in `docs/mcp.md`. No readiness percentage change.
- **2026-10-16** · Threading: the loaded text cursor threads into a text frame inside a group (it hit the group and showed it could not thread); a plain click still selects the group (#1075). Gap 27 closed. No readiness percentage change.
- **2026-10-16** · Greek text hyphenates. The patterns were never compiled in, so Greek set unhyphenated however narrow the column; `"Greek"`, `"Greek: Greece"`, `el` and `el-GR` all resolve now and ανθρωπος breaks αν-θρω-πος. They are the monotonic patterns (hyph-el-monoton, Dimitrios Filippou, under MIT), which is what polytonic text hyphenates by too. Five of InDesign's ~40 hyphenation languages. No readiness percentage change.
diff --cc crates/ui-egui/src/panels/pages.rs
index 88f04e362,4b2360f8f..778331bff
--- a/crates/ui-egui/src/panels/pages.rs
+++ b/crates/ui-egui/src/panels/pages.rs
@@@ -528,19 -501,33 +539,25 @@@ pub fn show(app: &mut DesignApp, ui: &m
crate::canvas::go_to_page(app, abs);
}
resp.context_menu(|ui| page_menu(app, ui, &doc, abs, si));
- // Page number under the page: white on a blue badge when selected. Pages too
- // narrow for their numbers share one label under the spread (below).
- if narrow {
- continue;
- }
- let name = app.session.page_label(abs);
- let g = ui.painter().layout_no_wrap(name, crate::theme::semibold(11.0), Color32::WHITE);
- let c = egui::pos2(pr.center().x, pr.max.y + 11.0);
- if selected {
- let br = egui::Rect::from_center_size(c, vec2(g.size().x.max(7.0) + 7.0, 12.5));
- ui.painter().rect_filled(br, 0.0, BADGE);
- }
- ui.painter().galley(c - g.size() / 2.0, g, Color32::WHITE);
}
- if narrow {
- let names: Vec<String> = (first..first + sp.pages.len()).map(|abs| app.session.page_label(abs)).collect();
- let label = match (names.first(), names.last()) {
- (Some(a), Some(b)) if names.len() > 1 => format!("{a}\u{2013}{b}"),
- (Some(a), _) => a.clone(),
- _ => String::new(),
- };
- let g = ui.painter().layout_no_wrap(label, crate::theme::semibold(11.0), Color32::WHITE);
- let c = egui::pos2(row.min.x + center, top + row_h + 11.0);
- if cur_spread == Some(si) && !editing_parents {
- ui.painter().rect_filled(egui::Rect::from_center_size(c, vec2(g.size().x + 7.0, 12.5)), 0.0, BADGE);
+ let label = spread_label(app, &doc, first, sp.pages.len());
+ let g = ui.painter().layout_no_wrap(label.clone(), crate::theme::semibold(11.0), Color32::WHITE);
+ let c = egui::pos2(row.min.x + center, top + row_h + 11.0);
+ let br = egui::Rect::from_center_size(c, vec2(g.size().x + 7.0, 12.5));
+ if cur_spread == Some(si) && !editing_parents {
+ ui.painter().rect_filled(br, 0.0, BADGE);
+ }
+ ui.painter().galley(c - g.size() / 2.0, g, Color32::WHITE);
+ let lr = ui.interact(br, ui.id().with(("spread_label", si)), Sense::click());
+ lr.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, &label));
+ if lr.clicked() {
++ if editing_parents {
++ let _ = app.run("layout.parents.edit", json!({"on": false}));
++ if let Some(view) = app.view_mut() {
++ view.fitted = false;
++ }
+ }
- ui.painter().galley(c - g.size() / 2.0, g, Color32::WHITE);
+ crate::canvas::go_to_page(app, first);
}
}
// Right-click on the empty part of the panel: the short menu.
@@@ -1132,101 -1143,3 +1173,112 @@@ mod tests
let _ = h.get_by_label("Edit page size");
}
}
+
+#[cfg(test)]
+mod spread_label_tests {
+ use egui_kittest::{Harness, kittest::Queryable};
+ use serde_json::json;
+
+ use super::*;
+
+ /// Section-marker activation targets its page and leaves parent editing without editing the document.
+ #[test]
+ fn double_clicking_a_section_marker_opens_that_pages_numbering_options() {
+ let mut app = app();
+ app.run("layout.section", json!({"page": 1, "startNumber": 1, "style": "lowerRoman"})).unwrap();
+ app.run("layout.section", json!({"page": 3, "startNumber": 1, "style": "arabic"})).unwrap();
+ app.canvas_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(1000.0, 800.0)));
+ app.run("layout.parents.edit", json!({"on": true})).unwrap();
+ let mut h = Harness::builder().with_size(vec2(280.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
+ |ui, app: &mut DesignApp| {
+ let key = egui::Id::new("section_marker_test_fonts");
+ if ui.data(|d| d.get_temp::<bool>(key)).is_none() {
+ crate::theme::install_fonts(ui.ctx(), "");
+ ui.data_mut(|d| d.insert_temp(key, true));
+ return;
+ }
+ show(app, ui);
+ },
+ app,
+ );
+ h.run_steps(3);
+ let pos = h.get_by_label("Numbering & Section Options: 1").rect().center();
+ let before = h.state().session.doc().unwrap().doc.clone();
+ for _ in 0..2 {
+ for pressed in [true, false] {
+ h.event(egui::Event::PointerMoved(pos));
+ h.event(egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE });
+ h.run_steps(1);
+ }
+ }
+ let dialog = h.state().ui.dialog.as_ref().unwrap();
+ assert_eq!(dialog.id, "numberingSection");
+ assert_eq!(dialog.fields.get("page"), Some(&json!(3)));
+ assert!(!h.state().session.doc().unwrap().editing_parents);
+ assert!(std::sync::Arc::ptr_eq(&h.state().session.doc().unwrap().doc, &before), "opening options does not edit the section");
+ }
+
++ /// Create a facing-page document for section navigation tests.
+ fn app() -> DesignApp {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({"facingPages": true, "pages": 9})).unwrap();
+ app
+ }
+
++ /// Read the label displayed for each document spread.
+ fn labels(app: &DesignApp) -> Vec<String> {
+ let doc = app.session.doc().unwrap().doc.clone();
+ (0..doc.spreads.len()).map(|si| spread_label(app, &doc, doc.first_page_of_spread(si), doc.spreads[si].pages.len())).collect()
+ }
+
++ /// Section boundaries split a spread label instead of implying continuous numbering.
+ #[test]
+ fn spreads_are_labelled_as_indesign_labels_them() {
+ // Chris Nielsen's "Numbering Page Sections": sections starting at 1 on pages 3 and 7,
+ // the second in letters, label their spreads "2, 1" and "6, A".
+ let mut app = app();
+ assert_eq!(labels(&app), ["1", "2–3", "4–5", "6–7", "8–9"]);
+ app.run("layout.section", json!({"page": 3, "startNumber": 1})).unwrap();
+ app.run("layout.section", json!({"page": 7, "startNumber": 1, "style": "upperLetters"})).unwrap();
+ assert_eq!(labels(&app), ["1", "2, 1", "2–3", "4, A", "B–C"]);
+ // Absolute numbering: positions, always a range.
+ app.session.prefs.absolute_page_numbers = true;
+ assert_eq!(labels(&app), ["1", "2–3", "4–5", "6–7", "8–9"]);
+ }
+
++ /// Labels navigate to document spreads, including when parent editing was active.
+ #[test]
+ fn the_panel_shows_spread_labels_and_a_click_on_one_goes_to_its_spread() {
+ let mut app = app();
+ app.run("layout.section", json!({"page": 3, "startNumber": 1})).unwrap();
+ // The canvas the panel's clicks move (not drawn here).
+ app.canvas_rect = Some(egui::Rect::from_min_size(egui::pos2(0.0, 0.0), vec2(1000.0, 800.0)));
+ let mut h = Harness::builder().with_size(vec2(260.0, 900.0)).build_ui_state(
+ |ui, app: &mut DesignApp| {
+ let key = egui::Id::new("test_fonts");
+ if ui.data(|d| d.get_temp::<bool>(key)).is_none() {
+ crate::theme::install_fonts(ui.ctx(), "");
+ ui.data_mut(|d| d.insert_temp(key, true));
+ return;
+ }
+ egui::ScrollArea::vertical().show(ui, |ui| show(app, ui));
+ },
+ app,
+ );
+ h.run_steps(3);
+ let _ = h.get_by_label("2, 1");
+ assert!(h.query_by_label("2 1").is_none());
+ // Each page is named for screen readers: two pages are numbered 1.
+ assert_eq!(h.query_all_by_label("Page 1").count(), 2);
++ h.state_mut().run("layout.parents.edit", json!({"on": true})).unwrap();
++ if let Some(view) = h.state_mut().view_mut() {
++ view.fitted = true;
++ }
++ h.run_steps(3);
+ h.get_by_label("2–3").click();
+ h.run_steps(3);
++ assert!(!h.state().session.doc().unwrap().editing_parents);
++ assert!(!h.state().view().unwrap().fitted);
+ assert_eq!(h.state().session.doc().unwrap().doc.page_loc(crate::canvas::current_page(h.state()).unwrap()).unwrap().0, 2);
+ }
+}