summaryrefslogtreecommitdiff
path: root/src/library/layout/container.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-02 14:48:51 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-02 14:48:51 +0100
commit56342bd972a13ffe21beaf2b87ab7eb1597704b4 (patch)
tree78f9549141e753dde4a938670c54f3fe8695a058 /src/library/layout/container.rs
parent37ac5d966ebaf97ac79c507028cd5b742b510b89 (diff)
Move layout traits into library
Diffstat (limited to 'src/library/layout/container.rs')
-rw-r--r--src/library/layout/container.rs26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/library/layout/container.rs b/src/library/layout/container.rs
index 60f9139b..023809d0 100644
--- a/src/library/layout/container.rs
+++ b/src/library/layout/container.rs
@@ -1,15 +1,15 @@
use crate::library::prelude::*;
-/// An inline-level container that sizes content and places it into a paragraph.
+/// An inline-level container that sizes content.
#[derive(Debug, Clone, Hash)]
pub struct BoxNode {
- /// How to size the node horizontally and vertically.
+ /// How to size the content horizontally and vertically.
pub sizing: Axes<Option<Rel<Length>>>,
- /// The node to be sized.
+ /// The content to be sized.
pub child: Content,
}
-#[node(Layout)]
+#[node(LayoutInline)]
impl BoxNode {
fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> {
let width = args.named("width")?;
@@ -19,8 +19,8 @@ impl BoxNode {
}
}
-impl Layout for BoxNode {
- fn layout(
+impl LayoutInline for BoxNode {
+ fn layout_inline(
&self,
world: Tracked<dyn World>,
regions: &Regions,
@@ -55,25 +55,21 @@ impl Layout for BoxNode {
Ok(frames)
}
-
- fn level(&self) -> Level {
- Level::Inline
- }
}
/// A block-level container that places content into a separate flow.
#[derive(Debug, Clone, Hash)]
pub struct BlockNode(pub Content);
-#[node(Layout)]
+#[node(LayoutBlock)]
impl BlockNode {
fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.eat()?.unwrap_or_default()).pack())
}
}
-impl Layout for BlockNode {
- fn layout(
+impl LayoutBlock for BlockNode {
+ fn layout_block(
&self,
world: Tracked<dyn World>,
regions: &Regions,
@@ -81,8 +77,4 @@ impl Layout for BlockNode {
) -> SourceResult<Vec<Frame>> {
self.0.layout_block(world, regions, styles)
}
-
- fn level(&self) -> Level {
- Level::Block
- }
}