summaryrefslogtreecommitdiff
path: root/src/library/layout.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-08-19 15:31:29 +0200
committerLaurenz <laurmaedje@gmail.com>2021-08-19 15:52:15 +0200
commita6f260ca39f70f82617eca87855789413715f47d (patch)
tree08141ae619bd21e0544d21433bce759aebc7ba83 /src/library/layout.rs
parentfdab7158c91c52a4ace211c804fdd8e9110f56de (diff)
Refactor layouting a bit
Notably: - Handle aspect ratio in fixed node - Inline constraint inflation into pad node
Diffstat (limited to 'src/library/layout.rs')
-rw-r--r--src/library/layout.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/library/layout.rs b/src/library/layout.rs
index b1510cb6..91e2e7f3 100644
--- a/src/library/layout.rs
+++ b/src/library/layout.rs
@@ -145,8 +145,12 @@ pub fn boxed(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
let height = args.named("height")?;
let body: Template = args.eat().unwrap_or_default();
Ok(Value::Template(Template::from_inline(move |state| {
- let child = body.to_stack(state).into();
- FixedNode { width, height, child }
+ FixedNode {
+ width,
+ height,
+ aspect: None,
+ child: body.to_stack(state).into(),
+ }
})))
}
@@ -190,10 +194,7 @@ pub fn stack(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
Ok(Value::Template(Template::from_block(move |state| {
let children = children
.iter()
- .map(|child| {
- let child = child.to_stack(state).into();
- StackChild::Any(child, state.aligns)
- })
+ .map(|child| StackChild::Any(child.to_stack(state).into(), state.aligns))
.collect();
let mut dirs = Gen::new(None, dir).unwrap_or(state.dirs);
@@ -204,7 +205,7 @@ pub fn stack(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> {
dirs.cross = state.dirs.main;
}
- StackNode { dirs, aspect: None, children }
+ StackNode { dirs, children }
})))
}