diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-11 22:38:30 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-11 22:38:30 +0200 |
| commit | d3bc4ec07349a96c3863ddce63c2e52b5e7e9f2f (patch) | |
| tree | 09c582973b58f05f9248d88f0020bf1dda262aa5 /src/layout/document.rs | |
| parent | f04ad0ffa5f34bb7fd97e5c94c7547f96904220c (diff) | |
Refactor layouting base 🪁
Diffstat (limited to 'src/layout/document.rs')
| -rw-r--r-- | src/layout/document.rs | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/layout/document.rs b/src/layout/document.rs index 69ac3d9d..a91dbbe9 100644 --- a/src/layout/document.rs +++ b/src/layout/document.rs @@ -3,6 +3,7 @@ use super::*; /// The top-level layout node. #[derive(Debug, Clone, PartialEq)] pub struct Document { + /// The runs of pages with same properties. pub runs: Vec<Pages>, } @@ -22,26 +23,17 @@ impl Document { pub struct Pages { /// The size of the pages. pub size: Size, - /// The layout node that produces the actual pages. + /// The layout node that produces the actual pages (typically a [stack]). + /// + /// [stack]: struct.Stack.html pub child: LayoutNode, } impl Pages { /// Layout the page run. pub async fn layout(&self, ctx: &mut LayoutContext) -> Vec<BoxLayout> { - let constraints = LayoutConstraints { - spaces: vec![LayoutSpace { base: self.size, size: self.size }], - repeat: true, - }; - - self.child - .layout(ctx, constraints) - .await - .into_iter() - .filter_map(|item| match item { - Layouted::Spacing(_) => None, - Layouted::Box(layout, _) => Some(layout), - }) - .collect() + let areas = Areas::repeat(self.size); + let layouted = self.child.layout(ctx, &areas).await; + layouted.into_iter().filter_map(Layouted::into_boxed).collect() } } |
