DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge PR #474
Brandon Thomas742d46446f80
diff --cc crates/doc/src/build.rsindex 2313e72f5,e31dc3c79..9fb075553--- a/crates/doc/src/build.rs+++ b/crates/doc/src/build.rs@@@ -560,30 -549,11 +560,32 @@@ impl Documentlet pi = self.parent_index(page.parent?)?;let ps = &self.parents[pi];// A parent spread can come without pages from a file.- let idx = if ps.pages.len() >= 2 && page.side == PageSide::Left { 0 } else { ps.pages.len().checked_sub(1)? };+ // A single-sided page takes the parent's first page, like a left-hand page.+ let first = ps.pages.len() >= 2 && matches!(page.side, PageSide::Left | PageSide::Single);+ let idx = if first { 0 } else { ps.pages.len().checked_sub(1)? };Some((pi, idx))}++ /// Ruler guides document page `abs` inherits from its applied parent page. They are stored on+ /// the parent page only: positions are moved from the parent page's place in its spread to+ /// this page's place in its own, so they draw and snap where the page is. Editing them+ /// happens on the parent page.+ pub fn inherited_guides(&self, abs: usize) -> Vec<Guide> {+ let (Some(page), Some((pi, qi))) = (self.page(abs), self.parent_page_for(abs)) else { return Vec::new() };+ let Some(parent) = self.parents.get(pi).and_then(|ps| ps.pages.get(qi)) else { return Vec::new() };+ let dx = page.x - parent.x;+ parent+ .guides+ .iter()+ .map(|g| {+ let mut g = g.clone();+ if g.orientation == Orientation::Vertical {+ g.position += dx;+ }+ g+ })+ .collect()+ }}#[cfg(test)]