From 272a4c228976466e9fa6cc100ad89f93dc5cc371 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 13 Jan 2021 23:19:44 +0100 Subject: =?UTF-8?q?Unbounded=20pages=20=F0=9F=8C=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eval/context.rs | 4 +++- src/eval/mod.rs | 4 ++-- src/eval/state.rs | 6 +++++- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/eval') diff --git a/src/eval/context.rs b/src/eval/context.rs index 64a8fbbe..1e09aaaf 100644 --- a/src/eval/context.rs +++ b/src/eval/context.rs @@ -95,6 +95,7 @@ impl EvalContext { 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, @@ -124,7 +125,7 @@ impl EvalContext { child: NodeStack { dirs: group.dirs, align: group.align, - expansion: Gen::uniform(Expansion::Fill), + expand: group.expand, children, } .into(), @@ -281,6 +282,7 @@ pub enum Softness { #[derive(Debug)] struct PageGroup { size: Size, + expand: Spec, padding: Sides, dirs: LayoutDirs, align: ChildAlign, diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 0e6fa79f..9abc1074 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -19,7 +19,7 @@ use std::rc::Rc; use crate::color::Color; use crate::diag::Pass; use crate::env::SharedEnv; -use crate::geom::{Angle, Gen, Length, Relative}; +use crate::geom::{Angle, Length, Relative, Spec}; use crate::layout::{self, Expansion, NodeSpacing, NodeStack}; use crate::syntax::*; @@ -137,7 +137,7 @@ impl Eval for Spanned<&NodeRaw> { ctx.push(NodeStack { dirs: ctx.state.dirs, align: ctx.state.align, - expansion: Gen::uniform(Expansion::Fit), + expand: Spec::uniform(Expansion::Fit), children, }); diff --git a/src/eval/state.rs b/src/eval/state.rs index 2a8ee2f0..ce6bd009 100644 --- a/src/eval/state.rs +++ b/src/eval/state.rs @@ -4,8 +4,9 @@ use fontdock::{fallback, FallbackTree, FontStretch, FontStyle, FontVariant, Font use super::Scope; use crate::geom::{ - Align, ChildAlign, Dir, LayoutDirs, Length, Linear, Relative, Sides, Size, + Align, ChildAlign, Dir, LayoutDirs, Length, Linear, Relative, Sides, Size, Spec, }; +use crate::layout::Expansion; use crate::paper::{Paper, PaperClass, PAPER_A4}; /// The evaluation state. @@ -45,6 +46,8 @@ pub struct StatePage { pub class: PaperClass, /// The width and height of the page. pub size: Size, + /// Whether the expand the pages to the `size` or to fit the content. + pub expand: Spec, /// The amount of white space in the order [left, top, right, bottom]. If a /// side is set to `None`, the default for the paper class is used. pub margins: Sides>, @@ -56,6 +59,7 @@ impl StatePage { Self { class: paper.class, size: paper.size(), + expand: Spec::uniform(Expansion::Fill), margins: Sides::uniform(None), } } -- cgit v1.2.3