1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! Defines alignment options for layout components.
/// Specifies how children are placed along the main axis (the direction of
/// layout) in layout containers such as [`crate::row::row`] or
/// [`crate::column::column`].
///
/// # Variants
///
/// - `Start`: Place children at the start (left or top).
/// - `Center`: Center children along the main axis.
/// - `End`: Place children at the end (right or bottom).
/// - `SpaceEvenly`: Evenly distribute children, including space at the start
/// and end.
/// - `SpaceBetween`: Evenly distribute children, with no space at the start and
/// end.
/// - `SpaceAround`: Evenly distribute children, with half-space at the start
/// and end.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum MainAxisAlignment {
/// Place children at the start (left or top).
Start,
/// Center children along the main axis.
Center,
/// Place children at the end (right or bottom).
End,
/// Evenly distribute children, including space at the start and end.
SpaceEvenly,
/// Evenly distribute children, with no space at the start and end.
SpaceBetween,
/// Evenly distribute children, with half-space at the start and end.
SpaceAround,
}
impl Default for MainAxisAlignment {
/// Returns [`MainAxisAlignment::Start`] as the default value.
///
/// # Example
///
/// ```
/// use tessera_components::alignment::MainAxisAlignment;
/// assert_eq!(MainAxisAlignment::default(), MainAxisAlignment::Start);
/// ```
fn default() -> Self {
Self::Start
}
}
/// Specifies how children are aligned along the cross axis (perpendicular to
/// the layout direction) in layout containers such as [`crate::row::row`] or
/// [`crate::column::column`].
///
/// # Variants
///
/// - `Start`: Align children to the start (left or top).
/// - `Center`: Center children along the cross axis.
/// - `End`: Align children to the end (right or bottom).
/// - `Stretch`: Stretch children to fill the cross axis.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum CrossAxisAlignment {
/// Align children to the start (left or top).
Start,
/// Center children along the cross axis.
Center,
/// Align children to the end (right or bottom).
End,
/// Stretch children to fill the entire cross axis.
Stretch,
}
impl Default for CrossAxisAlignment {
/// Returns [`CrossAxisAlignment::Start`] as the default value.
fn default() -> Self {
Self::Start
}
}
/// Specifies the alignment of a child within its parent container, both
/// vertically and horizontally. Useful for positioning a single child inside a
/// container, such as in a [`crate::boxed::boxed`] component.
///
/// # Variants
/// - `TopStart`: Top-left corner.
/// - `TopCenter`: Top edge, centered horizontally.
/// - `TopEnd`: Top-right corner.
/// - `CenterStart`: Center vertically, left edge.
/// - `Center`: Center both vertically and horizontally.
/// - `CenterEnd`: Center vertically, right edge.
/// - `BottomStart`: Bottom-left corner.
/// - `BottomCenter`: Bottom edge, centered horizontally.
/// - `BottomEnd`: Bottom-right corner.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Alignment {
/// Top-left corner.
TopStart,
/// Top edge, centered horizontally.
TopCenter,
/// Top-right corner.
TopEnd,
/// Center vertically, left edge.
CenterStart,
/// Center both vertically and horizontally.
Center,
/// Center vertically, right edge.
CenterEnd,
/// Bottom-left corner.
BottomStart,
/// Bottom edge, centered horizontally.
BottomCenter,
/// Bottom-right corner.
BottomEnd,
}
impl Default for Alignment {
/// Returns [`Alignment::TopStart`] as the default value.
///
/// # Example
///
/// ```
/// use tessera_components::alignment::Alignment;
/// assert_eq!(Alignment::default(), Alignment::TopStart);
/// ```
fn default() -> Self {
Self::TopStart
}
}