diff options
Diffstat (limited to 'src/library/layout')
| -rw-r--r-- | src/library/layout/grid.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/locate.rs | 14 | ||||
| -rw-r--r-- | src/library/layout/mod.rs | 2 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/library/layout/grid.rs b/src/library/layout/grid.rs index 5b621732..4cad9de6 100644 --- a/src/library/layout/grid.rs +++ b/src/library/layout/grid.rs @@ -204,7 +204,9 @@ impl<'a> GridLayouter<'a> { /// Determines the columns sizes and then layouts the grid row-by-row. pub fn layout(mut self) -> TypResult<Vec<Arc<Frame>>> { + self.ctx.pins.freeze(); self.measure_columns()?; + self.ctx.pins.unfreeze(); for y in 0 .. self.rows.len() { // Skip to next region if current one is full, but only for content @@ -370,10 +372,12 @@ impl<'a> GridLayouter<'a> { pod.base.x = self.regions.base.x; } + self.ctx.pins.freeze(); let mut sizes = node .layout(self.ctx, &pod, self.styles)? .into_iter() .map(|frame| frame.size.y); + self.ctx.pins.unfreeze(); // For each region, we want to know the maximum height any // column requires. diff --git a/src/library/layout/locate.rs b/src/library/layout/locate.rs new file mode 100644 index 00000000..e94a48ba --- /dev/null +++ b/src/library/layout/locate.rs @@ -0,0 +1,14 @@ +use crate::library::prelude::*; +use crate::model::{Group, LocateNode}; + +/// Format content with access to its location on the page. +pub fn locate(_: &mut Machine, args: &mut Args) -> TypResult<Value> { + let node = LocateNode::new(args.expect("recipe")?); + Ok(Value::Content(Content::Locate(node))) +} + +/// Create a new group of locatable elements. +pub fn group(_: &mut Machine, args: &mut Args) -> TypResult<Value> { + let key = args.expect("key")?; + Ok(Value::dynamic(Group::new(key))) +} diff --git a/src/library/layout/mod.rs b/src/library/layout/mod.rs index 588b15aa..6cf5b550 100644 --- a/src/library/layout/mod.rs +++ b/src/library/layout/mod.rs @@ -5,6 +5,7 @@ mod columns; mod container; mod flow; mod grid; +mod locate; mod pad; mod page; mod place; @@ -16,6 +17,7 @@ pub use columns::*; pub use container::*; pub use flow::*; pub use grid::*; +pub use locate::*; pub use pad::*; pub use page::*; pub use place::*; |
