From 7a6c2cce7747f7632f0be012f49b548db3e62a2d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 14 Jun 2022 15:07:13 +0200 Subject: Make radius configuration unconfusing --- src/model/property.rs | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'src/model') diff --git a/src/model/property.rs b/src/model/property.rs index 0e171939..8681da7d 100644 --- a/src/model/property.rs +++ b/src/model/property.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use super::{Interruption, NodeId, StyleChain}; use crate::eval::{RawLength, Smart}; -use crate::geom::{Length, Numeric, Relative, Sides, Spec}; +use crate::geom::{Corners, Length, Numeric, Relative, Sides, Spec}; use crate::library::layout::PageNode; use crate::library::structure::{EnumNode, ListNode}; use crate::library::text::ParNode; @@ -191,12 +191,15 @@ impl Resolve for Sides { type Output = Sides; fn resolve(self, styles: StyleChain) -> Self::Output { - Sides { - left: self.left.resolve(styles), - right: self.right.resolve(styles), - top: self.top.resolve(styles), - bottom: self.bottom.resolve(styles), - } + self.map(|v| v.resolve(styles)) + } +} + +impl Resolve for Corners { + type Output = Corners; + + fn resolve(self, styles: StyleChain) -> Self::Output { + self.map(|v| v.resolve(styles)) } } @@ -252,7 +255,7 @@ where type Output = Sides; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer, |inner, outer, _| inner.fold(outer)) + self.zip(outer, |inner, outer| inner.fold(outer)) } } @@ -260,7 +263,7 @@ impl Fold for Sides>> { type Output = Sides>; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer, |inner, outer, _| inner.unwrap_or(outer)) + self.zip(outer, |inner, outer| inner.unwrap_or(outer)) } } @@ -268,7 +271,26 @@ impl Fold for Sides>>> { type Output = Sides>>; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer, |inner, outer, _| inner.unwrap_or(outer)) + self.zip(outer, |inner, outer| inner.unwrap_or(outer)) + } +} + +impl Fold for Corners +where + T: Fold, +{ + type Output = Corners; + + fn fold(self, outer: Self::Output) -> Self::Output { + self.zip(outer, |inner, outer| inner.fold(outer)) + } +} + +impl Fold for Corners>> { + type Output = Corners>; + + fn fold(self, outer: Self::Output) -> Self::Output { + self.zip(outer, |inner, outer| inner.unwrap_or(outer)) } } -- cgit v1.2.3