diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-02 14:48:51 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-02 14:48:51 +0100 |
| commit | 56342bd972a13ffe21beaf2b87ab7eb1597704b4 (patch) | |
| tree | 78f9549141e753dde4a938670c54f3fe8695a058 /src/library/layout/transform.rs | |
| parent | 37ac5d966ebaf97ac79c507028cd5b742b510b89 (diff) | |
Move layout traits into library
Diffstat (limited to 'src/library/layout/transform.rs')
| -rw-r--r-- | src/library/layout/transform.rs | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/library/layout/transform.rs b/src/library/layout/transform.rs index 061efa6b..a73a1827 100644 --- a/src/library/layout/transform.rs +++ b/src/library/layout/transform.rs @@ -1,16 +1,16 @@ use crate::geom::Transform; use crate::library::prelude::*; -/// Move a node without affecting layout. +/// Move content without affecting layout. #[derive(Debug, Hash)] pub struct MoveNode { - /// The offset by which to move the node. + /// The offset by which to move the content. pub delta: Axes<Rel<Length>>, - /// The node whose contents should be moved. + /// The content that should be moved. pub child: Content, } -#[node(Layout)] +#[node(LayoutInline)] impl MoveNode { fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let dx = args.named("dx")?.unwrap_or_default(); @@ -23,8 +23,8 @@ impl MoveNode { } } -impl Layout for MoveNode { - fn layout( +impl LayoutInline for MoveNode { + fn layout_inline( &self, world: Tracked<dyn World>, regions: &Regions, @@ -40,28 +40,24 @@ impl Layout for MoveNode { Ok(frames) } - - fn level(&self) -> Level { - Level::Inline - } } -/// Transform a node without affecting layout. +/// Transform content without affecting layout. #[derive(Debug, Hash)] pub struct TransformNode<const T: TransformKind> { - /// Transformation to apply to the contents. + /// Transformation to apply to the content. pub transform: Transform, - /// The node whose contents should be transformed. + /// The content that should be transformed. pub child: Content, } -/// Rotate a node without affecting layout. +/// Rotate content without affecting layout. pub type RotateNode = TransformNode<ROTATE>; -/// Scale a node without affecting layout. +/// Scale content without affecting layout. pub type ScaleNode = TransformNode<SCALE>; -#[node(Layout)] +#[node(LayoutInline)] impl<const T: TransformKind> TransformNode<T> { /// The origin of the transformation. #[property(resolve)] @@ -85,8 +81,8 @@ impl<const T: TransformKind> TransformNode<T> { } } -impl<const T: TransformKind> Layout for TransformNode<T> { - fn layout( +impl<const T: TransformKind> LayoutInline for TransformNode<T> { + fn layout_inline( &self, world: Tracked<dyn World>, regions: &Regions, @@ -106,10 +102,6 @@ impl<const T: TransformKind> Layout for TransformNode<T> { Ok(frames) } - - fn level(&self) -> Level { - Level::Inline - } } /// Kinds of transformations. |
