diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-10-13 14:15:17 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-10-23 20:22:47 +0200 |
| commit | 5f4dde0a6b32c7620b29af30f69591cf3995af9b (patch) | |
| tree | 0c56fc286620b03b51d8555e37190c53c008ed98 /src/library/layout.rs | |
| parent | 9ac125dea8d6ea6cc01814d04413225845b69d65 (diff) | |
Remove inline alignment from stack
The current inline alignment is very broken and leads to lots of subtle weirdness. Getting rid of it simplifies the stack's interface a lot. At a later point either:
- inline alignment will be added back in a better way, or
- all nodes will be able to expand or align themselves, meaning that the stack's children take care of their alignment
Diffstat (limited to 'src/library/layout.rs')
| -rw-r--r-- | src/library/layout.rs | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/src/library/layout.rs b/src/library/layout.rs index c8b22f88..efa012b9 100644 --- a/src/library/layout.rs +++ b/src/library/layout.rs @@ -204,27 +204,11 @@ pub fn stack(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> { Value::Template(v) => Self::Any(v), } - let dir = args.named("dir")?; + let dir = args.named("dir")?.unwrap_or(Dir::TTB); let spacing = args.named("spacing")?; let list: Vec<Child> = args.all().collect(); Ok(Value::Template(Template::from_block(move |style| { - let mut dirs = Gen::new(style.dir, dir.unwrap_or(Dir::TTB)); - - // If the directions become aligned, fix up the inline direction since - // that's the one that is not user-defined. - if dirs.inline.axis() == dirs.block.axis() { - dirs.inline = Dir::TTB; - } - - // Use the current alignments for all children, but take care to apply - // them to the correct axes (by swapping them if the stack axes are - // different from the style axes). - let mut aligns = style.aligns; - if dirs.inline.axis() != style.dir.axis() { - aligns = Gen::new(aligns.block, aligns.inline); - } - let mut children = vec![]; let mut delayed = None; @@ -241,13 +225,13 @@ pub fn stack(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> { } let node = template.to_stack(style).into(); - children.push(StackChild::Any(node, aligns)); + children.push(StackChild::Any(node, style.aligns.block)); delayed = spacing; } } } - StackNode { dirs, children } + StackNode { dir, children } }))) } |
