1use fret_core::Px;
2
3use crate::{MetricRef, Radius};
4
5#[derive(Debug, Clone, PartialEq)]
10pub struct Corners4<T> {
11 pub top_left: T,
12 pub top_right: T,
13 pub bottom_right: T,
14 pub bottom_left: T,
15}
16
17impl<T> Corners4<T> {
18 pub fn tltrbrbl(top_left: T, top_right: T, bottom_right: T, bottom_left: T) -> Self {
19 Self {
20 top_left,
21 top_right,
22 bottom_right,
23 bottom_left,
24 }
25 }
26
27 pub fn map<U>(self, mut f: impl FnMut(T) -> U) -> Corners4<U> {
28 Corners4 {
29 top_left: f(self.top_left),
30 top_right: f(self.top_right),
31 bottom_right: f(self.bottom_right),
32 bottom_left: f(self.bottom_left),
33 }
34 }
35}
36
37impl<T: Clone> Corners4<T> {
38 pub fn all(value: T) -> Self {
39 Self {
40 top_left: value.clone(),
41 top_right: value.clone(),
42 bottom_right: value.clone(),
43 bottom_left: value,
44 }
45 }
46}
47
48impl From<Corners4<Radius>> for Corners4<MetricRef> {
49 fn from(value: Corners4<Radius>) -> Self {
50 value.map(MetricRef::radius)
51 }
52}
53
54impl From<Corners4<Px>> for Corners4<MetricRef> {
55 fn from(value: Corners4<Px>) -> Self {
56 value.map(MetricRef::Px)
57 }
58}