From 5f1499d380e223e7e1b2a8a96eb99e3ec95a56ac Mon Sep 17 00:00:00 2001 From: Martin Haug Date: Sat, 30 Apr 2022 21:59:34 +0200 Subject: Add round corners and change arguments --- src/model/layout.rs | 6 ++++-- src/model/styles.rs | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src/model') diff --git a/src/model/layout.rs b/src/model/layout.rs index 51154286..63e8f088 100644 --- a/src/model/layout.rs +++ b/src/model/layout.rs @@ -353,7 +353,8 @@ impl Layout for FillNode { ) -> TypResult>> { let mut frames = self.child.layout(ctx, regions, styles)?; for frame in &mut frames { - let shape = Geometry::Rect(frame.size).filled(self.fill); + let shape = Geometry::Rect(frame.size, Sides::splat(Length::zero())) + .filled(self.fill); Arc::make_mut(frame).prepend(Point::zero(), Element::Shape(shape)); } Ok(frames) @@ -378,7 +379,8 @@ impl Layout for StrokeNode { ) -> TypResult>> { let mut frames = self.child.layout(ctx, regions, styles)?; for frame in &mut frames { - let shape = Geometry::Rect(frame.size).stroked(self.stroke); + let shape = Geometry::Rect(frame.size, Sides::splat(Length::zero())) + .stroked(self.stroke); Arc::make_mut(frame).prepend(Point::zero(), Element::Shape(shape)); } Ok(frames) diff --git a/src/model/styles.rs b/src/model/styles.rs index eb7a7053..2e752625 100644 --- a/src/model/styles.rs +++ b/src/model/styles.rs @@ -459,6 +459,22 @@ where } } +impl Fold for Sides> +where + T: Default, +{ + type Output = Sides; + + fn fold(self, outer: Self::Output) -> Self::Output { + Sides { + left: self.left.unwrap_or(outer.left), + right: self.right.unwrap_or(outer.right), + top: self.top.unwrap_or(outer.top), + bottom: self.bottom.unwrap_or(outer.bottom), + } + } +} + /// A scoped property barrier. /// /// Barriers interact with [scoped](StyleMap::scoped) styles: A scoped style -- cgit v1.2.3