summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-10-13 14:15:17 +0200
committerLaurenz <laurmaedje@gmail.com>2021-10-23 20:22:47 +0200
commit5f4dde0a6b32c7620b29af30f69591cf3995af9b (patch)
tree0c56fc286620b03b51d8555e37190c53c008ed98 /src/eval
parent9ac125dea8d6ea6cc01814d04413225845b69d65 (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/eval')
-rw-r--r--src/eval/template.rs21
-rw-r--r--src/eval/walk.rs8
2 files changed, 14 insertions, 15 deletions
diff --git a/src/eval/template.rs b/src/eval/template.rs
index 0ea312e5..59fe293a 100644
--- a/src/eval/template.rs
+++ b/src/eval/template.rs
@@ -6,7 +6,7 @@ use std::rc::Rc;
use super::Str;
use crate::diag::StrResult;
-use crate::geom::{Align, Dir, Gen, GenAxis, Length, Linear, Sides, Size};
+use crate::geom::{Align, Dir, GenAxis, Length, Linear, Sides, Size};
use crate::layout::{
Decoration, LayoutNode, LayoutTree, PadNode, PageRun, ParChild, ParNode, StackChild,
StackNode,
@@ -335,8 +335,7 @@ impl Builder {
/// Push a block node into the active stack, finishing the active paragraph.
fn block(&mut self, node: impl Into<LayoutNode>) {
self.parbreak();
- let aligns = self.style.aligns;
- self.stack.push(StackChild::Any(node.into(), aligns));
+ self.stack.push(StackChild::Any(node.into(), self.style.aligns.block));
self.parbreak();
}
@@ -407,7 +406,7 @@ impl PageBuilder {
}
struct StackBuilder {
- dirs: Gen<Dir>,
+ dir: Dir,
children: Vec<StackChild>,
last: Last<StackChild>,
par: ParBuilder,
@@ -416,7 +415,7 @@ struct StackBuilder {
impl StackBuilder {
fn new(style: &Style) -> Self {
Self {
- dirs: Gen::new(style.dir, Dir::TTB),
+ dir: Dir::TTB,
children: vec![],
last: Last::None,
par: ParBuilder::new(style),
@@ -445,17 +444,17 @@ impl StackBuilder {
}
fn build(self) -> StackNode {
- let Self { dirs, mut children, par, mut last } = self;
+ let Self { dir, mut children, par, mut last } = self;
if let Some(par) = par.build() {
children.extend(last.any());
children.push(par);
}
- StackNode { dirs, children }
+ StackNode { dir, children }
}
}
struct ParBuilder {
- aligns: Gen<Align>,
+ align: Align,
dir: Dir,
line_spacing: Length,
children: Vec<ParChild>,
@@ -465,7 +464,7 @@ struct ParBuilder {
impl ParBuilder {
fn new(style: &Style) -> Self {
Self {
- aligns: style.aligns,
+ align: style.aligns.block,
dir: style.dir,
line_spacing: style.line_spacing(),
children: vec![],
@@ -508,10 +507,10 @@ impl ParBuilder {
}
fn build(self) -> Option<StackChild> {
- let Self { aligns, dir, line_spacing, children, .. } = self;
+ let Self { align, dir, line_spacing, children, .. } = self;
(!children.is_empty()).then(|| {
let node = ParNode { dir, line_spacing, children };
- StackChild::Any(node.into(), aligns)
+ StackChild::Any(node.into(), align)
})
}
}
diff --git a/src/eval/walk.rs b/src/eval/walk.rs
index 90361141..b76300ec 100644
--- a/src/eval/walk.rs
+++ b/src/eval/walk.rs
@@ -2,7 +2,7 @@ use std::rc::Rc;
use super::{Eval, EvalContext, Str, Template, Value};
use crate::diag::TypResult;
-use crate::geom::{Dir, Gen};
+use crate::geom::Align;
use crate::layout::{ParChild, ParNode, StackChild, StackNode};
use crate::syntax::*;
use crate::util::BoolExt;
@@ -117,11 +117,11 @@ fn walk_item(ctx: &mut EvalContext, label: Str, body: Template) {
)],
};
StackNode {
- dirs: Gen::new(Dir::TTB, style.dir),
+ dir: style.dir,
children: vec![
- StackChild::Any(label.into(), Gen::default()),
+ StackChild::Any(label.into(), Align::Start),
StackChild::Spacing((style.text.size / 2.0).into()),
- StackChild::Any(body.to_stack(&style).into(), Gen::default()),
+ StackChild::Any(body.to_stack(&style).into(), Align::Start),
],
}
});