diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-07-29 18:09:51 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-07-29 18:09:51 +0200 |
| commit | bbcdeb128cce04cd95714b7bc7af5a23a7e38bd2 (patch) | |
| tree | e0a1620d335982669cd7671cbd71df46d100e9ea /src/library/layout.rs | |
| parent | f34ba3dcda182d9b9c14cc94fdb48810bf18bef0 (diff) | |
Move, rename and switch some things (boring) 🚚
- Problems -> Diagnostics
- Position -> Pos
- offset_spans -> Offset trait
- Size -> Length (and some more size types renamed)
- Paper into its own module
- scope::Parser -> parsing::CallParser
- Create `Decorations` alias
- Remove lots of double newlines
- Switch from f32 to f64
Diffstat (limited to 'src/library/layout.rs')
| -rw-r--r-- | src/library/layout.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/library/layout.rs b/src/library/layout.rs index 9fac37b7..2d0e3ac5 100644 --- a/src/library/layout.rs +++ b/src/library/layout.rs @@ -1,7 +1,6 @@ -use crate::size::PSize; +use crate::length::ScaleLength; use super::*; - function! { /// `align`: Aligns content along the layouting axes. #[derive(Debug, Clone, PartialEq)] @@ -13,14 +12,14 @@ function! { parse(header, body, ctx, f) { AlignFunc { body: body!(opt: body, ctx, f), - map: PosAxisMap::parse::<AxisKey>(&mut f.problems, &mut header.args), + map: PosAxisMap::parse::<AxisKey>(&mut f.diagnostics, &mut header.args), } } layout(self, ctx, f) { ctx.base = ctx.spaces[0].dimensions; - let map = self.map.dedup(&mut f.problems, ctx.axes, |alignment| { + let map = self.map.dedup(&mut f.diagnostics, ctx.axes, |alignment| { alignment.axis().map(|s| s.to_generic(ctx.axes)) }); @@ -61,14 +60,14 @@ function! { DirectionFunc { name_span: header.name.span, body: body!(opt: body, ctx, f), - map: PosAxisMap::parse::<AxisKey>(&mut f.problems, &mut header.args), + map: PosAxisMap::parse::<AxisKey>(&mut f.diagnostics, &mut header.args), } } layout(self, ctx, f) { ctx.base = ctx.spaces[0].dimensions; - let map = self.map.dedup(&mut f.problems, ctx.axes, |direction| { + let map = self.map.dedup(&mut f.diagnostics, ctx.axes, |direction| { Some(direction.axis().to_generic(ctx.axes)) }); @@ -103,15 +102,15 @@ function! { #[derive(Debug, Clone, PartialEq)] pub struct BoxFunc { body: SyntaxModel, - extents: AxisMap<PSize>, + extents: AxisMap<ScaleLength>, debug: Option<bool>, } parse(header, body, ctx, f) { BoxFunc { body: body!(opt: body, ctx, f).unwrap_or(SyntaxModel::new()), - extents: AxisMap::parse::<ExtentKey>(&mut f.problems, &mut header.args.key), - debug: header.args.key.get::<bool>(&mut f.problems, "debug"), + extents: AxisMap::parse::<ExtentKey>(&mut f.diagnostics, &mut header.args.key), + debug: header.args.key.get::<bool>(&mut f.diagnostics, "debug"), } } @@ -123,12 +122,12 @@ function! { ctx.debug = debug; } - let map = self.extents.dedup(&mut f.problems, ctx.axes); + let map = self.extents.dedup(&mut f.diagnostics, ctx.axes); for &axis in &[Horizontal, Vertical] { - if let Some(psize) = map.get(axis) { - let size = psize.scaled(ctx.base.get(axis)); - *ctx.base.get_mut(axis) = size; - *ctx.spaces[0].dimensions.get_mut(axis) = size; + if let Some(scale) = map.get(axis) { + let length = scale.scaled(ctx.base.get(axis)); + *ctx.base.get_mut(axis) = length; + *ctx.spaces[0].dimensions.get_mut(axis) = length; *ctx.spaces[0].expansion.get_mut(axis) = true; } } |
