From 3ca5b238238e1128aa7bbfbd5db9e632045d8600 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 28 Feb 2022 15:50:48 +0100 Subject: Reorganize library --- src/library/layout/transform.rs | 86 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/library/layout/transform.rs (limited to 'src/library/layout/transform.rs') diff --git a/src/library/layout/transform.rs b/src/library/layout/transform.rs new file mode 100644 index 00000000..fafb37a4 --- /dev/null +++ b/src/library/layout/transform.rs @@ -0,0 +1,86 @@ +use crate::geom::Transform; +use crate::library::prelude::*; + +/// Transform a node without affecting layout. +#[derive(Debug, Hash)] +pub struct TransformNode { + /// Transformation to apply to the contents. + pub transform: Transform, + /// The node whose contents should be transformed. + pub child: LayoutNode, +} + +/// Transform a node by translating it without affecting layout. +pub type MoveNode = TransformNode; + +/// Transform a node by rotating it without affecting layout. +pub type RotateNode = TransformNode; + +/// Transform a node by scaling it without affecting layout. +pub type ScaleNode = TransformNode; + +#[class] +impl TransformNode { + /// The origin of the transformation. + pub const ORIGIN: Spec> = Spec::default(); + + fn construct(_: &mut Context, args: &mut Args) -> TypResult