diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-28 12:40:16 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-28 12:40:16 +0100 |
| commit | 989d170dc7318ca3cbaa5b76760eb14f4e6a8605 (patch) | |
| tree | 0a486ddb4d339b8a43313f7c6e18b9595b8fd955 /library/src/graphics/shape.rs | |
| parent | 7caf98fe42797eab59a39ef71071030c9790245a (diff) | |
Fragments
Diffstat (limited to 'library/src/graphics/shape.rs')
| -rw-r--r-- | library/src/graphics/shape.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/library/src/graphics/shape.rs b/library/src/graphics/shape.rs index 4c9fec07..114182e5 100644 --- a/library/src/graphics/shape.rs +++ b/library/src/graphics/shape.rs @@ -19,7 +19,7 @@ pub type CircleNode = ShapeNode<CIRCLE>; /// A ellipse with optional content. pub type EllipseNode = ShapeNode<ELLIPSE>; -#[node(LayoutInline)] +#[node(Layout, Inline)] impl<const S: ShapeKind> ShapeNode<S> { /// How to fill the shape. pub const FILL: Option<Paint> = None; @@ -72,13 +72,13 @@ impl<const S: ShapeKind> ShapeNode<S> { } } -impl<const S: ShapeKind> LayoutInline for ShapeNode<S> { - fn layout_inline( +impl<const S: ShapeKind> Layout for ShapeNode<S> { + fn layout( &self, world: Tracked<dyn World>, styles: StyleChain, regions: &Regions, - ) -> SourceResult<Frame> { + ) -> SourceResult<Fragment> { let mut frame; if let Some(child) = &self.0 { let mut inset = styles.get(Self::INSET); @@ -90,7 +90,7 @@ impl<const S: ShapeKind> LayoutInline for ShapeNode<S> { let child = child.clone().padded(inset.map(|side| side.map(Length::from))); let mut pod = Regions::one(regions.first, regions.base, regions.expand); - frame = child.layout_inline(world, styles, &pod)?; + frame = child.layout(world, styles, &pod)?.into_frame(); // Relayout with full expansion into square region to make sure // the result is really a square or circle. @@ -106,7 +106,7 @@ impl<const S: ShapeKind> LayoutInline for ShapeNode<S> { pod.first = Size::splat(length); pod.expand = Axes::splat(true); - frame = child.layout_inline(world, styles, &pod)?; + frame = child.layout(world, styles, &pod)?.into_frame(); } } else { // The default size that a shape takes on if it has no child and @@ -165,10 +165,12 @@ impl<const S: ShapeKind> LayoutInline for ShapeNode<S> { frame.link(url.clone()); } - Ok(frame) + Ok(Fragment::frame(frame)) } } +impl<const S: ShapeKind> Inline for ShapeNode<S> {} + /// A category of shape. pub type ShapeKind = usize; |
