diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-13 23:19:44 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-13 23:19:44 +0100 |
| commit | 272a4c228976466e9fa6cc100ad89f93dc5cc371 (patch) | |
| tree | ad02a6e57b07da061432d58ff0ca46d6777bdb97 /src/library/layout.rs | |
| parent | 1b53e27f270e3c040ee095573af9a5243980191a (diff) | |
Unbounded pages 🌌
Diffstat (limited to 'src/library/layout.rs')
| -rw-r--r-- | src/library/layout.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/library/layout.rs b/src/library/layout.rs index 59c1954b..0e04c507 100644 --- a/src/library/layout.rs +++ b/src/library/layout.rs @@ -197,13 +197,12 @@ pub fn box_(ctx: &mut EvalContext, args: &mut Args) -> Value { let children = ctx.end_content_group(); let fill_if = |c| if c { Expansion::Fill } else { Expansion::Fit }; - let expansion = - Spec::new(fill_if(width.is_some()), fill_if(height.is_some())).switch(dirs); + let expand = Spec::new(fill_if(width.is_some()), fill_if(height.is_some())); ctx.push(NodeFixed { width, height, - child: NodeStack { dirs, align, expansion, children }.into(), + child: NodeStack { dirs, align, expand, children }.into(), }); ctx.state = snapshot; @@ -271,6 +270,7 @@ pub fn page(ctx: &mut EvalContext, args: &mut Args) -> Value { if let Some(paper) = Paper::from_name(&name.v) { ctx.state.page.class = paper.class; ctx.state.page.size = paper.size(); + ctx.state.page.expand = Spec::uniform(Expansion::Fill); } else { ctx.diag(error!(name.span, "invalid paper name")); } @@ -279,11 +279,13 @@ pub fn page(ctx: &mut EvalContext, args: &mut Args) -> Value { if let Some(width) = args.get(ctx, "width") { ctx.state.page.class = PaperClass::Custom; ctx.state.page.size.width = width; + ctx.state.page.expand.horizontal = Expansion::Fill; } if let Some(height) = args.get(ctx, "height") { ctx.state.page.class = PaperClass::Custom; ctx.state.page.size.height = height; + ctx.state.page.expand.vertical = Expansion::Fill; } if let Some(margins) = args.get(ctx, "margins") { @@ -307,8 +309,9 @@ pub fn page(ctx: &mut EvalContext, args: &mut Args) -> Value { } if args.get(ctx, "flip").unwrap_or(false) { - let size = &mut ctx.state.page.size; - std::mem::swap(&mut size.width, &mut size.height); + let page = &mut ctx.state.page; + std::mem::swap(&mut page.size.width, &mut page.size.height); + std::mem::swap(&mut page.expand.horizontal, &mut page.expand.vertical); } let main = args.get(ctx, "main-dir"); |
