summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/layout/document.rs4
-rw-r--r--src/layout/fixed.rs2
-rw-r--r--src/layout/mod.rs4
-rw-r--r--src/layout/node.rs2
-rw-r--r--src/layout/pad.rs6
-rw-r--r--src/layout/par.rs8
-rw-r--r--src/layout/spacing.rs8
-rw-r--r--src/layout/stack.rs10
-rw-r--r--src/layout/text.rs4
9 files changed, 22 insertions, 26 deletions
diff --git a/src/layout/document.rs b/src/layout/document.rs
index c2d7b38b..69ac3d9d 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 0d438879..93947305 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<LayoutItem> {
+ ) -> Vec<Layouted> {
let space = constraints.spaces[0];
let size = Size::new(
self.width
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 2368c441..d5ab24e7 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<LayoutItem>;
+ ) -> Vec<Layouted>;
}
/// 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 3230621f..0adbb145 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<LayoutItem> {
+ ) -> Vec<Layouted> {
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 2e1817b7..e7584dc8 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<LayoutItem> {
+ ) -> Vec<Layouted> {
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 2a139760..52086cc9 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<LayoutItem> {
+ ) -> Vec<Layouted> {
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 9eac1ad5..766ff4d2 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<LayoutItem> {
- vec![LayoutItem::Spacing(self.amount)]
+ async fn layout(&self, _: &mut LayoutContext, _: LayoutConstraints) -> Vec<Layouted> {
+ vec![Layouted::Spacing(self.amount)]
}
}
diff --git a/src/layout/stack.rs b/src/layout/stack.rs
index 6cbe03e3..47dd93ea 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<LayoutItem> {
+ ) -> Vec<Layouted> {
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 7ba4be21..1c09b40a 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<LayoutItem> {
+ ) -> Vec<Layouted> {
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)]
}
}