From 463e4ebd8234da5e28700e9b22b6ef5f0dfef56f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 13 Oct 2019 12:08:07 +0200 Subject: =?UTF-8?q?Refactor=20layout=20types=20=F0=9F=9A=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/library/align.rs | 11 ++++++----- src/library/mod.rs | 7 +++---- src/library/styles.rs | 25 +++++++++++++------------ 3 files changed, 22 insertions(+), 21 deletions(-) (limited to 'src/library') diff --git a/src/library/align.rs b/src/library/align.rs index 4b2ee8c3..b1e41abb 100644 --- a/src/library/align.rs +++ b/src/library/align.rs @@ -38,12 +38,13 @@ impl Function for AlignFunc { Ok(AlignFunc { alignment, body }) } - fn layout(&self, mut ctx: LayoutContext) -> LayoutResult> { + fn layout(&self, ctx: LayoutContext) -> LayoutResult { if let Some(body) = &self.body { - // Override the previous alignment and do the layouting. - ctx.space.alignment = self.alignment; - layout(body, ctx) - .map(|l| Some(Layout::Boxed(l))) + // // Override the previous alignment and do the layouting. + // ctx.space.alignment = self.alignment; + // layout(body, ctx) + // .map(|l| Some(Layout::Boxed(l))) + Ok(FuncCommands::new()) } else { unimplemented!("context-modifying align func") } diff --git a/src/library/mod.rs b/src/library/mod.rs index 9323c4c0..acbd11db 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -9,10 +9,9 @@ mod styles; pub mod prelude { pub use crate::syntax::{SyntaxTree, FuncHeader, Expression}; pub use crate::parsing::{parse, ParseContext, ParseResult, ParseError}; - pub use crate::layout::{layout, Layout, LayoutContext, LayoutResult, LayoutError}; - pub use crate::layout::flex::FlexLayout; - pub use crate::layout::boxed::BoxLayout; - pub use crate::func::Function; + pub use crate::layout::{layout_tree, layout_text, MultiLayout, Layout, LayoutContext}; + pub use crate::layout::{LayoutResult, LayoutError}; + pub use crate::func::{Function, Command, FuncCommands}; pub fn err, T>(message: S) -> ParseResult { Err(ParseError::new(message)) diff --git a/src/library/styles.rs b/src/library/styles.rs index c84b9fed..28cc0e48 100644 --- a/src/library/styles.rs +++ b/src/library/styles.rs @@ -1,7 +1,7 @@ //! Basic style functions: bold, italic, monospace. use super::prelude::*; -use toddle::query::FontClass; +// use toddle::query::FontClass; @@ -27,19 +27,20 @@ macro_rules! style_func { } } - fn layout(&self, ctx: LayoutContext) -> LayoutResult> { - // Change the context. - let mut $style = ctx.style.clone(); - $style_change + fn layout(&self, ctx: LayoutContext) -> LayoutResult { + // // Change the context. + // let mut $style = ctx.style.clone(); + // $style_change - // Create a box and put it into a flex layout. - let boxed = layout(&self.body, LayoutContext { - style: &$style, - .. ctx - })?; - let flex = FlexLayout::from_box(boxed); + // // Create a box and put it into a flex layout. + // let boxed = layout(&self.body, LayoutContext { + // style: &$style, + // .. ctx + // })?; + // let flex = FlexLayout::from_box(boxed); - Ok(Some(Layout::Flex(flex))) + // Ok(Some(Layout::Flex(flex))) + Ok(FuncCommands::new()) } } }; -- cgit v1.2.3