DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Status bar page box names the parent in view and lists the parents
paaspaas0087675f5b0bfe
diff --git a/ROADMAP.md b/ROADMAP.mdindex a7b5105d3..1cead9f02 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -348,6 +348,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.mNewest first.+- **2026-10-21** · While a parent is shown, the status bar's page box and Properties › Page name it ("A-Parent") instead of page 1, as InDesign's; their lists have the parents after the pages, and choosing one shows that parent (a page leaves the parents). Found in the Learn Skills Daily course, chapter 25. 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.diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 8d94f099f..505fd9bce 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -238,6 +238,52 @@ pub fn current_parent_page(app: &DesignApp) -> Option<(usize, usize)> {Some((pi, qi))}+/// The page box's entries (the status bar's, and Properties › Page), as InDesign's: the+/// document's pages by name, then the parents by label ("A-Parent").+pub struct PageBox {+ pub names: Vec<String>,+ /// The entry in view: the parent shown while parents are edited, else the page.+ pub current: usize,+ /// How many of `names` are pages; the parents follow.+ pub pages: usize,+ parents: Vec<designcraft_doc::SpreadId>,+}++impl PageBox {+ /// The name of the entry in view ("3", "A-Parent").+ pub fn current_name(&self) -> &str {+ self.names.get(self.current).map_or("", String::as_str)+ }+}++pub fn page_box(app: &DesignApp) -> Option<PageBox> {+ let st = app.session.active()?;+ let pages = st.doc.page_count();+ let mut names: Vec<String> = (0..pages).map(|i| app.session.page_label(i)).collect();+ names.extend(st.doc.parents.iter().map(|p| p.parent.as_ref().map(|i| i.label()).unwrap_or_default()));+ let current = match current_parent_page(app) {+ Some((pi, _)) => pages + pi,+ None => current_page(app).unwrap_or(0).min(pages.saturating_sub(1)),+ };+ Some(PageBox { names, current, pages, parents: st.doc.parents.iter().map(|p| p.id).collect() })+}++/// Shows entry `i` of `b`: a page (leaving the parents, if they are shown) or a parent.+pub fn page_box_go(app: &mut DesignApp, b: &PageBox, i: usize) {+ if i < b.pages {+ if app.session.active().is_some_and(|st| st.editing_parents) {+ let _ = app.run("layout.parents.edit", json!({"on": false}));+ // The canvas refits to the page's spread once it is centred.+ if let Some(v) = app.view_mut() {+ v.fitted = false;+ }+ }+ go_to_page(app, i);+ } else if let Some(id) = b.parents.get(i - b.pages) {+ let _ = app.run("layout.parents.edit", json!({"parent": id.0}));+ }+}+/// Scroll so absolute page `abs` is centred (keeps zoom).pub fn go_to_page(app: &mut DesignApp, abs: usize) {let Some(st) = app.session.active() else { return };diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rsindex 0df5361f9..d4814c49c 100644--- a/crates/ui-egui/src/chrome.rs+++ b/crates/ui-egui/src/chrome.rs@@ -776,22 +776,45 @@ pub fn status_bar(app: &mut DesignApp, ui: &mut egui::Ui) {if icons::button(ui, "prev", 14.0, false, crate::i18n::tr(&app.ui.language, "Previous Spread")).clicked() {crate::canvas::go_to_page(app, cur.saturating_sub(1));}- let name = app.session.page_label(cur);+ // The page box, as InDesign's: the page in view, or the parent while one is shown+ // ("A-Parent"); its menu lists the pages, then the parents.+ let pb = crate::canvas::page_box(app);+ let name = pb.as_ref().map_or_else(String::new, |b| b.current_name().to_string());let (fr, fresp) = ui.allocate_exact_size(vec2(80.0, 14.0), Sense::click());ui.painter().rect(fr, 0.0, t.input, Stroke::new(1.0, t.field_border), egui::StrokeKind::Inside);- ui.painter().text(fr.left_center() + vec2(5.0, 0.0), egui::Align2::LEFT_CENTER, &name, small.clone(), t.text);+ // A long parent name is cut at the arrow.+ ui.painter().with_clip_rect(egui::Rect::from_min_max(fr.min, egui::pos2(fr.max.x - 14.0, fr.max.y))).text(+ fr.left_center() + vec2(5.0, 0.0),+ egui::Align2::LEFT_CENTER,+ &name,+ small.clone(),+ t.text,+ );ui.painter().text(fr.right_center() - vec2(5.0, 0.0), egui::Align2::RIGHT_CENTER, "▾", small.clone(), t.text);- egui::Popup::menu(&fresp).show(|ui| {- let names: Vec<String> = (0..n).map(|i| app.session.page_label(i)).collect();- egui::ScrollArea::vertical().max_height(300.0).show(ui, |ui| {- for (i, nm) in names.iter().enumerate() {- if ui.button(nm).clicked() {- crate::canvas::go_to_page(app, i);- ui.close();+ fresp.widget_info(|| {+ let mut info = egui::WidgetInfo::labeled(egui::WidgetType::ComboBox, true, "Page");+ info.current_text_value = Some(name.clone());+ info+ });+ let mut picked = None;+ if let Some(b) = &pb {+ egui::Popup::menu(&fresp).show(|ui| {+ egui::ScrollArea::vertical().max_height(300.0).show(ui, |ui| {+ for (i, nm) in b.names.iter().enumerate() {+ if i == b.pages && i > 0 {+ ui.separator();+ }+ if ui.selectable_label(i == b.current, nm).clicked() {+ picked = Some(i);+ ui.close();+ }}- }+ });});- });+ }+ if let (Some(b), Some(i)) = (&pb, picked) {+ crate::canvas::page_box_go(app, b, i);+ }if icons::button(ui, "next", 14.0, false, crate::i18n::tr(&app.ui.language, "Next Spread")).clicked() {crate::canvas::go_to_page(app, (cur + 1).min(n - 1));}@@ -1261,6 +1284,45 @@ mod tests {assert_eq!(h.state().app.ui.open_panel.as_deref(), Some("preflight"));}+ /// The course's chapter 25: while a parent is shown, the status bar's page box names it+ /// ("A-Parent"), as InDesign's. Its menu lists the pages, then the parents: a parent shows+ /// that parent, a page leaves the parents for that page.+ #[test]+ fn the_page_box_names_the_parent_in_view_and_lists_the_parents() {+ use egui::accesskit::Role;+ let mut app = app();+ app.run("file.new", serde_json::json!({"pages": 4, "facingPages": true})).unwrap();+ app.run("layout.parents.new", serde_json::json!({"prefix": "B", "name": "Cover"})).unwrap();+ app.ui.dock_tab = "properties".into();+ let mut h = test_window::open(app, vec2(1200.0, 700.0));+ let shown = |h: &egui_kittest::Harness<'static, test_window::Window>| {+ let b = h.get_by(|n| n.role() == Role::ComboBox && n.label().as_deref() == Some("Page"));+ b.value().unwrap_or_default()+ };+ assert_eq!(shown(&h), "1");+ h.state_mut().app.run("layout.parents.edit", serde_json::json!({"on": true})).unwrap();+ h.run_steps(6);+ assert_eq!(shown(&h), "A-Parent");+ // The menu: a parent.+ h.get_by(|n| n.role() == Role::ComboBox && n.label().as_deref() == Some("Page")).click();+ h.run_steps(3);+ for name in ["1", "2", "3", "4", "A-Parent"] {+ assert!(h.query_by_label(name).is_some(), "{name} is listed");+ }+ h.get_by_label("B-Cover").click();+ h.run_steps(6);+ assert_eq!(shown(&h), "B-Cover");+ assert_eq!(crate::canvas::current_parent_page(&h.state().app).map(|(i, _)| i), Some(1));+ // A page: the parents are left.+ h.get_by(|n| n.role() == Role::ComboBox && n.label().as_deref() == Some("Page")).click();+ h.run_steps(3);+ h.get_by_label("3").click();+ h.run_steps(6);+ assert!(!h.state().app.session.active().unwrap().editing_parents);+ assert_eq!(crate::canvas::current_page(&h.state().app), Some(2));+ assert_eq!(shown(&h), "3");+ }+/// As in InDesign, double-clicking the preflight count (or its light) shows the panel.#[test]fn double_clicking_the_status_bar_error_count_opens_the_preflight_panel() {diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rsindex 44acf6e2c..b700fcddc 100644--- a/crates/ui-egui/src/panels/properties.rs+++ b/crates/ui-egui/src/panels/properties.rs@@ -444,12 +444,13 @@ fn document_sections(app: &mut DesignApp, ui: &mut Ui) {// Page.section(ui, crate::i18n::tr(&app.ui.language, "Page"), true);let b = block(ui, FIELD_H);- let names: Vec<String> = (0..d.page_count()).map(|i| app.session.page_label(i)).collect();- let picked = place(ui, sub(b, 0.0, 0.0, 93.0, FIELD_H), |ui| {- widgets::dropdown_list(ui, &names[cur.min(names.len().saturating_sub(1))], 93.0, &names, Some(cur))- });- if let Some(pg) = picked {- crate::canvas::go_to_page(app, pg);+ // As the status bar's page box: the page, or the parent shown ("A-Parent"); then the parents.+ if let Some(pb) = crate::canvas::page_box(app) {+ let picked =+ place(ui, sub(b, 0.0, 0.0, 93.0, FIELD_H), |ui| widgets::dropdown_list(ui, pb.current_name(), 93.0, &pb.names, Some(pb.current)));+ if let Some(i) = picked {+ crate::canvas::page_box_go(app, &pb, i);+ }}let (add, del) = place(ui, sub(b, 172.0, 0.0, 50.0, FIELD_H), |ui| {ui.spacing_mut().item_spacing.x = 4.0;