summaryrefslogtreecommitdiff
path: root/src/library/transform.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-11-17 23:09:23 +0100
committerLaurenz <laurmaedje@gmail.com>2021-11-17 23:09:23 +0100
commit095fa52be5d7ed135f39553359e0253cfea6b71b (patch)
tree71e8a71a8b7755b32221a30c32f62cc146acdd33 /src/library/transform.rs
parente869c899bcaefb19c3c47955577396b85494b823 (diff)
Placed node
Diffstat (limited to 'src/library/transform.rs')
-rw-r--r--src/library/transform.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/library/transform.rs b/src/library/transform.rs
index d0a27622..ef9caf2e 100644
--- a/src/library/transform.rs
+++ b/src/library/transform.rs
@@ -2,22 +2,21 @@ use super::prelude::*;
/// `move`: Move content without affecting layout.
pub fn move_(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
- let x = args.named("x")?;
- let y = args.named("y")?;
+ let dx = args.named("dx")?;
+ let dy = args.named("dy")?;
let body: Template = args.expect("body")?;
-
Ok(Value::Template(Template::from_inline(move |style| {
- MoveNode {
- offset: Spec::new(x, y),
- child: body.pack(style),
- }
+ body.pack(style).moved(dx, dy)
})))
}
+/// A node that moves its child without affecting layout.
#[derive(Debug, Hash)]
-struct MoveNode {
- offset: Spec<Option<Linear>>,
- child: PackedNode,
+pub struct MoveNode {
+ /// The node whose contents should be moved.
+ pub child: PackedNode,
+ /// How much to move the contents.
+ pub offset: Spec<Option<Linear>>,
}
impl Layout for MoveNode {