summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-06-14 15:07:13 +0200
committerLaurenz <laurmaedje@gmail.com>2022-06-14 17:17:54 +0200
commit7a6c2cce7747f7632f0be012f49b548db3e62a2d (patch)
tree30103d743fcf22c6838e5ce3b6c632abe15e78b9 /src/model
parent6832ca2a26df5a9407bd2b0266cc0bab328ebeba (diff)
Make radius configuration unconfusing
Diffstat (limited to 'src/model')
-rw-r--r--src/model/property.rs42
1 files changed, 32 insertions, 10 deletions
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<T: Resolve> Resolve for Sides<T> {
type Output = Sides<T::Output>;
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<T: Resolve> Resolve for Corners<T> {
+ type Output = Corners<T::Output>;
+
+ fn resolve(self, styles: StyleChain) -> Self::Output {
+ self.map(|v| v.resolve(styles))
}
}
@@ -252,7 +255,7 @@ where
type Output = Sides<T::Output>;
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<Option<Relative<Length>>> {
type Output = Sides<Relative<Length>>;
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<Option<Smart<Relative<RawLength>>>> {
type Output = Sides<Smart<Relative<RawLength>>>;
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<T> Fold for Corners<T>
+where
+ T: Fold,
+{
+ type Output = Corners<T::Output>;
+
+ fn fold(self, outer: Self::Output) -> Self::Output {
+ self.zip(outer, |inner, outer| inner.fold(outer))
+ }
+}
+
+impl Fold for Corners<Option<Relative<Length>>> {
+ type Output = Corners<Relative<Length>>;
+
+ fn fold(self, outer: Self::Output) -> Self::Output {
+ self.zip(outer, |inner, outer| inner.unwrap_or(outer))
}
}