summaryrefslogtreecommitdiff
path: root/library/src/layout
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/layout')
-rw-r--r--library/src/layout/align.rs6
-rw-r--r--library/src/layout/columns.rs8
-rw-r--r--library/src/layout/container.rs6
-rw-r--r--library/src/layout/pad.rs6
-rw-r--r--library/src/layout/page.rs2
-rw-r--r--library/src/layout/transform.rs12
6 files changed, 20 insertions, 20 deletions
diff --git a/library/src/layout/align.rs b/library/src/layout/align.rs
index d7f571cb..ae60b4c6 100644
--- a/library/src/layout/align.rs
+++ b/library/src/layout/align.rs
@@ -7,7 +7,7 @@ pub struct AlignNode {
/// How to align the content horizontally and vertically.
pub aligns: Axes<Option<GenAlign>>,
/// The content to be aligned.
- pub child: Content,
+ pub body: Content,
}
#[node(Layout)]
@@ -22,7 +22,7 @@ impl AlignNode {
}
}
- Ok(body.aligned(aligns))
+ Ok(Self { aligns, body }.pack())
}
}
@@ -44,7 +44,7 @@ impl Layout for AlignNode {
}
// Layout the child.
- let mut fragment = self.child.layout(vt, styles.chain(&map), pod)?;
+ let mut fragment = self.body.layout(vt, styles.chain(&map), pod)?;
for (region, frame) in regions.iter().zip(&mut fragment) {
// Align in the target size. The target size depends on whether we
// should expand.
diff --git a/library/src/layout/columns.rs b/library/src/layout/columns.rs
index e16302d9..28576fdd 100644
--- a/library/src/layout/columns.rs
+++ b/library/src/layout/columns.rs
@@ -8,7 +8,7 @@ pub struct ColumnsNode {
pub columns: NonZeroUsize,
/// The child to be layouted into the columns. Most likely, this should be a
/// flow or stack node.
- pub child: Content,
+ pub body: Content,
}
#[node(Layout)]
@@ -20,7 +20,7 @@ impl ColumnsNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self {
columns: args.expect("column count")?,
- child: args.expect("body")?,
+ body: args.expect("body")?,
}
.pack())
}
@@ -36,7 +36,7 @@ impl Layout for ColumnsNode {
// Separating the infinite space into infinite columns does not make
// much sense.
if !regions.first.x.is_finite() {
- return self.child.layout(vt, styles, regions);
+ return self.body.layout(vt, styles, regions);
}
// Determine the width of the gutter and each column.
@@ -60,7 +60,7 @@ impl Layout for ColumnsNode {
};
// Layout the children.
- let mut frames = self.child.layout(vt, styles, pod)?.into_iter();
+ let mut frames = self.body.layout(vt, styles, pod)?.into_iter();
let mut finished = vec![];
let dir = styles.get(TextNode::DIR);
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs
index 762a4bd5..0b035273 100644
--- a/library/src/layout/container.rs
+++ b/library/src/layout/container.rs
@@ -7,7 +7,7 @@ pub struct BoxNode {
/// How to size the content horizontally and vertically.
pub sizing: Axes<Option<Rel<Length>>>,
/// The content to be sized.
- pub child: Content,
+ pub body: Content,
}
#[node(Layout, Inline)]
@@ -16,7 +16,7 @@ impl BoxNode {
let width = args.named("width")?;
let height = args.named("height")?;
let body = args.eat::<Content>()?.unwrap_or_default();
- Ok(body.boxed(Axes::new(width, height)))
+ Ok(Self { sizing: Axes::new(width, height), body }.pack())
}
}
@@ -47,7 +47,7 @@ impl Layout for BoxNode {
};
// Layout the child.
- let mut frame = self.child.layout(vt, styles, pod)?.into_frame();
+ let mut frame = self.body.layout(vt, styles, pod)?.into_frame();
// Ensure frame size matches regions size if expansion is on.
let target = regions.expand.select(regions.first, frame.size());
diff --git a/library/src/layout/pad.rs b/library/src/layout/pad.rs
index d7357460..7ae738ac 100644
--- a/library/src/layout/pad.rs
+++ b/library/src/layout/pad.rs
@@ -6,7 +6,7 @@ pub struct PadNode {
/// The amount of padding.
pub padding: Sides<Rel<Length>>,
/// The content whose sides to pad.
- pub child: Content,
+ pub body: Content,
}
#[node(Layout)]
@@ -21,7 +21,7 @@ impl PadNode {
let bottom = args.named("bottom")?.or(y).or(all).unwrap_or_default();
let body = args.expect::<Content>("body")?;
let padding = Sides::new(left, top, right, bottom);
- Ok(body.padded(padding))
+ Ok(Self { padding, body }.pack())
}
}
@@ -37,7 +37,7 @@ impl Layout for PadNode {
// Layout child into padded regions.
let padding = self.padding.resolve(styles);
let pod = regions.map(&mut backlog, |size| shrink(size, padding));
- let mut fragment = self.child.layout(vt, styles, pod)?;
+ let mut fragment = self.body.layout(vt, styles, pod)?;
for frame in &mut fragment {
// Apply the padding inversely such that the grown size padded
diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs
index e9e27e35..8ea1eed6 100644
--- a/library/src/layout/page.rs
+++ b/library/src/layout/page.rs
@@ -84,7 +84,7 @@ impl PageNode {
// Realize columns.
let columns = styles.get(Self::COLUMNS);
if columns.get() > 1 {
- child = ColumnsNode { columns, child: self.0.clone() }.pack();
+ child = ColumnsNode { columns, body: self.0.clone() }.pack();
}
// Realize margins.
diff --git a/library/src/layout/transform.rs b/library/src/layout/transform.rs
index 5ccb5686..8bf465a9 100644
--- a/library/src/layout/transform.rs
+++ b/library/src/layout/transform.rs
@@ -8,7 +8,7 @@ pub struct MoveNode {
/// The offset by which to move the content.
pub delta: Axes<Rel<Length>>,
/// The content that should be moved.
- pub child: Content,
+ pub body: Content,
}
#[node(Layout, Inline)]
@@ -18,7 +18,7 @@ impl MoveNode {
let dy = args.named("dy")?.unwrap_or_default();
Ok(Self {
delta: Axes::new(dx, dy),
- child: args.expect("body")?,
+ body: args.expect("body")?,
}
.pack())
}
@@ -31,7 +31,7 @@ impl Layout for MoveNode {
styles: StyleChain,
regions: Regions,
) -> SourceResult<Fragment> {
- let mut fragment = self.child.layout(vt, styles, regions)?;
+ let mut fragment = self.body.layout(vt, styles, regions)?;
for frame in &mut fragment {
let delta = self.delta.resolve(styles);
let delta = delta.zip(frame.size()).map(|(d, s)| d.relative_to(s));
@@ -49,7 +49,7 @@ pub struct TransformNode<const T: TransformKind> {
/// Transformation to apply to the content.
pub transform: Transform,
/// The content that should be transformed.
- pub child: Content,
+ pub body: Content,
}
/// Rotate content without affecting layout.
@@ -78,7 +78,7 @@ impl<const T: TransformKind> TransformNode<T> {
}
};
- Ok(Self { transform, child: args.expect("body")? }.pack())
+ Ok(Self { transform, body: args.expect("body")? }.pack())
}
}
@@ -89,7 +89,7 @@ impl<const T: TransformKind> Layout for TransformNode<T> {
styles: StyleChain,
regions: Regions,
) -> SourceResult<Fragment> {
- let mut fragment = self.child.layout(vt, styles, regions)?;
+ let mut fragment = self.body.layout(vt, styles, regions)?;
for frame in &mut fragment {
let origin = styles.get(Self::ORIGIN).unwrap_or(Align::CENTER_HORIZON);
let Axes { x, y } = origin.zip(frame.size()).map(|(o, s)| o.position(s));