diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-02 14:48:51 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-02 14:48:51 +0100 |
| commit | 56342bd972a13ffe21beaf2b87ab7eb1597704b4 (patch) | |
| tree | 78f9549141e753dde4a938670c54f3fe8695a058 /src/library/layout/align.rs | |
| parent | 37ac5d966ebaf97ac79c507028cd5b742b510b89 (diff) | |
Move layout traits into library
Diffstat (limited to 'src/library/layout/align.rs')
| -rw-r--r-- | src/library/layout/align.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/library/layout/align.rs b/src/library/layout/align.rs index f49763b5..2ee565cc 100644 --- a/src/library/layout/align.rs +++ b/src/library/layout/align.rs @@ -1,26 +1,23 @@ use crate::library::prelude::*; use crate::library::text::{HorizontalAlign, ParNode}; -/// Align a node along the layouting axes. +/// Align content along the layouting axes. #[derive(Debug, Hash)] pub struct AlignNode { - /// How to align the node horizontally and vertically. + /// How to align the content horizontally and vertically. pub aligns: Axes<Option<RawAlign>>, - /// The node to be aligned. + /// The content to be aligned. pub child: Content, } -#[node(Layout)] +#[node(LayoutBlock)] impl AlignNode { fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let aligns: Axes<Option<RawAlign>> = args.find()?.unwrap_or_default(); let body: Content = args.expect("body")?; if let Axes { x: Some(x), y: None } = aligns { - if body - .to::<dyn Layout>() - .map_or(true, |node| node.level() == Level::Inline) - { + if !body.has::<dyn LayoutBlock>() { return Ok(body.styled(ParNode::ALIGN, HorizontalAlign(x))); } } @@ -29,8 +26,8 @@ impl AlignNode { } } -impl Layout for AlignNode { - fn layout( +impl LayoutBlock for AlignNode { + fn layout_block( &self, world: Tracked<dyn World>, regions: &Regions, @@ -62,8 +59,4 @@ impl Layout for AlignNode { Ok(frames) } - - fn level(&self) -> Level { - Level::Block - } } |
