From 495b525694aa5901385f3acad043b4a9f3ebb911 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 8 Dec 2022 19:46:06 +0100 Subject: [PATCH] Naming consistency --- library/src/layout/align.rs | 6 +++--- library/src/layout/columns.rs | 8 ++++---- library/src/layout/container.rs | 6 +++--- library/src/layout/pad.rs | 6 +++--- library/src/layout/page.rs | 2 +- library/src/layout/transform.rs | 12 ++++++------ library/src/math/matrix.rs | 4 ++-- library/src/math/mod.rs | 22 +++++++++++----------- library/src/math/style.rs | 16 ++++++++-------- library/src/shared/ext.rs | 8 ++++---- library/src/visualize/line.rs | 4 ++-- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/library/src/layout/align.rs b/library/src/layout/align.rs index d7f571cbd..ae60b4c6a 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>, /// 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 e16302d95..28576fdd9 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 { 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 762a4bd55..0b0352732 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>>, /// 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::()?.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 d73574609..7ae738ac1 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>, /// 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::("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 e9e27e354..8ea1eed61 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 5ccb5686c..8bf465a9b 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>, /// 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 { - 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 { /// 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 TransformNode { } }; - Ok(Self { transform, child: args.expect("body")? }.pack()) + Ok(Self { transform, body: args.expect("body")? }.pack()) } } @@ -89,7 +89,7 @@ impl Layout for TransformNode { styles: StyleChain, regions: Regions, ) -> SourceResult { - 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 d835b3485..bc5e542a5 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); @@ -60,7 +60,7 @@ castable! { }, } -/// A case distinction in a mathematical formula. +/// A case distinction. #[derive(Debug, Hash)] pub struct CasesNode(Vec); diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs index 83cc62aa7..1139296cf 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, /// Whether the formula is display-level. pub display: bool, + /// The pieces of the formula. + pub children: Vec, } #[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 3db2e631b..9e81a549f 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 3c20c90f5..811ae7573 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>>) -> Self { - crate::layout::BoxNode { sizing, child: self }.pack() + crate::layout::BoxNode { sizing, body: self }.pack() } fn aligned(self, aligns: Axes>) -> Self { - crate::layout::AlignNode { aligns, child: self }.pack() + crate::layout::AlignNode { aligns, body: self }.pack() } fn padded(self, padding: Sides>) -> Self { - crate::layout::PadNode { padding, child: self }.pack() + crate::layout::PadNode { padding, body: self }.pack() } fn moved(self, delta: Axes>) -> 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 0875fafcb..ef6ce2c39 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>, + pub origin: Axes>, /// The offset from the `origin` where the line ends. - delta: Axes>, + pub delta: Axes>, } #[node(Layout, Inline)]