diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-03-11 12:59:55 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-03-11 23:36:06 +0100 |
| commit | 5ac7eb3860ebd3247f6486c227e816894cb8fd91 (patch) | |
| tree | a29a868c681c7de39f15f2d9d3f031db1861b90a /src/library/layout | |
| parent | 5ce2a006b6d45d29be15e4562ae3ab4fc1b8e97c (diff) | |
Rename template to content
Diffstat (limited to 'src/library/layout')
| -rw-r--r-- | src/library/layout/align.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/columns.rs | 8 | ||||
| -rw-r--r-- | src/library/layout/container.rs | 8 | ||||
| -rw-r--r-- | src/library/layout/grid.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/pad.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/page.rs | 28 | ||||
| -rw-r--r-- | src/library/layout/place.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/spacing.rs | 8 | ||||
| -rw-r--r-- | src/library/layout/stack.rs | 8 |
9 files changed, 38 insertions, 38 deletions
diff --git a/src/library/layout/align.rs b/src/library/layout/align.rs index 7fbe0d01..2a969524 100644 --- a/src/library/layout/align.rs +++ b/src/library/layout/align.rs @@ -12,10 +12,10 @@ pub struct AlignNode { #[class] impl AlignNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { let aligns: Spec<_> = args.find()?.unwrap_or_default(); let body: LayoutNode = args.expect("body")?; - Ok(Template::block(body.aligned(aligns))) + Ok(Content::block(body.aligned(aligns))) } } diff --git a/src/library/layout/columns.rs b/src/library/layout/columns.rs index 167e7068..9e461108 100644 --- a/src/library/layout/columns.rs +++ b/src/library/layout/columns.rs @@ -16,8 +16,8 @@ impl ColumnsNode { /// The size of the gutter space between each column. pub const GUTTER: Linear = Relative::new(0.04).into(); - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::block(Self { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::block(Self { columns: args.expect("column count")?, child: args.expect("body")?, })) @@ -105,7 +105,7 @@ pub struct ColbreakNode; #[class] impl ColbreakNode { - fn construct(_: &mut Context, _: &mut Args) -> TypResult<Template> { - Ok(Template::Colbreak) + fn construct(_: &mut Context, _: &mut Args) -> TypResult<Content> { + Ok(Content::Colbreak) } } diff --git a/src/library/layout/container.rs b/src/library/layout/container.rs index 55579878..f7f4017c 100644 --- a/src/library/layout/container.rs +++ b/src/library/layout/container.rs @@ -5,11 +5,11 @@ pub struct BoxNode; #[class] impl BoxNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { let width = args.named("width")?; let height = args.named("height")?; let body: LayoutNode = args.find()?.unwrap_or_default(); - Ok(Template::inline(body.sized(Spec::new(width, height)))) + Ok(Content::inline(body.sized(Spec::new(width, height)))) } } @@ -18,7 +18,7 @@ pub struct BlockNode; #[class] impl BlockNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::Block(args.find()?.unwrap_or_default())) + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::Block(args.find()?.unwrap_or_default())) } } diff --git a/src/library/layout/grid.rs b/src/library/layout/grid.rs index 63cd83b1..90cf6da3 100644 --- a/src/library/layout/grid.rs +++ b/src/library/layout/grid.rs @@ -13,13 +13,13 @@ pub struct GridNode { #[class] impl GridNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { let columns = args.named("columns")?.unwrap_or_default(); let rows = args.named("rows")?.unwrap_or_default(); let base_gutter: Vec<TrackSizing> = args.named("gutter")?.unwrap_or_default(); let column_gutter = args.named("column-gutter")?; let row_gutter = args.named("row-gutter")?; - Ok(Template::block(Self { + Ok(Content::block(Self { tracks: Spec::new(columns, rows), gutter: Spec::new( column_gutter.unwrap_or_else(|| base_gutter.clone()), diff --git a/src/library/layout/pad.rs b/src/library/layout/pad.rs index 175a54f0..835beef9 100644 --- a/src/library/layout/pad.rs +++ b/src/library/layout/pad.rs @@ -11,7 +11,7 @@ pub struct PadNode { #[class] impl PadNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { let all = args.find()?; let hor = args.named("horizontal")?; let ver = args.named("vertical")?; @@ -21,7 +21,7 @@ impl PadNode { let bottom = args.named("bottom")?.or(ver).or(all).unwrap_or_default(); let body: LayoutNode = args.expect("body")?; let padding = Sides::new(left, top, right, bottom); - Ok(Template::block(body.padded(padding))) + Ok(Content::block(body.padded(padding))) } } diff --git a/src/library/layout/page.rs b/src/library/layout/page.rs index 4b6d68c5..def2940e 100644 --- a/src/library/layout/page.rs +++ b/src/library/layout/page.rs @@ -32,8 +32,8 @@ impl PageNode { /// The page's footer. pub const FOOTER: Marginal = Marginal::None; - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::Page(Self(args.expect("body")?))) + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::Page(Self(args.expect("body")?))) } fn set(args: &mut Args, styles: &mut StyleMap) -> TypResult<()> { @@ -125,12 +125,12 @@ impl PageNode { (Length::zero(), padding.top, header), (size.y - padding.bottom, padding.bottom, footer), ] { - if let Some(template) = marginal.resolve(ctx, page)? { + if let Some(content) = marginal.resolve(ctx, page)? { let pos = Point::new(padding.left, y); let w = size.x - padding.left - padding.right; let area = Size::new(w, h); let pod = Regions::one(area, area, area.map(Length::is_finite)); - let sub = Layout::layout(&template, ctx, &pod, styles)?.remove(0); + let sub = Layout::layout(&content, ctx, &pod, styles)?.remove(0); Arc::make_mut(frame).push_frame(pos, sub); } } @@ -155,8 +155,8 @@ pub struct PagebreakNode; #[class] impl PagebreakNode { - fn construct(_: &mut Context, _: &mut Args) -> TypResult<Template> { - Ok(Template::Pagebreak) + fn construct(_: &mut Context, _: &mut Args) -> TypResult<Content> { + Ok(Content::Pagebreak) } } @@ -165,18 +165,18 @@ impl PagebreakNode { pub enum Marginal { /// Nothing, None, - /// A bare template. - Template(Template), - /// A closure mapping from a page number to a template. + /// Bare content. + Content(Content), + /// A closure mapping from a page number to content. Func(Func, Span), } impl Marginal { /// Resolve the marginal based on the page number. - pub fn resolve(&self, ctx: &mut Context, page: usize) -> TypResult<Option<Template>> { + pub fn resolve(&self, ctx: &mut Context, page: usize) -> TypResult<Option<Content>> { Ok(match self { Self::None => None, - Self::Template(template) => Some(template.clone()), + Self::Content(content) => Some(content.clone()), Self::Func(func, span) => { let args = Args::from_values(*span, [Value::Int(page as i64)]); func.call(ctx, args)?.cast().at(*span)? @@ -187,15 +187,15 @@ impl Marginal { impl Cast<Spanned<Value>> for Marginal { fn is(value: &Spanned<Value>) -> bool { - matches!(&value.v, Value::Template(_) | Value::Func(_)) + matches!(&value.v, Value::Content(_) | Value::Func(_)) } fn cast(value: Spanned<Value>) -> StrResult<Self> { match value.v { Value::None => Ok(Self::None), - Value::Template(v) => Ok(Self::Template(v)), + Value::Content(v) => Ok(Self::Content(v)), Value::Func(v) => Ok(Self::Func(v, value.span)), - _ => Err("expected none, template or function")?, + _ => Err("expected none, content or function")?, } } } diff --git a/src/library/layout/place.rs b/src/library/layout/place.rs index d65b3836..99ff5292 100644 --- a/src/library/layout/place.rs +++ b/src/library/layout/place.rs @@ -7,12 +7,12 @@ pub struct PlaceNode(pub LayoutNode); #[class] impl PlaceNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { let aligns = args.find()?.unwrap_or(Spec::with_x(Some(Align::Left))); let tx = args.named("dx")?.unwrap_or_default(); let ty = args.named("dy")?.unwrap_or_default(); let body: LayoutNode = args.expect("body")?; - Ok(Template::block(Self( + Ok(Content::block(Self( body.moved(Point::new(tx, ty)).aligned(aligns), ))) } diff --git a/src/library/layout/spacing.rs b/src/library/layout/spacing.rs index 3bebfb14..9a27a8b2 100644 --- a/src/library/layout/spacing.rs +++ b/src/library/layout/spacing.rs @@ -5,8 +5,8 @@ pub struct HNode; #[class] impl HNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::Horizontal(args.expect("spacing")?)) + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::Horizontal(args.expect("spacing")?)) } } @@ -15,8 +15,8 @@ pub struct VNode; #[class] impl VNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::Vertical(args.expect("spacing")?)) + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::Vertical(args.expect("spacing")?)) } } diff --git a/src/library/layout/stack.rs b/src/library/layout/stack.rs index 414490ef..88e27116 100644 --- a/src/library/layout/stack.rs +++ b/src/library/layout/stack.rs @@ -14,8 +14,8 @@ pub struct StackNode { #[class] impl StackNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::block(Self { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::block(Self { dir: args.named("dir")?.unwrap_or(Dir::TTB), spacing: args.named("spacing")?, children: args.all()?, @@ -76,12 +76,12 @@ impl Debug for StackChild { castable! { StackChild, - Expected: "linear, fractional or template", + Expected: "linear, fractional or content", Value::Length(v) => Self::Spacing(SpacingKind::Linear(v.into())), Value::Relative(v) => Self::Spacing(SpacingKind::Linear(v.into())), Value::Linear(v) => Self::Spacing(SpacingKind::Linear(v)), Value::Fractional(v) => Self::Spacing(SpacingKind::Fractional(v)), - Value::Template(v) => Self::Node(v.pack()), + Value::Content(v) => Self::Node(v.pack()), } /// Performs stack layout. |
