1#[derive(Debug, Clone, Copy, PartialEq, Default)]
5pub struct EdgeInsets {
6 pub top: f32,
7 pub right: f32,
8 pub bottom: f32,
9 pub left: f32,
10}
11
12impl EdgeInsets {
13 pub const ZERO: Self = Self {
14 top: 0.0,
15 right: 0.0,
16 bottom: 0.0,
17 left: 0.0,
18 };
19
20 pub fn all(v: f32) -> Self {
21 Self {
22 top: v,
23 right: v,
24 bottom: v,
25 left: v,
26 }
27 }
28
29 pub fn symmetric(vertical: f32, horizontal: f32) -> Self {
30 Self {
31 top: vertical,
32 bottom: vertical,
33 left: horizontal,
34 right: horizontal,
35 }
36 }
37
38 pub fn horizontal(&self) -> f32 {
39 self.left + self.right
40 }
41 pub fn vertical(&self) -> f32 {
42 self.top + self.bottom
43 }
44}
45
46impl From<f32> for EdgeInsets {
47 fn from(v: f32) -> Self {
48 Self::all(v)
49 }
50}
51
52impl From<f64> for EdgeInsets {
53 fn from(v: f64) -> Self {
54 Self::all(v as f32)
55 }
56}
57
58impl From<i32> for EdgeInsets {
59 fn from(v: i32) -> Self {
60 Self::all(v as f32)
61 }
62}
63
64#[derive(Debug, Clone, Copy, PartialEq, Default)]
66pub struct BorderRadius {
67 pub top_left: f32,
68 pub top_right: f32,
69 pub bottom_right: f32,
70 pub bottom_left: f32,
71}
72
73impl BorderRadius {
74 pub const ZERO: Self = Self {
75 top_left: 0.0,
76 top_right: 0.0,
77 bottom_right: 0.0,
78 bottom_left: 0.0,
79 };
80
81 pub fn all(r: f32) -> Self {
82 Self {
83 top_left: r,
84 top_right: r,
85 bottom_right: r,
86 bottom_left: r,
87 }
88 }
89
90 pub fn to_array(self) -> [f32; 4] {
91 [
92 self.top_left,
93 self.top_right,
94 self.bottom_right,
95 self.bottom_left,
96 ]
97 }
98}
99
100#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
102pub enum Align {
103 #[default]
104 Top,
105 Bottom,
106 Left,
107 Right,
108 Center,
109 SpaceBetween,
110 SpaceAround,
111}
112
113#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
114pub enum BorderAlignment {
115 #[default]
116 Inside,
117 Center,
118 Outside,
119}