From 92c01da36016e94ff20163806ddcbcf7e33d4031 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 10 Oct 2020 22:19:36 +0200 Subject: =?UTF-8?q?Switch=20back=20to=20custom=20geometry=20types,=20unifi?= =?UTF-8?q?ed=20with=20layout=20primitives=20=F0=9F=8F=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/nodes/document.rs | 47 -------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 src/layout/nodes/document.rs (limited to 'src/layout/nodes/document.rs') diff --git a/src/layout/nodes/document.rs b/src/layout/nodes/document.rs deleted file mode 100644 index 5c7a2410..00000000 --- a/src/layout/nodes/document.rs +++ /dev/null @@ -1,47 +0,0 @@ -use super::*; - -/// The top-level layouting node. -#[derive(Debug, Clone, PartialEq)] -pub struct Document { - pub runs: Vec, -} - -impl Document { - /// Layout the document. - pub async fn layout(&self, ctx: &mut LayoutContext) -> Vec { - let mut layouts = vec![]; - for run in &self.runs { - layouts.extend(run.layout(ctx).await); - } - layouts - } -} - -/// A variable-length run of pages that all have the same properties. -#[derive(Debug, Clone, PartialEq)] -pub struct Pages { - /// The size of the pages. - pub size: Size, - /// The layout node that produces the actual pages. - pub child: LayoutNode, -} - -impl Pages { - /// Layout the page run. - pub async fn layout(&self, ctx: &mut LayoutContext) -> Vec { - 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 { - LayoutItem::Spacing(_) => None, - LayoutItem::Box(layout, _) => Some(layout), - }) - .collect() - } -} -- cgit v1.2.3