From f04ad0ffa5f34bb7fd97e5c94c7547f96904220c Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 11 Oct 2020 13:08:27 +0200 Subject: [PATCH] =?UTF-8?q?Rename=20LayoutItem=20to=20Layouted=20=E2=9C=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/document.rs | 4 ++-- src/layout/fixed.rs | 2 +- src/layout/mod.rs | 4 ++-- src/layout/node.rs | 2 +- src/layout/pad.rs | 6 +++--- src/layout/par.rs | 8 ++++---- src/layout/spacing.rs | 8 ++------ src/layout/stack.rs | 10 +++++----- src/layout/text.rs | 4 ++-- 9 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/layout/document.rs b/src/layout/document.rs index c2d7b38bb..69ac3d9de 100644 --- a/src/layout/document.rs +++ b/src/layout/document.rs @@ -39,8 +39,8 @@ impl Pages { .await .into_iter() .filter_map(|item| match item { - LayoutItem::Spacing(_) => None, - LayoutItem::Box(layout, _) => Some(layout), + Layouted::Spacing(_) => None, + Layouted::Box(layout, _) => Some(layout), }) .collect() } diff --git a/src/layout/fixed.rs b/src/layout/fixed.rs index 0d438879b..939473056 100644 --- a/src/layout/fixed.rs +++ b/src/layout/fixed.rs @@ -15,7 +15,7 @@ impl Layout for Fixed { &self, ctx: &mut LayoutContext, constraints: LayoutConstraints, - ) -> Vec { + ) -> Vec { let space = constraints.spaces[0]; let size = Size::new( self.width diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 2368c4416..d5ab24e73 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -55,14 +55,14 @@ pub trait Layout { &self, ctx: &mut LayoutContext, constraints: LayoutConstraints, - ) -> Vec; + ) -> Vec; } /// An item that is produced by [layouting] a node. /// /// [layouting]: trait.Layout.html#method.layout #[derive(Debug, Clone, PartialEq)] -pub enum LayoutItem { +pub enum Layouted { /// Spacing that should be added to the parent. Spacing(Length), /// A box that should be aligned in the parent. diff --git a/src/layout/node.rs b/src/layout/node.rs index 3230621fd..0adbb1457 100644 --- a/src/layout/node.rs +++ b/src/layout/node.rs @@ -40,7 +40,7 @@ impl Layout for LayoutNode { &self, ctx: &mut LayoutContext, constraints: LayoutConstraints, - ) -> Vec { + ) -> Vec { match self { Self::Spacing(spacing) => spacing.layout(ctx, constraints).await, Self::Text(text) => text.layout(ctx, constraints).await, diff --git a/src/layout/pad.rs b/src/layout/pad.rs index 2e1817b7d..e7584dc8c 100644 --- a/src/layout/pad.rs +++ b/src/layout/pad.rs @@ -14,7 +14,7 @@ impl Layout for Pad { &self, ctx: &mut LayoutContext, constraints: LayoutConstraints, - ) -> Vec { + ) -> Vec { self.child .layout(ctx, LayoutConstraints { spaces: constraints @@ -30,7 +30,7 @@ impl Layout for Pad { .await .into_iter() .map(|item| match item { - LayoutItem::Box(boxed, align) => { + Layouted::Box(boxed, align) => { let padding = self.padding.eval(boxed.size); let padded = boxed.size + padding.size(); @@ -38,7 +38,7 @@ impl Layout for Pad { let start = Point::new(padding.left, padding.top); outer.push_layout(start, boxed); - LayoutItem::Box(outer, align) + Layouted::Box(outer, align) } item => item, }) diff --git a/src/layout/par.rs b/src/layout/par.rs index 2a139760a..52086cc9d 100644 --- a/src/layout/par.rs +++ b/src/layout/par.rs @@ -20,7 +20,7 @@ impl Layout for Par { &self, ctx: &mut LayoutContext, constraints: LayoutConstraints, - ) -> Vec { + ) -> Vec { let mut layouter = LineLayouter::new(LineContext { dirs: self.dirs, spaces: constraints.spaces, @@ -39,8 +39,8 @@ impl Layout for Par { for item in items { match item { - LayoutItem::Spacing(amount) => layouter.push_spacing(amount), - LayoutItem::Box(boxed, aligns) => layouter.push_box(boxed, aligns), + Layouted::Spacing(amount) => layouter.push_spacing(amount), + Layouted::Box(boxed, aligns) => layouter.push_box(boxed, aligns), } } } @@ -48,7 +48,7 @@ impl Layout for Par { layouter .finish() .into_iter() - .map(|boxed| LayoutItem::Box(boxed, self.aligns)) + .map(|boxed| Layouted::Box(boxed, self.aligns)) .collect() } } diff --git a/src/layout/spacing.rs b/src/layout/spacing.rs index 9eac1ad55..766ff4d23 100644 --- a/src/layout/spacing.rs +++ b/src/layout/spacing.rs @@ -11,12 +11,8 @@ pub struct Spacing { #[async_trait(?Send)] impl Layout for Spacing { - async fn layout( - &self, - _: &mut LayoutContext, - _: LayoutConstraints, - ) -> Vec { - vec![LayoutItem::Spacing(self.amount)] + async fn layout(&self, _: &mut LayoutContext, _: LayoutConstraints) -> Vec { + vec![Layouted::Spacing(self.amount)] } } diff --git a/src/layout/stack.rs b/src/layout/stack.rs index 6cbe03e3a..47dd93eac 100644 --- a/src/layout/stack.rs +++ b/src/layout/stack.rs @@ -36,7 +36,7 @@ impl Layout for Stack { &self, ctx: &mut LayoutContext, constraints: LayoutConstraints, - ) -> Vec { + ) -> Vec { let mut items = vec![]; let size = constraints.spaces[0].size; @@ -59,8 +59,8 @@ impl Layout for Stack { for item in child.layout(ctx, child_constraints).await { match item { - LayoutItem::Spacing(spacing) => space.push_spacing(spacing), - LayoutItem::Box(mut boxed, aligns) => { + Layouted::Spacing(spacing) => space.push_spacing(spacing), + Layouted::Box(mut boxed, aligns) => { let mut last = false; while let Err(back) = space.push_box(boxed, aligns) { boxed = back; @@ -68,7 +68,7 @@ impl Layout for Stack { break; } - items.push(LayoutItem::Box(space.finish(), self.aligns)); + items.push(Layouted::Box(space.finish(), self.aligns)); if i + 1 < constraints.spaces.len() { i += 1; @@ -84,7 +84,7 @@ impl Layout for Stack { } } - items.push(LayoutItem::Box(space.finish(), self.aligns)); + items.push(Layouted::Box(space.finish(), self.aligns)); items } } diff --git a/src/layout/text.rs b/src/layout/text.rs index 7ba4be210..1c09b40a8 100644 --- a/src/layout/text.rs +++ b/src/layout/text.rs @@ -23,7 +23,7 @@ impl Layout for Text { &self, ctx: &mut LayoutContext, _constraints: LayoutConstraints, - ) -> Vec { + ) -> Vec { let mut loader = ctx.loader.borrow_mut(); let boxed = shaping::shape( &self.text, @@ -34,7 +34,7 @@ impl Layout for Text { self.variant, ) .await; - vec![LayoutItem::Box(boxed, self.aligns)] + vec![Layouted::Box(boxed, self.aligns)] } }