From bbcdeb128cce04cd95714b7bc7af5a23a7e38bd2 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 29 Jul 2020 18:09:51 +0200 Subject: =?UTF-8?q?Move,=20rename=20and=20switch=20some=20things=20(boring?= =?UTF-8?q?)=20=F0=9F=9A=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- src/library/layout.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/library/layout.rs') 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::(&mut f.problems, &mut header.args), + map: PosAxisMap::parse::(&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::(&mut f.problems, &mut header.args), + map: PosAxisMap::parse::(&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, + extents: AxisMap, debug: Option, } parse(header, body, ctx, f) { BoxFunc { body: body!(opt: body, ctx, f).unwrap_or(SyntaxModel::new()), - extents: AxisMap::parse::(&mut f.problems, &mut header.args.key), - debug: header.args.key.get::(&mut f.problems, "debug"), + extents: AxisMap::parse::(&mut f.diagnostics, &mut header.args.key), + debug: header.args.key.get::(&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; } } -- cgit v1.2.3