diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-11-30 18:54:46 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-11-30 18:54:46 +0100 |
| commit | 5782b82770f6923677942c3b4e2bf4f7258e47d8 (patch) | |
| tree | 2b477fc285e9da5380e556648056b985ecbccfe0 /src/library | |
| parent | b13ed627fff73a599b34d760cd99aa2f08d58ea8 (diff) | |
Refactor layouting base ♻
Diffstat (limited to 'src/library')
| -rw-r--r-- | src/library/align.rs | 8 | ||||
| -rw-r--r-- | src/library/boxed.rs | 2 | ||||
| -rw-r--r-- | src/library/page.rs | 10 | ||||
| -rw-r--r-- | src/library/spacing.rs | 8 | ||||
| -rw-r--r-- | src/library/style.rs | 8 |
5 files changed, 18 insertions, 18 deletions
diff --git a/src/library/align.rs b/src/library/align.rs index 55063ebe..530120e7 100644 --- a/src/library/align.rs +++ b/src/library/align.rs @@ -69,7 +69,7 @@ function! { layout(this, ctx) { let mut axes = ctx.axes; - let primary_horizontal = axes.primary.axis.is_horizontal(); + let primary_horizontal = axes.primary.is_horizontal(); let mut primary = false; let mut secondary = false; @@ -87,7 +87,7 @@ function! { *was_set = true; - let horizontal = axis.axis.is_horizontal(); + let horizontal = axis.is_horizontal(); let alignment = generic_alignment(spec, horizontal)?; if axis.alignment == Alignment::End && alignment == Alignment::Origin { @@ -116,13 +116,13 @@ function! { set_axis(!primary_horizontal, this.vertical)?; Ok(match &this.body { - Some(body) => commands![AddMultiple( + Some(body) => vec![AddMultiple( layout_tree(body, LayoutContext { axes, .. ctx.clone() })? )], - None => commands![Command::SetAxes(axes)] + None => vec![Command::SetAxes(axes)] }) } } diff --git a/src/library/boxed.rs b/src/library/boxed.rs index 1cc4e020..8984417c 100644 --- a/src/library/boxed.rs +++ b/src/library/boxed.rs @@ -32,6 +32,6 @@ function! { ctx.spaces[0].dimensions.y = height; } - Ok(commands![AddMultiple(layout_tree(&this.body, ctx)?)]) + Ok(vec![AddMultiple(layout_tree(&this.body, ctx)?)]) } } diff --git a/src/library/page.rs b/src/library/page.rs index 40872d63..e8a80870 100644 --- a/src/library/page.rs +++ b/src/library/page.rs @@ -7,7 +7,7 @@ pub struct PageBreak; function! { data: PageBreak, parse: plain, - layout(_, _) { Ok(commands![FinishSpace]) } + layout(_, _) { Ok(vec![FinishSpace]) } } /// `page.size`: Set the size of pages. @@ -29,12 +29,12 @@ function! { } layout(this, ctx) { - let mut style = ctx.page_style; + let mut style = ctx.style.page; if let Some(width) = this.width { style.dimensions.x = width; } if let Some(height) = this.height { style.dimensions.y = height; } - Ok(commands![SetPageStyle(style)]) + Ok(vec![SetPageStyle(style)]) } } @@ -67,13 +67,13 @@ function! { } layout(this, ctx) { - let mut style = ctx.page_style; + let mut style = ctx.style.page; if let Some(left) = this.left { style.margins.left = left; } if let Some(top) = this.top { style.margins.top = top; } if let Some(right) = this.right { style.margins.right = right; } if let Some(bottom) = this.bottom { style.margins.bottom = bottom; } - Ok(commands![SetPageStyle(style)]) + Ok(vec![SetPageStyle(style)]) } } diff --git a/src/library/spacing.rs b/src/library/spacing.rs index d52153b1..869a6227 100644 --- a/src/library/spacing.rs +++ b/src/library/spacing.rs @@ -7,7 +7,7 @@ pub struct LineBreak; function! { data: LineBreak, parse: plain, - layout(_, _) { Ok(commands![FinishLine]) } + layout(_, _) { Ok(vec![FinishLine]) } } /// `paragraph.break`: Ends the current paragraph. @@ -19,7 +19,7 @@ pub struct ParagraphBreak; function! { data: ParagraphBreak, parse: plain, - layout(_, _) { Ok(commands![BreakParagraph]) } + layout(_, _) { Ok(vec![BreakParagraph]) } } macro_rules! space_func { @@ -47,10 +47,10 @@ macro_rules! space_func { layout(this, ctx) { let $var = match this.0 { Spacing::Absolute(s) => s, - Spacing::Relative(f) => f * ctx.text_style.font_size, + Spacing::Relative(f) => f * ctx.style.text.font_size, }; - Ok(commands![$command]) + Ok(vec![$command]) } } ); diff --git a/src/library/style.rs b/src/library/style.rs index a63166cf..b2de19bb 100644 --- a/src/library/style.rs +++ b/src/library/style.rs @@ -18,16 +18,16 @@ macro_rules! stylefunc { } layout(this, ctx) { - let mut style = ctx.text_style.clone(); + let mut style = ctx.style.text.clone(); style.toggle_class(FontClass::$ident); Ok(match &this.body { - Some(body) => commands![ + Some(body) => vec![ SetTextStyle(style), LayoutTree(body), - SetTextStyle(ctx.text_style.clone()), + SetTextStyle(ctx.style.text.clone()), ], - None => commands![SetTextStyle(style)] + None => vec![SetTextStyle(style)] }) } } |
