Naming consistency

This commit is contained in:
Laurenz 2022-12-08 19:46:06 +01:00
parent e6857f810e
commit 495b525694
11 changed files with 47 additions and 47 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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());

View File

@ -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

View File

@ -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.

View File

@ -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));

View File

@ -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>);

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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)]