summaryrefslogtreecommitdiff
path: root/library/src/layout
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/layout')
-rw-r--r--library/src/layout/align.rs10
-rw-r--r--library/src/layout/container.rs24
-rw-r--r--library/src/layout/enum.rs4
-rw-r--r--library/src/layout/flow.rs2
-rw-r--r--library/src/layout/grid.rs4
-rw-r--r--library/src/layout/list.rs4
-rw-r--r--library/src/layout/mod.rs2
-rw-r--r--library/src/layout/par.rs2
-rw-r--r--library/src/layout/table.rs4
-rw-r--r--library/src/layout/terms.rs8
10 files changed, 32 insertions, 32 deletions
diff --git a/library/src/layout/align.rs b/library/src/layout/align.rs
index bd9c60fa..e0df0436 100644
--- a/library/src/layout/align.rs
+++ b/library/src/layout/align.rs
@@ -20,11 +20,6 @@ use crate::prelude::*;
styles.set(Self::ALIGNMENT, aligns);
})]
pub struct AlignNode {
- /// The content to align.
- #[positional]
- #[required]
- pub body: Content,
-
/// The alignment along both axes.
///
/// Possible values for horizontal alignments are:
@@ -62,6 +57,11 @@ pub struct AlignNode {
#[skip]
#[default(Axes::new(GenAlign::Start, GenAlign::Specific(Align::Top)))]
pub alignment: Axes<Option<GenAlign>>,
+
+ /// The content to align.
+ #[positional]
+ #[required]
+ pub body: Content,
}
impl Show for AlignNode {
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs
index 67504ca3..8f5d69cc 100644
--- a/library/src/layout/container.rs
+++ b/library/src/layout/container.rs
@@ -26,7 +26,7 @@ pub struct BoxNode {
/// The contents of the box.
#[positional]
#[default]
- pub body: Content,
+ pub body: Option<Content>,
/// The width of the box.
///
@@ -133,16 +133,16 @@ impl Layout for BoxNode {
.unwrap_or(regions.base());
// Apply inset.
- let mut child = self.body();
+ let mut body = self.body().unwrap_or_default();
let inset = styles.get(Self::INSET);
if inset.iter().any(|v| !v.is_zero()) {
- child = child.padded(inset.map(|side| side.map(Length::from)));
+ body = body.padded(inset.map(|side| side.map(Length::from)));
}
// Select the appropriate base and expansion for the child depending
// on whether it is automatically or relatively sized.
let pod = Regions::one(size, expand);
- let mut frame = child.layout(vt, styles, pod)?.into_frame();
+ let mut frame = body.layout(vt, styles, pod)?.into_frame();
// Apply baseline shift.
let shift = styles.get(Self::BASELINE).relative_to(frame.height());
@@ -191,11 +191,11 @@ impl Layout for BoxNode {
/// Blocks are also useful to force elements that would otherwise be inline to
/// become block-level, especially when writing show rules.
/// ```example
-/// #show heading: it => it.title
+/// #show heading: it => it.body
/// = Blockless
/// More text.
///
-/// #show heading: it => block(it.title)
+/// #show heading: it => block(it.body)
/// = Blocky
/// More text.
/// ```
@@ -236,7 +236,7 @@ pub struct BlockNode {
/// The contents of the block.
#[positional]
#[default]
- pub body: Content,
+ pub body: Option<Content>,
/// The block's width.
///
@@ -360,10 +360,10 @@ impl Layout for BlockNode {
regions: Regions,
) -> SourceResult<Fragment> {
// Apply inset.
- let mut child = self.body();
+ let mut body = self.body().unwrap_or_default();
let inset = styles.get(Self::INSET);
if inset.iter().any(|v| !v.is_zero()) {
- child = child.clone().padded(inset.map(|side| side.map(Length::from)));
+ body = body.clone().padded(inset.map(|side| side.map(Length::from)));
}
// Resolve the sizing to a concrete size.
@@ -380,7 +380,7 @@ impl Layout for BlockNode {
// Measure to ensure frames for all regions have the same width.
if sizing.x == Smart::Auto {
let pod = Regions::one(size, Axes::splat(false));
- let frame = child.layout(vt, styles, pod)?.into_frame();
+ let frame = body.layout(vt, styles, pod)?.into_frame();
size.x = frame.width();
expand.x = true;
}
@@ -407,10 +407,10 @@ impl Layout for BlockNode {
pod.last = None;
}
- child.layout(vt, styles, pod)?.into_frames()
+ body.layout(vt, styles, pod)?.into_frames()
} else {
let pod = Regions::one(size, expand);
- child.layout(vt, styles, pod)?.into_frames()
+ body.layout(vt, styles, pod)?.into_frames()
};
// Prepare fill and stroke.
diff --git a/library/src/layout/enum.rs b/library/src/layout/enum.rs
index edc954d0..853a7a67 100644
--- a/library/src/layout/enum.rs
+++ b/library/src/layout/enum.rs
@@ -77,7 +77,7 @@ pub struct EnumNode {
/// ) [+ #phase]
/// ```
#[variadic]
- pub items: Vec<EnumItem>,
+ pub children: Vec<EnumItem>,
/// If this is `{false}`, the items are spaced apart with
/// [enum spacing]($func/enum.spacing). If it is `{true}`, they use normal
@@ -203,7 +203,7 @@ impl Layout for EnumNode {
let mut parents = styles.get(Self::PARENTS);
let full = styles.get(Self::FULL);
- for item in self.items() {
+ for item in self.children() {
number = item.number().unwrap_or(number);
let resolved = if full {
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs
index 02f34857..8554bd98 100644
--- a/library/src/layout/flow.rs
+++ b/library/src/layout/flow.rs
@@ -34,7 +34,7 @@ impl Layout for FlowNode {
if let Some(node) = child.to::<StyledNode>() {
map = node.map();
styles = outer.chain(&map);
- child = node.sub();
+ child = node.body();
}
if let Some(node) = child.to::<VNode>() {
diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs
index d3758fd6..b6465e1c 100644
--- a/library/src/layout/grid.rs
+++ b/library/src/layout/grid.rs
@@ -73,7 +73,7 @@ pub struct GridNode {
///
/// The cells are populated in row-major order.
#[variadic]
- pub cells: Vec<Content>,
+ pub children: Vec<Content>,
/// Defines the column sizes.
///
@@ -114,7 +114,7 @@ impl Layout for GridNode {
regions: Regions,
) -> SourceResult<Fragment> {
// Prepare grid layout by unifying content and gutter tracks.
- let cells = self.cells();
+ let cells = self.children();
let layouter = GridLayouter::new(
vt,
Axes::new(&self.columns().0, &self.rows().0),
diff --git a/library/src/layout/list.rs b/library/src/layout/list.rs
index 69d2e717..5ba6b9b0 100644
--- a/library/src/layout/list.rs
+++ b/library/src/layout/list.rs
@@ -49,7 +49,7 @@ pub struct ListNode {
/// ]
/// ```
#[variadic]
- pub items: Vec<ListItem>,
+ pub children: Vec<ListItem>,
/// If this is `{false}`, the items are spaced apart with [list
/// spacing]($func/list.spacing). If it is `{true}`, they use normal
@@ -141,7 +141,7 @@ impl Layout for ListNode {
let marker = styles.get(Self::MARKER).resolve(vt.world(), depth)?;
let mut cells = vec![];
- for item in self.items() {
+ for item in self.children() {
cells.push(Content::empty());
cells.push(marker.clone());
cells.push(Content::empty());
diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs
index afdfd795..96d16ec8 100644
--- a/library/src/layout/mod.rs
+++ b/library/src/layout/mod.rs
@@ -307,7 +307,7 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> {
) -> SourceResult<()> {
let map = self.scratch.maps.alloc(styled.map());
let stored = self.scratch.styles.alloc(styles);
- let content = self.scratch.content.alloc(styled.sub());
+ let content = self.scratch.content.alloc(styled.body());
let styles = stored.chain(map);
self.interrupt_style(&map, None)?;
self.accept(content, styles)?;
diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs
index a55b2dc3..2564940c 100644
--- a/library/src/layout/par.rs
+++ b/library/src/layout/par.rs
@@ -521,7 +521,7 @@ fn collect<'a>(
let outer = styles;
let mut styles = *styles;
if let Some(node) = child.to::<StyledNode>() {
- child = Box::leak(Box::new(node.sub()));
+ child = Box::leak(Box::new(node.body()));
styles = outer.chain(Box::leak(Box::new(node.map())));
}
diff --git a/library/src/layout/table.rs b/library/src/layout/table.rs
index 33ce9088..0083a7bf 100644
--- a/library/src/layout/table.rs
+++ b/library/src/layout/table.rs
@@ -40,7 +40,7 @@ use crate::prelude::*;
pub struct TableNode {
/// The contents of the table cells.
#[variadic]
- pub cells: Vec<Content>,
+ pub children: Vec<Content>,
/// Defines the column sizes.
/// See the [grid documentation]($func/grid) for more information on track
@@ -135,7 +135,7 @@ impl Layout for TableNode {
let gutter = Axes::new(self.column_gutter().0, self.row_gutter().0);
let cols = tracks.x.len().max(1);
let cells: Vec<_> = self
- .cells()
+ .children()
.into_iter()
.enumerate()
.map(|(i, child)| {
diff --git a/library/src/layout/terms.rs b/library/src/layout/terms.rs
index e8adfdda..2933ea20 100644
--- a/library/src/layout/terms.rs
+++ b/library/src/layout/terms.rs
@@ -36,7 +36,7 @@ pub struct TermsNode {
/// ) [/ #product: Born in #year.]
/// ```
#[variadic]
- pub items: Vec<TermItem>,
+ pub children: Vec<TermItem>,
/// If this is `{false}`, the items are spaced apart with [term list
/// spacing]($func/terms.spacing). If it is `{true}`, they use normal
@@ -101,12 +101,12 @@ impl Layout for TermsNode {
};
let mut cells = vec![];
- for item in self.items() {
+ for child in self.children() {
let body = Content::sequence(vec![
HNode::new((-body_indent).into()).pack(),
- (item.term() + TextNode::packed(':')).strong(),
+ (child.term() + TextNode::packed(':')).strong(),
SpaceNode::new().pack(),
- item.description(),
+ child.description(),
]);
cells.push(Content::empty());