summaryrefslogtreecommitdiff
path: root/src/library/stack.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/stack.rs')
-rw-r--r--src/library/stack.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/library/stack.rs b/src/library/stack.rs
index f4f7a3cf..8c8a9f60 100644
--- a/src/library/stack.rs
+++ b/src/library/stack.rs
@@ -3,16 +3,7 @@
use super::prelude::*;
use super::{AlignNode, SpacingKind};
-/// `stack`: Stack children along an axis.
-pub fn stack(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
- Ok(Value::block(StackNode {
- dir: args.named("dir")?.unwrap_or(Dir::TTB),
- spacing: args.named("spacing")?,
- children: args.all().collect(),
- }))
-}
-
-/// A node that stacks its children.
+/// Stack children along an axis.
#[derive(Debug, Hash)]
pub struct StackNode {
/// The stacking direction.
@@ -23,6 +14,17 @@ pub struct StackNode {
pub children: Vec<StackChild>,
}
+#[class]
+impl StackNode {
+ fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> {
+ Ok(Node::block(Self {
+ dir: args.named("dir")?.unwrap_or(Dir::TTB),
+ spacing: args.named("spacing")?,
+ children: args.all().collect(),
+ }))
+ }
+}
+
impl Layout for StackNode {
fn layout(
&self,