diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-09 18:16:59 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-09 18:20:02 +0100 |
| commit | 010cc2effc2fd0e1c4e52d5c914cb4d74506bc0a (patch) | |
| tree | e50060d271f076b00945e5569e7f8ffef2c28e9f /library/src/layout/container.rs | |
| parent | 12a59963b08b68cc39dcded4d3d3e6a6631c2732 (diff) | |
New block spacing model
Diffstat (limited to 'library/src/layout/container.rs')
| -rw-r--r-- | library/src/layout/container.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs index d65b78b6..22a9e02e 100644 --- a/library/src/layout/container.rs +++ b/library/src/layout/container.rs @@ -1,3 +1,4 @@ +use super::VNode; use crate::prelude::*; /// An inline-level container that sizes content. @@ -63,9 +64,22 @@ pub struct BlockNode(pub Content); #[node(LayoutBlock)] impl BlockNode { + /// The spacing between the previous and this block. + #[property(skip)] + pub const ABOVE: VNode = VNode::weak(Em::new(1.2).into()); + /// The spacing between this and the following block. + #[property(skip)] + pub const BELOW: VNode = VNode::weak(Em::new(1.2).into()); + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { Ok(Self(args.eat()?.unwrap_or_default()).pack()) } + + fn set(...) { + let spacing = args.named("spacing")?.map(VNode::weak); + styles.set_opt(Self::ABOVE, args.named("above")?.map(VNode::strong).or(spacing)); + styles.set_opt(Self::BELOW, args.named("below")?.map(VNode::strong).or(spacing)); + } } impl LayoutBlock for BlockNode { |
