diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-26 13:25:14 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-26 13:26:31 +0200 |
| commit | f7c67cde72e6a67f45180856b332bae9863243bd (patch) | |
| tree | 09b1a40e17b2f8aa0c3661ac989a40840cea1f12 /src/library/structure/doc.rs | |
| parent | 09aabc3a21e403e0b09a6d6ba517e34a303b217c (diff) | |
New document & flow building
Diffstat (limited to 'src/library/structure/doc.rs')
| -rw-r--r-- | src/library/structure/doc.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/library/structure/doc.rs b/src/library/structure/doc.rs new file mode 100644 index 00000000..d3fc0b39 --- /dev/null +++ b/src/library/structure/doc.rs @@ -0,0 +1,29 @@ +use crate::library::layout::PageNode; +use crate::library::prelude::*; + +/// A sequence of page runs. +#[derive(Hash)] +pub struct DocNode(pub StyleVec<PageNode>); + +impl DocNode { + /// Layout the document into a sequence of frames, one per page. + pub fn layout( + &self, + ctx: &mut Context, + styles: StyleChain, + ) -> TypResult<Vec<Arc<Frame>>> { + let mut frames = vec![]; + for (page, map) in self.0.iter() { + let number = 1 + frames.len(); + frames.extend(page.layout(ctx, number, map.chain(&styles))?); + } + Ok(frames) + } +} + +impl Debug for DocNode { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + f.write_str("Doc ")?; + self.0.fmt(f) + } +} |
