summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-08-17 12:49:48 +0200
committerLaurenz <laurmaedje@gmail.com>2021-08-17 12:49:48 +0200
commitc53d98a22f367a9eecfb45d1b22f1be5c6cf908d (patch)
treeac319fa1b53d659bc021f5ebfd85b868f982a922 /src/library
parent9a798ce6f6e734a02764473891632c071fed41ee (diff)
More logical ordering and naming
Diffstat (limited to 'src/library')
-rw-r--r--src/library/elements.rs14
-rw-r--r--src/library/layout.rs28
2 files changed, 20 insertions, 22 deletions
diff --git a/src/library/elements.rs b/src/library/elements.rs
index 1ad56a81..f4577084 100644
--- a/src/library/elements.rs
+++ b/src/library/elements.rs
@@ -24,7 +24,7 @@ pub fn image(ctx: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
})?;
Ok(Value::template(move |ctx| {
- ctx.push_into_par(ImageNode { id, width, height })
+ ctx.inline(ImageNode { id, width, height })
}))
}
@@ -62,19 +62,19 @@ fn rect_impl(
body: Template,
) -> Value {
Value::template(move |ctx| {
- let mut stack = ctx.exec_template_stack(&body);
+ let mut stack = ctx.exec_template(&body);
stack.aspect = aspect;
let fixed = FixedNode { width, height, child: stack.into() };
if let Some(fill) = fill {
- ctx.push_into_par(BackgroundNode {
+ ctx.inline(BackgroundNode {
shape: BackgroundShape::Rect,
fill: Paint::Color(fill),
child: fixed.into(),
});
} else {
- ctx.push_into_par(fixed);
+ ctx.inline(fixed);
}
})
}
@@ -117,7 +117,7 @@ fn ellipse_impl(
// perfectly into the ellipse.
const PAD: f64 = 0.5 - SQRT_2 / 4.0;
- let mut stack = ctx.exec_template_stack(&body);
+ let mut stack = ctx.exec_template(&body);
stack.aspect = aspect;
let fixed = FixedNode {
@@ -131,13 +131,13 @@ fn ellipse_impl(
};
if let Some(fill) = fill {
- ctx.push_into_par(BackgroundNode {
+ ctx.inline(BackgroundNode {
shape: BackgroundShape::Ellipse,
fill: Paint::Color(fill),
child: fixed.into(),
});
} else {
- ctx.push_into_par(fixed);
+ ctx.inline(fixed);
}
})
}
diff --git a/src/library/layout.rs b/src/library/layout.rs
index 67e58606..e910139c 100644
--- a/src/library/layout.rs
+++ b/src/library/layout.rs
@@ -82,7 +82,7 @@ pub fn pagebreak(_: &mut EvalContext, _: &mut Arguments) -> TypResult<Value> {
pub fn h(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
let spacing = args.expect("spacing")?;
Ok(Value::template(move |ctx| {
- ctx.push_spacing(GenAxis::Cross, spacing);
+ ctx.spacing(GenAxis::Cross, spacing);
}))
}
@@ -90,7 +90,7 @@ pub fn h(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
pub fn v(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
let spacing = args.expect("spacing")?;
Ok(Value::template(move |ctx| {
- ctx.push_spacing(GenAxis::Main, spacing);
+ ctx.spacing(GenAxis::Main, spacing);
}))
}
@@ -134,8 +134,8 @@ pub fn boxed(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
let height = args.named("height")?;
let body = args.eat().unwrap_or_default();
Ok(Value::template(move |ctx| {
- let child = ctx.exec_template_stack(&body).into();
- ctx.push_into_par(FixedNode { width, height, child });
+ let child = ctx.exec_template(&body).into();
+ ctx.inline(FixedNode { width, height, child });
}))
}
@@ -143,8 +143,8 @@ pub fn boxed(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
pub fn block(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
let body = args.expect("body")?;
Ok(Value::template(move |ctx| {
- let block = ctx.exec_template_stack(&body);
- ctx.push_into_stack(block);
+ let block = ctx.exec_template(&body);
+ ctx.block(block);
}))
}
@@ -165,8 +165,8 @@ pub fn pad(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
);
Ok(Value::template(move |ctx| {
- let child = ctx.exec_template_stack(&body).into();
- ctx.push_into_stack(PadNode { padding, child });
+ let child = ctx.exec_template(&body).into();
+ ctx.block(PadNode { padding, child });
}))
}
@@ -179,7 +179,7 @@ pub fn stack(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
let children = children
.iter()
.map(|child| {
- let child = ctx.exec_template_stack(child).into();
+ let child = ctx.exec_template(child).into();
StackChild::Any(child, ctx.state.aligns)
})
.collect();
@@ -192,7 +192,7 @@ pub fn stack(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
dirs.cross = ctx.state.dirs.main;
}
- ctx.push_into_stack(StackNode { dirs, aspect: None, children });
+ ctx.block(StackNode { dirs, aspect: None, children });
}))
}
@@ -220,10 +220,8 @@ pub fn grid(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
);
Ok(Value::template(move |ctx| {
- let children = children
- .iter()
- .map(|child| ctx.exec_template_stack(child).into())
- .collect();
+ let children =
+ children.iter().map(|child| ctx.exec_template(child).into()).collect();
let mut dirs = Gen::new(column_dir, row_dir).unwrap_or(ctx.state.dirs);
@@ -243,7 +241,7 @@ pub fn grid(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
};
}
- ctx.push_into_stack(GridNode {
+ ctx.block(GridNode {
dirs,
tracks: tracks.clone(),
gutter: gutter.clone(),