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/graphics | |
| parent | 37ac5d966ebaf97ac79c507028cd5b742b510b89 (diff) | |
Move layout traits into library
Diffstat (limited to 'src/library/graphics')
| -rw-r--r-- | src/library/graphics/hide.rs | 12 | ||||
| -rw-r--r-- | src/library/graphics/image.rs | 10 | ||||
| -rw-r--r-- | src/library/graphics/line.rs | 10 | ||||
| -rw-r--r-- | src/library/graphics/shape.rs | 20 |
4 files changed, 18 insertions, 34 deletions
diff --git a/src/library/graphics/hide.rs b/src/library/graphics/hide.rs index fafd7421..d320b06c 100644 --- a/src/library/graphics/hide.rs +++ b/src/library/graphics/hide.rs @@ -1,18 +1,18 @@ use crate::library::prelude::*; -/// Hide a node without affecting layout. +/// Hide content without affecting layout. #[derive(Debug, Hash)] pub struct HideNode(pub Content); -#[node(Layout)] +#[node(LayoutInline)] impl HideNode { fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { Ok(Self(args.expect("body")?).pack()) } } -impl Layout for HideNode { - fn layout( +impl LayoutInline for HideNode { + fn layout_inline( &self, world: Tracked<dyn World>, regions: &Regions, @@ -24,8 +24,4 @@ impl Layout for HideNode { } Ok(frames) } - - fn level(&self) -> Level { - Level::Inline - } } diff --git a/src/library/graphics/image.rs b/src/library/graphics/image.rs index 9c3a775a..e27ea488 100644 --- a/src/library/graphics/image.rs +++ b/src/library/graphics/image.rs @@ -8,7 +8,7 @@ use crate::library::text::TextNode; #[derive(Debug, Hash)] pub struct ImageNode(pub Image); -#[node(Layout)] +#[node(LayoutInline)] impl ImageNode { /// How the image should adjust itself to a given area. pub const FIT: ImageFit = ImageFit::Cover; @@ -36,8 +36,8 @@ impl ImageNode { } } -impl Layout for ImageNode { - fn layout( +impl LayoutInline for ImageNode { + fn layout_inline( &self, _: Tracked<dyn World>, regions: &Regions, @@ -95,10 +95,6 @@ impl Layout for ImageNode { Ok(vec![frame]) } - - fn level(&self) -> Level { - Level::Inline - } } /// How an image should adjust itself to a given area. diff --git a/src/library/graphics/line.rs b/src/library/graphics/line.rs index c2f89404..ee7813a5 100644 --- a/src/library/graphics/line.rs +++ b/src/library/graphics/line.rs @@ -9,7 +9,7 @@ pub struct LineNode { delta: Axes<Rel<Length>>, } -#[node(Layout)] +#[node(LayoutInline)] impl LineNode { /// How to stroke the line. #[property(resolve, fold)] @@ -36,8 +36,8 @@ impl LineNode { } } -impl Layout for LineNode { - fn layout( +impl LayoutInline for LineNode { + fn layout_inline( &self, _: Tracked<dyn World>, regions: &Regions, @@ -65,10 +65,6 @@ impl Layout for LineNode { Ok(vec![frame]) } - - fn level(&self) -> Level { - Level::Inline - } } castable! { diff --git a/src/library/graphics/shape.rs b/src/library/graphics/shape.rs index 608c9842..4804cd68 100644 --- a/src/library/graphics/shape.rs +++ b/src/library/graphics/shape.rs @@ -3,23 +3,23 @@ use std::f64::consts::SQRT_2; use crate::library::prelude::*; use crate::library::text::TextNode; -/// Place a node into a sizable and fillable shape. +/// A sizable and fillable shape with optional content. #[derive(Debug, Hash)] pub struct ShapeNode<const S: ShapeKind>(pub Option<Content>); -/// Place a node into a square. +/// A square with optional content. pub type SquareNode = ShapeNode<SQUARE>; -/// Place a node into a rectangle. +/// A rectangle with optional content. pub type RectNode = ShapeNode<RECT>; -/// Place a node into a circle. +/// A circle with optional content. pub type CircleNode = ShapeNode<CIRCLE>; -/// Place a node into an ellipse. +/// A ellipse with optional content. pub type EllipseNode = ShapeNode<ELLIPSE>; -#[node(Layout)] +#[node(LayoutInline)] impl<const S: ShapeKind> ShapeNode<S> { /// How to fill the shape. pub const FILL: Option<Paint> = None; @@ -72,8 +72,8 @@ impl<const S: ShapeKind> ShapeNode<S> { } } -impl<const S: ShapeKind> Layout for ShapeNode<S> { - fn layout( +impl<const S: ShapeKind> LayoutInline for ShapeNode<S> { + fn layout_inline( &self, world: Tracked<dyn World>, regions: &Regions, @@ -173,10 +173,6 @@ impl<const S: ShapeKind> Layout for ShapeNode<S> { Ok(frames) } - - fn level(&self) -> Level { - Level::Inline - } } /// A category of shape. |
