summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-08 19:46:06 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-08 19:46:06 +0100
commit495b525694aa5901385f3acad043b4a9f3ebb911 (patch)
tree36be972fb666b61309b7538335de1a7313c46c8f
parente6857f810e8868d95ebe78753568016b6dea12ca (diff)
Naming consistency
-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
-rw-r--r--library/src/math/matrix.rs4
-rw-r--r--library/src/math/mod.rs22
-rw-r--r--library/src/math/style.rs16
-rw-r--r--library/src/shared/ext.rs8
-rw-r--r--library/src/visualize/line.rs4
11 files changed, 47 insertions, 47 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));
diff --git a/library/src/math/matrix.rs b/library/src/math/matrix.rs
index d835b348..bc5e542a 100644
--- a/library/src/math/matrix.rs
+++ b/library/src/math/matrix.rs
@@ -1,6 +1,6 @@
use super::*;
-/// A column vector in a mathematical formula.
+/// A column vector.
#[derive(Debug, Hash)]
pub struct VecNode(Vec<Content>);
@@ -60,7 +60,7 @@ castable! {
},
}
-/// A case distinction in a mathematical formula.
+/// A case distinction.
#[derive(Debug, Hash)]
pub struct CasesNode(Vec<Content>);
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 83cc62aa..1139296c 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -17,10 +17,10 @@ use crate::text::{FontFamily, LinebreakNode, SpaceNode, SymbolNode, TextNode};
/// A piece of a mathematical formula.
#[derive(Debug, Clone, Hash)]
pub struct MathNode {
- /// The pieces of the formula.
- pub children: Vec<Content>,
/// Whether the formula is display-level.
pub display: bool,
+ /// The pieces of the formula.
+ pub children: Vec<Content>,
}
#[node(Show, Layout, Inline, Texify)]
@@ -350,7 +350,7 @@ impl Texify for AccNode {
}
}
-/// A fraction in a mathematical formula.
+/// A fraction.
#[derive(Debug, Hash)]
pub struct FracNode {
/// The numerator.
@@ -379,7 +379,7 @@ impl Texify for FracNode {
}
}
-/// A binomial in a mathematical formula.
+/// A binomial.
#[derive(Debug, Hash)]
pub struct BinomNode {
/// The upper index.
@@ -408,7 +408,7 @@ impl Texify for BinomNode {
}
}
-/// A sub- and/or superscript in a mathematical formula.
+/// A sub- and/or superscript.
#[derive(Debug, Hash)]
pub struct ScriptNode {
/// The base.
@@ -455,9 +455,9 @@ impl Texify for AlignNode {
}
}
-/// A square root in a mathematical formula.
+/// A square root.
#[derive(Debug, Hash)]
-pub struct SqrtNode(Content);
+pub struct SqrtNode(pub Content);
#[node(Texify)]
impl SqrtNode {
@@ -475,9 +475,9 @@ impl Texify for SqrtNode {
}
}
-/// A floored expression in a mathematical formula.
+/// A floored expression.
#[derive(Debug, Hash)]
-pub struct FloorNode(Content);
+pub struct FloorNode(pub Content);
#[node(Texify)]
impl FloorNode {
@@ -495,9 +495,9 @@ impl Texify for FloorNode {
}
}
-/// A ceiled expression in a mathematical formula.
+/// A ceiled expression.
#[derive(Debug, Hash)]
-pub struct CeilNode(Content);
+pub struct CeilNode(pub Content);
#[node(Texify)]
impl CeilNode {
diff --git a/library/src/math/style.rs b/library/src/math/style.rs
index 3db2e631..9e81a549 100644
--- a/library/src/math/style.rs
+++ b/library/src/math/style.rs
@@ -2,7 +2,7 @@ use super::*;
/// Serif (roman) font style.
#[derive(Debug, Hash)]
-pub struct SerifNode(Content);
+pub struct SerifNode(pub Content);
#[node(Texify)]
impl SerifNode {
@@ -22,7 +22,7 @@ impl Texify for SerifNode {
/// Sans-serif font style.
#[derive(Debug, Hash)]
-pub struct SansNode(Content);
+pub struct SansNode(pub Content);
#[node(Texify)]
impl SansNode {
@@ -42,7 +42,7 @@ impl Texify for SansNode {
/// Bold font style.
#[derive(Debug, Hash)]
-pub struct BoldNode(Content);
+pub struct BoldNode(pub Content);
#[node(Texify)]
impl BoldNode {
@@ -62,7 +62,7 @@ impl Texify for BoldNode {
/// Italic font style.
#[derive(Debug, Hash)]
-pub struct ItalNode(Content);
+pub struct ItalNode(pub Content);
#[node(Texify)]
impl ItalNode {
@@ -82,7 +82,7 @@ impl Texify for ItalNode {
/// Calligraphic font style.
#[derive(Debug, Hash)]
-pub struct CalNode(Content);
+pub struct CalNode(pub Content);
#[node(Texify)]
impl CalNode {
@@ -102,7 +102,7 @@ impl Texify for CalNode {
/// Fraktur font style.
#[derive(Debug, Hash)]
-pub struct FrakNode(Content);
+pub struct FrakNode(pub Content);
#[node(Texify)]
impl FrakNode {
@@ -122,7 +122,7 @@ impl Texify for FrakNode {
/// Monospace font style.
#[derive(Debug, Hash)]
-pub struct MonoNode(Content);
+pub struct MonoNode(pub Content);
#[node(Texify)]
impl MonoNode {
@@ -142,7 +142,7 @@ impl Texify for MonoNode {
/// Blackboard bold (double-struck) font style.
#[derive(Debug, Hash)]
-pub struct BbNode(Content);
+pub struct BbNode(pub Content);
#[node(Texify)]
impl BbNode {
diff --git a/library/src/shared/ext.rs b/library/src/shared/ext.rs
index 3c20c90f..811ae757 100644
--- a/library/src/shared/ext.rs
+++ b/library/src/shared/ext.rs
@@ -53,19 +53,19 @@ impl ContentExt for Content {
}
fn boxed(self, sizing: Axes<Option<Rel<Length>>>) -> Self {
- crate::layout::BoxNode { sizing, child: self }.pack()
+ crate::layout::BoxNode { sizing, body: self }.pack()
}
fn aligned(self, aligns: Axes<Option<GenAlign>>) -> Self {
- crate::layout::AlignNode { aligns, child: self }.pack()
+ crate::layout::AlignNode { aligns, body: self }.pack()
}
fn padded(self, padding: Sides<Rel<Length>>) -> Self {
- crate::layout::PadNode { padding, child: self }.pack()
+ crate::layout::PadNode { padding, body: self }.pack()
}
fn moved(self, delta: Axes<Rel<Length>>) -> Self {
- crate::layout::MoveNode { delta, child: self }.pack()
+ crate::layout::MoveNode { delta, body: self }.pack()
}
fn filled(self, fill: Paint) -> Self {
diff --git a/library/src/visualize/line.rs b/library/src/visualize/line.rs
index 0875fafc..ef6ce2c3 100644
--- a/library/src/visualize/line.rs
+++ b/library/src/visualize/line.rs
@@ -4,9 +4,9 @@ use crate::prelude::*;
#[derive(Debug, Hash)]
pub struct LineNode {
/// Where the line starts.
- origin: Axes<Rel<Length>>,
+ pub origin: Axes<Rel<Length>>,
/// The offset from the `origin` where the line ends.
- delta: Axes<Rel<Length>>,
+ pub delta: Axes<Rel<Length>>,
}
#[node(Layout, Inline)]