diff options
Diffstat (limited to 'crates/typst-library/src/visualize/shape.rs')
| -rw-r--r-- | crates/typst-library/src/visualize/shape.rs | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/crates/typst-library/src/visualize/shape.rs b/crates/typst-library/src/visualize/shape.rs index ff05be2b..f21bf93e 100644 --- a/crates/typst-library/src/visualize/shape.rs +++ b/crates/typst-library/src/visualize/shape.rs @@ -63,7 +63,6 @@ pub struct RectElem { /// rect(stroke: 2pt + red), /// ) /// ``` - #[resolve] #[fold] pub stroke: Smart<Sides<Option<Option<Stroke>>>>, @@ -101,20 +100,17 @@ pub struct RectElem { /// ), /// ) /// ``` - #[resolve] #[fold] pub radius: Corners<Option<Rel<Length>>>, /// How much to pad the rectangle's content. /// See the [box's documentation]($box.inset) for more details. - #[resolve] #[fold] #[default(Sides::splat(Some(Abs::pt(5.0).into())))] pub inset: Sides<Option<Rel<Length>>>, /// How much to expand the rectangle's size without affecting the layout. /// See the [box's documentation]($box.outset) for more details. - #[resolve] #[fold] pub outset: Sides<Option<Rel<Length>>>, @@ -123,15 +119,14 @@ pub struct RectElem { /// When this is omitted, the rectangle takes on a default size of at most /// `{45pt}` by `{30pt}`. #[positional] - #[borrowed] pub body: Option<Content>, } impl Show for Packed<RectElem> { fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> { Ok(BlockElem::single_layouter(self.clone(), engine.routines.layout_rect) - .with_width(self.width(styles)) - .with_height(self.height(styles)) + .with_width(self.width.get(styles)) + .with_height(self.height.get(styles)) .pack() .spanned(self.span())) } @@ -186,26 +181,22 @@ pub struct SquareElem { /// How to stroke the square. See the /// [rectangle's documentation]($rect.stroke) for more details. - #[resolve] #[fold] pub stroke: Smart<Sides<Option<Option<Stroke>>>>, /// How much to round the square's corners. See the /// [rectangle's documentation]($rect.radius) for more details. - #[resolve] #[fold] pub radius: Corners<Option<Rel<Length>>>, /// How much to pad the square's content. See the /// [box's documentation]($box.inset) for more details. - #[resolve] #[fold] #[default(Sides::splat(Some(Abs::pt(5.0).into())))] pub inset: Sides<Option<Rel<Length>>>, /// How much to expand the square's size without affecting the layout. See /// the [box's documentation]($box.outset) for more details. - #[resolve] #[fold] pub outset: Sides<Option<Rel<Length>>>, @@ -215,15 +206,14 @@ pub struct SquareElem { /// When this is omitted, the square takes on a default size of at most /// `{30pt}`. #[positional] - #[borrowed] pub body: Option<Content>, } impl Show for Packed<SquareElem> { fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> { Ok(BlockElem::single_layouter(self.clone(), engine.routines.layout_square) - .with_width(self.width(styles)) - .with_height(self.height(styles)) + .with_width(self.width.get(styles)) + .with_height(self.height.get(styles)) .pack() .spanned(self.span())) } @@ -257,20 +247,17 @@ pub struct EllipseElem { /// How to stroke the ellipse. See the /// [rectangle's documentation]($rect.stroke) for more details. - #[resolve] #[fold] pub stroke: Smart<Option<Stroke>>, /// How much to pad the ellipse's content. See the /// [box's documentation]($box.inset) for more details. - #[resolve] #[fold] #[default(Sides::splat(Some(Abs::pt(5.0).into())))] pub inset: Sides<Option<Rel<Length>>>, /// How much to expand the ellipse's size without affecting the layout. See /// the [box's documentation]($box.outset) for more details. - #[resolve] #[fold] pub outset: Sides<Option<Rel<Length>>>, @@ -279,15 +266,14 @@ pub struct EllipseElem { /// When this is omitted, the ellipse takes on a default size of at most /// `{45pt}` by `{30pt}`. #[positional] - #[borrowed] pub body: Option<Content>, } impl Show for Packed<EllipseElem> { fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> { Ok(BlockElem::single_layouter(self.clone(), engine.routines.layout_ellipse) - .with_width(self.width(styles)) - .with_height(self.height(styles)) + .with_width(self.width.get(styles)) + .with_height(self.height.get(styles)) .pack() .spanned(self.span())) } @@ -347,36 +333,32 @@ pub struct CircleElem { /// How to stroke the circle. See the /// [rectangle's documentation]($rect.stroke) for more details. - #[resolve] #[fold] #[default(Smart::Auto)] pub stroke: Smart<Option<Stroke>>, /// How much to pad the circle's content. See the /// [box's documentation]($box.inset) for more details. - #[resolve] #[fold] #[default(Sides::splat(Some(Abs::pt(5.0).into())))] pub inset: Sides<Option<Rel<Length>>>, /// How much to expand the circle's size without affecting the layout. See /// the [box's documentation]($box.outset) for more details. - #[resolve] #[fold] pub outset: Sides<Option<Rel<Length>>>, /// The content to place into the circle. The circle expands to fit this /// content, keeping the 1-1 aspect ratio. #[positional] - #[borrowed] pub body: Option<Content>, } impl Show for Packed<CircleElem> { fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> { Ok(BlockElem::single_layouter(self.clone(), engine.routines.layout_circle) - .with_width(self.width(styles)) - .with_height(self.height(styles)) + .with_width(self.width.get(styles)) + .with_height(self.height.get(styles)) .pack() .spanned(self.span())) } |
