diff options
Diffstat (limited to 'library/src/layout')
| -rw-r--r-- | library/src/layout/align.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/columns.rs | 8 | ||||
| -rw-r--r-- | library/src/layout/container.rs | 8 | ||||
| -rw-r--r-- | library/src/layout/flow.rs | 9 | ||||
| -rw-r--r-- | library/src/layout/grid.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/hide.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/pad.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/page.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/par.rs | 6 | ||||
| -rw-r--r-- | library/src/layout/place.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/repeat.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/spacing.rs | 8 | ||||
| -rw-r--r-- | library/src/layout/stack.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/transform.rs | 8 |
14 files changed, 57 insertions, 22 deletions
diff --git a/library/src/layout/align.rs b/library/src/layout/align.rs index 506ef684..4fae3c3c 100644 --- a/library/src/layout/align.rs +++ b/library/src/layout/align.rs @@ -1,6 +1,8 @@ use crate::prelude::*; -/// Just an empty shell to scope styles. +/// Align content horizontally and vertically. +#[func] +#[capable] #[derive(Debug, Hash)] pub enum AlignNode {} diff --git a/library/src/layout/columns.rs b/library/src/layout/columns.rs index 28576fdd..0e29bc00 100644 --- a/library/src/layout/columns.rs +++ b/library/src/layout/columns.rs @@ -2,6 +2,8 @@ use crate::prelude::*; use crate::text::TextNode; /// Separate a region into multiple equally sized columns. +#[func] +#[capable(Layout)] #[derive(Debug, Hash)] pub struct ColumnsNode { /// How many columns there should be. @@ -11,7 +13,7 @@ pub struct ColumnsNode { pub body: Content, } -#[node(Layout)] +#[node] impl ColumnsNode { /// The size of the gutter space between each column. #[property(resolve)] @@ -101,12 +103,14 @@ impl Layout for ColumnsNode { } /// A column break. +#[func] +#[capable(Behave)] #[derive(Debug, Hash)] pub struct ColbreakNode { pub weak: bool, } -#[node(Behave)] +#[node] impl ColbreakNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { let weak = args.named("weak")?.unwrap_or(false); diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs index 0b035273..85257715 100644 --- a/library/src/layout/container.rs +++ b/library/src/layout/container.rs @@ -2,6 +2,8 @@ use super::VNode; use crate::prelude::*; /// An inline-level container that sizes content. +#[func] +#[capable(Layout, Inline)] #[derive(Debug, Hash)] pub struct BoxNode { /// How to size the content horizontally and vertically. @@ -10,7 +12,7 @@ pub struct BoxNode { pub body: Content, } -#[node(Layout, Inline)] +#[node] impl BoxNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { let width = args.named("width")?; @@ -60,10 +62,12 @@ impl Layout for BoxNode { impl Inline for BoxNode {} /// A block-level container that places content into a separate flow. +#[func] +#[capable(Layout)] #[derive(Debug, Hash)] pub struct BlockNode(pub Content); -#[node(Layout)] +#[node] impl BlockNode { /// The spacing between the previous and this block. #[property(skip)] diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs index b78f3932..611e9ee1 100644 --- a/library/src/layout/flow.rs +++ b/library/src/layout/flow.rs @@ -7,15 +7,12 @@ use crate::prelude::*; /// /// This node is reponsible for layouting both the top-level content flow and /// the contents of boxes. +#[capable(Layout)] #[derive(Hash)] pub struct FlowNode(pub StyleVec<Content>, pub bool); -#[node(Layout)] -impl FlowNode { - fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { - Ok(BlockNode(args.expect("body")?).pack()) - } -} +#[node] +impl FlowNode {} impl Layout for FlowNode { fn layout( diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs index 9ae780f1..2a6bd4ff 100644 --- a/library/src/layout/grid.rs +++ b/library/src/layout/grid.rs @@ -3,6 +3,8 @@ use crate::prelude::*; use super::Spacing; /// Arrange content in a grid. +#[func] +#[capable(Layout)] #[derive(Debug, Hash)] pub struct GridNode { /// Defines sizing for content rows and columns. @@ -13,7 +15,7 @@ pub struct GridNode { pub cells: Vec<Content>, } -#[node(Layout)] +#[node] impl GridNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { let TrackSizings(columns) = args.named("columns")?.unwrap_or_default(); diff --git a/library/src/layout/hide.rs b/library/src/layout/hide.rs index f6ce21d5..1318b7ed 100644 --- a/library/src/layout/hide.rs +++ b/library/src/layout/hide.rs @@ -1,10 +1,12 @@ use crate::prelude::*; /// Hide content without affecting layout. +#[func] +#[capable(Layout, Inline)] #[derive(Debug, Hash)] pub struct HideNode(pub Content); -#[node(Layout, Inline)] +#[node] impl HideNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { Ok(Self(args.expect("body")?).pack()) diff --git a/library/src/layout/pad.rs b/library/src/layout/pad.rs index 7ae738ac..9c44919d 100644 --- a/library/src/layout/pad.rs +++ b/library/src/layout/pad.rs @@ -1,6 +1,8 @@ use crate::prelude::*; /// Pad content at the sides. +#[func] +#[capable(Layout)] #[derive(Debug, Hash)] pub struct PadNode { /// The amount of padding. @@ -9,7 +11,7 @@ pub struct PadNode { pub body: Content, } -#[node(Layout)] +#[node] impl PadNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { let all = args.named("rest")?.or(args.find()?); diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs index 8ea1eed6..5a23b27b 100644 --- a/library/src/layout/page.rs +++ b/library/src/layout/page.rs @@ -5,6 +5,8 @@ use crate::prelude::*; use crate::text::TextNode; /// Layouts its child onto one or multiple pages. +#[func] +#[capable] #[derive(Clone, Hash)] pub struct PageNode(pub Content); @@ -143,6 +145,8 @@ impl Debug for PageNode { } /// A page break. +#[func] +#[capable] #[derive(Debug, Copy, Clone, Hash)] pub struct PagebreakNode { pub weak: bool, diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs index d93bfba7..925eea54 100644 --- a/library/src/layout/par.rs +++ b/library/src/layout/par.rs @@ -12,6 +12,8 @@ use crate::text::{ }; /// Arrange text, spacing and inline-level nodes into a paragraph. +#[func] +#[capable] #[derive(Hash)] pub struct ParNode(pub StyleVec<Content>); @@ -142,10 +144,12 @@ castable! { } /// A paragraph break. +#[func] +#[capable(Unlabellable)] #[derive(Debug, Hash)] pub struct ParbreakNode; -#[node(Unlabellable)] +#[node] impl ParbreakNode { fn construct(_: &Vm, _: &mut Args) -> SourceResult<Content> { Ok(Self.pack()) diff --git a/library/src/layout/place.rs b/library/src/layout/place.rs index 28d231b7..4c9c0a46 100644 --- a/library/src/layout/place.rs +++ b/library/src/layout/place.rs @@ -1,10 +1,12 @@ use crate::prelude::*; /// Place content at an absolute position. +#[func] +#[capable(Layout, Behave)] #[derive(Debug, Hash)] pub struct PlaceNode(pub Content, bool); -#[node(Layout, Behave)] +#[node] impl PlaceNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { let aligns = args.find()?.unwrap_or(Axes::with_x(Some(GenAlign::Start))); diff --git a/library/src/layout/repeat.rs b/library/src/layout/repeat.rs index 6e0ce39f..196f19de 100644 --- a/library/src/layout/repeat.rs +++ b/library/src/layout/repeat.rs @@ -1,10 +1,12 @@ use crate::prelude::*; /// Repeats content to fill a line. +#[func] +#[capable(Layout, Inline)] #[derive(Debug, Hash)] pub struct RepeatNode(pub Content); -#[node(Layout, Inline)] +#[node] impl RepeatNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { Ok(Self(args.expect("body")?).pack()) diff --git a/library/src/layout/spacing.rs b/library/src/layout/spacing.rs index f5c39af4..91e45b03 100644 --- a/library/src/layout/spacing.rs +++ b/library/src/layout/spacing.rs @@ -3,6 +3,8 @@ use std::cmp::Ordering; use crate::prelude::*; /// Horizontal spacing. +#[func] +#[capable(Behave)] #[derive(Debug, Copy, Clone, Hash)] pub struct HNode { /// The amount of horizontal spacing. @@ -11,7 +13,7 @@ pub struct HNode { pub weak: bool, } -#[node(Behave)] +#[node] impl HNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { let amount = args.expect("spacing")?; @@ -50,6 +52,8 @@ impl Behave for HNode { } /// Vertical spacing. +#[func] +#[capable(Behave)] #[derive(Debug, Copy, Clone, Hash, PartialEq, PartialOrd)] pub struct VNode { /// The amount of vertical spacing. @@ -58,7 +62,7 @@ pub struct VNode { pub weakness: u8, } -#[node(Behave)] +#[node] impl VNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { let amount = args.expect("spacing")?; diff --git a/library/src/layout/stack.rs b/library/src/layout/stack.rs index d44dcb48..1e956669 100644 --- a/library/src/layout/stack.rs +++ b/library/src/layout/stack.rs @@ -4,6 +4,8 @@ use super::{AlignNode, Spacing}; use crate::prelude::*; /// Arrange content and spacing along an axis. +#[func] +#[capable(Layout)] #[derive(Debug, Hash)] pub struct StackNode { /// The stacking direction. @@ -14,7 +16,7 @@ pub struct StackNode { pub children: Vec<StackChild>, } -#[node(Layout)] +#[node] impl StackNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { Ok(Self { diff --git a/library/src/layout/transform.rs b/library/src/layout/transform.rs index 8bf465a9..35b6709a 100644 --- a/library/src/layout/transform.rs +++ b/library/src/layout/transform.rs @@ -3,6 +3,8 @@ use typst::geom::Transform; use crate::prelude::*; /// Move content without affecting layout. +#[func] +#[capable(Layout, Inline)] #[derive(Debug, Hash)] pub struct MoveNode { /// The offset by which to move the content. @@ -11,7 +13,7 @@ pub struct MoveNode { pub body: Content, } -#[node(Layout, Inline)] +#[node] impl MoveNode { fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { let dx = args.named("dx")?.unwrap_or_default(); @@ -44,6 +46,8 @@ impl Layout for MoveNode { impl Inline for MoveNode {} /// Transform content without affecting layout. +#[func] +#[capable(Layout, Inline)] #[derive(Debug, Hash)] pub struct TransformNode<const T: TransformKind> { /// Transformation to apply to the content. @@ -58,7 +62,7 @@ pub type RotateNode = TransformNode<ROTATE>; /// Scale content without affecting layout. pub type ScaleNode = TransformNode<SCALE>; -#[node(Layout, Inline)] +#[node] impl<const T: TransformKind> TransformNode<T> { /// The origin of the transformation. #[property(resolve)] |
