summaryrefslogtreecommitdiff
path: root/src/library/align.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-01-07 21:24:36 +0100
committerLaurenz <laurmaedje@gmail.com>2022-01-08 00:20:48 +0100
commite74ae6ce70d4c6ca006613eadf07f920951789e3 (patch)
tree0b9b2ddabf79dad8d55631780ee5d70afe7362d7 /src/library/align.rs
parent0b624390906e911bde325b487b2710b67c8205c8 (diff)
Make all nodes into classes
Diffstat (limited to 'src/library/align.rs')
-rw-r--r--src/library/align.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/library/align.rs b/src/library/align.rs
index e8dfabb1..8eee116e 100644
--- a/src/library/align.rs
+++ b/src/library/align.rs
@@ -3,14 +3,7 @@
use super::prelude::*;
use super::ParNode;
-/// `align`: Configure the alignment along the layouting axes.
-pub fn align(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
- let aligns: Spec<_> = args.find().unwrap_or_default();
- let body: PackedNode = args.expect("body")?;
- Ok(Value::block(body.aligned(aligns)))
-}
-
-/// A node that aligns its child.
+/// Align a node along the layouting axes.
#[derive(Debug, Hash)]
pub struct AlignNode {
/// How to align the node horizontally and vertically.
@@ -19,6 +12,15 @@ pub struct AlignNode {
pub child: PackedNode,
}
+#[class]
+impl AlignNode {
+ fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> {
+ let aligns: Spec<_> = args.find().unwrap_or_default();
+ let body: PackedNode = args.expect("body")?;
+ Ok(Node::block(body.aligned(aligns)))
+ }
+}
+
impl Layout for AlignNode {
fn layout(
&self,