summaryrefslogtreecommitdiff
path: root/src/exec/context.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-03-11 10:48:29 +0100
committerLaurenz <laurmaedje@gmail.com>2021-03-11 10:48:29 +0100
commitc1b1dbcc0925ba1730fabbfbca3c8b99831c5561 (patch)
tree6e4cb30753729c699bd899a7f2ec352e276beee8 /src/exec/context.rs
parent4e5f85aa4ac0d6b51323bb2a6e1fbd3f4f46babb (diff)
Better expansion behaviour 🐪
This makes expansion behaviour inheritable by placing it into the area and passing it down during layouting instead of computing some approximation of what we want during execution.
Diffstat (limited to 'src/exec/context.rs')
-rw-r--r--src/exec/context.rs20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/exec/context.rs b/src/exec/context.rs
index d491a251..4d2047a6 100644
--- a/src/exec/context.rs
+++ b/src/exec/context.rs
@@ -7,7 +7,7 @@ use super::*;
use crate::diag::{Diag, DiagSet};
use crate::geom::{ChildAlign, Dir, Gen, LayoutDirs, Length, Linear, Sides, Size};
use crate::layout::{
- Expansion, Node, NodePad, NodePages, NodePar, NodeSpacing, NodeStack, NodeText, Tree,
+ Node, NodePad, NodePages, NodePar, NodeSpacing, NodeStack, NodeText, Tree,
};
use crate::parse::is_newline;
@@ -105,18 +105,18 @@ impl<'a> ExecContext<'a> {
}
}
- /// Execute the body of a function and return the result as a stack node.
- pub fn exec_body(&mut self, body: &ValueTemplate, expand: Spec<Expansion>) -> Node {
+ /// Execute a template and return the result as a stack node.
+ pub fn exec(&mut self, template: &ValueTemplate) -> Node {
let dirs = self.state.dirs;
let align = self.state.align;
self.start_group(ContentGroup);
self.start_par_group();
- body.exec(self);
+ template.exec(self);
self.end_par_group();
let children = self.end_group::<ContentGroup>().1;
- NodeStack { dirs, align, expand, children }.into()
+ NodeStack { dirs, align, children }.into()
}
/// Start a page group based on the active page state.
@@ -128,7 +128,6 @@ impl<'a> ExecContext<'a> {
pub fn start_page_group(&mut self, softness: Softness) {
self.start_group(PageGroup {
size: self.state.page.size,
- expand: self.state.page.expand,
padding: self.state.page.margins(),
dirs: self.state.dirs,
align: self.state.align,
@@ -158,7 +157,6 @@ impl<'a> ExecContext<'a> {
child: NodeStack {
dirs: group.dirs,
align: group.align,
- expand: group.expand,
children,
}
.into(),
@@ -186,13 +184,6 @@ impl<'a> ExecContext<'a> {
self.push(NodePar {
dirs: group.dirs,
align: group.align,
- // FIXME: This is a hack and should be superseded by something
- // better.
- cross_expansion: if self.groups.len() <= 1 {
- Expansion::Fill
- } else {
- Expansion::Fit
- },
line_spacing: group.line_spacing,
children,
});
@@ -306,7 +297,6 @@ pub enum Softness {
#[derive(Debug)]
struct PageGroup {
size: Size,
- expand: Spec<Expansion>,
padding: Sides<Linear>,
dirs: LayoutDirs,
align: ChildAlign,