From 989d170dc7318ca3cbaa5b76760eb14f4e6a8605 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 28 Nov 2022 12:40:16 +0100 Subject: Fragments --- library/src/structure/document.rs | 3 ++- library/src/structure/list.rs | 10 +++++----- library/src/structure/table.rs | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'library/src/structure') diff --git a/library/src/structure/document.rs b/library/src/structure/document.rs index 2e5761e0..e52c92ad 100644 --- a/library/src/structure/document.rs +++ b/library/src/structure/document.rs @@ -26,7 +26,8 @@ impl LayoutRoot for DocumentNode { let mut pages = vec![]; for (page, map) in self.0.iter() { let number = 1 + pages.len(); - pages.extend(page.layout(world, number, styles.chain(map))?); + let fragment = page.layout(world, number, styles.chain(map))?; + pages.extend(fragment); } Ok(Document { diff --git a/library/src/structure/list.rs b/library/src/structure/list.rs index 6bfddd2e..b51284a8 100644 --- a/library/src/structure/list.rs +++ b/library/src/structure/list.rs @@ -18,7 +18,7 @@ pub type EnumNode = ListNode; /// A description list. pub type DescNode = ListNode; -#[node(LayoutBlock)] +#[node(Layout)] impl ListNode { /// How the list is labelled. #[property(referenced)] @@ -75,13 +75,13 @@ impl ListNode { } } -impl LayoutBlock for ListNode { - fn layout_block( +impl Layout for ListNode { + fn layout( &self, world: Tracked, styles: StyleChain, regions: &Regions, - ) -> SourceResult> { + ) -> SourceResult { let mut cells = vec![]; let mut number = 1; @@ -137,7 +137,7 @@ impl LayoutBlock for ListNode { gutter: Axes::with_y(vec![gutter.into()]), cells, } - .layout_block(world, styles, regions) + .layout(world, styles, regions) } } diff --git a/library/src/structure/table.rs b/library/src/structure/table.rs index 4dd14cdd..bb900f3d 100644 --- a/library/src/structure/table.rs +++ b/library/src/structure/table.rs @@ -12,7 +12,7 @@ pub struct TableNode { pub cells: Vec, } -#[node(LayoutBlock)] +#[node(Layout)] impl TableNode { /// How to fill the cells. #[property(referenced)] @@ -50,13 +50,13 @@ impl TableNode { } } -impl LayoutBlock for TableNode { - fn layout_block( +impl Layout for TableNode { + fn layout( &self, world: Tracked, styles: StyleChain, regions: &Regions, - ) -> SourceResult> { + ) -> SourceResult { let fill = styles.get(Self::FILL); let stroke = styles.get(Self::STROKE).map(PartialStroke::unwrap_or_default); let padding = styles.get(Self::PADDING); @@ -89,7 +89,7 @@ impl LayoutBlock for TableNode { gutter: self.gutter.clone(), cells, } - .layout_block(world, styles, regions) + .layout(world, styles, regions) } } -- cgit v1.2.3