DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
#1620: Restore Properties Back from parent editing
makesomethingshitb6f82deb1160
diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rsindex 5235180e0..d9d40e98a 100644--- a/crates/ui-egui/src/chrome.rs+++ b/crates/ui-egui/src/chrome.rs@@ -1377,6 +1377,15 @@ mod tests {assert_eq!(d.parents[0].pages[0].width, 500.0);assert_eq!(d.spreads, before.spreads);let parents = d.parents.clone();+ if properties {+ let saved = d.clone();+ h.get_by_label("Back").click();+ h.run_steps(3);+ assert!(!h.state().session.doc().unwrap().editing_parents, "Back returns to document properties");+ assert_eq!(h.state().session.tool_id(), "selection");+ assert!(h.query_by_label("Back").is_none(), "the next frame must leave the page properties screen");+ assert!(std::sync::Arc::ptr_eq(&saved, &h.state().session.doc().unwrap().doc));+ }h.state_mut().run("layout.parents.edit", json!({"on": false})).unwrap();h.state_mut().session.set_tool("page");h.state_mut().run("layout.selectPage", json!({"page": 1})).unwrap();@@ -1385,6 +1394,15 @@ mod tests {let d = &h.state().session.doc().unwrap().doc;assert_eq!(d.spreads[0].pages[0].width, 530.0);assert_eq!(d.parents, parents);+ if properties {+ let saved = d.clone();+ h.get_by_label("Back").click();+ h.run_steps(3);+ assert_eq!(h.state().session.tool_id(), "selection");+ assert!(h.query_by_label("Back").is_none());+ assert_eq!(h.state().session.doc().unwrap().selection.page, None);+ assert!(std::sync::Arc::ptr_eq(&saved, &h.state().session.doc().unwrap().doc));+ }}}diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rsindex 6f1c0e02e..779e1e159 100644--- a/crates/ui-egui/src/panels/properties.rs+++ b/crates/ui-egui/src/panels/properties.rs@@ -212,7 +212,7 @@ pub(crate) fn preset_name(w: f64, h: f64) -> &'static str {/// Properties with the Page tool (Properties › Edit Page), as InDesign's: a "Page" band with Back,/// Page Size for this page alone (which page, preset, orientation, W/H), Margins and Columns and-/// Quick Actions. Back returns to the Selection tool and the document's properties.+/// Quick Actions. Back leaves parent editing and returns to the Selection tool and document properties.fn page_sections(app: &mut DesignApp, ui: &mut Ui, spread: designcraft_doc::SpreadRef, page: usize) {let u = units(app);let lang = app.ui.language.clone();@@ -236,6 +236,9 @@ fn page_sections(app: &mut DesignApp, ui: &mut Ui, spread: designcraft_doc::Spre});rule(ui);if back {+ if matches!(spread, designcraft_doc::SpreadRef::Parent(_)) {+ let _ = app.run("layout.parents.edit", json!({"on": false}));+ }let _ = app.run("layout.selectPage", json!({"page": null}));app.select_tool("selection");return;