tessera_ui_basic_components/
alignment.rs

1//! Defines alignment options for layout components.
2
3/// Alignment along the main axis (the direction of layout).
4#[derive(Debug, Clone, Copy, PartialEq)]
5pub enum MainAxisAlignment {
6    /// Align to the start (left or top).
7    Start,
8    /// Align to the center.
9    Center,
10    /// Align to the end (right or bottom).
11    End,
12    /// Distribute space evenly, with space at the start and end.
13    SpaceEvenly,
14    /// Distribute space evenly, with no space at the start and end.
15    SpaceBetween,
16    /// Distribute space evenly, with half-space at the start and end.
17    SpaceAround,
18}
19
20impl Default for MainAxisAlignment {
21    fn default() -> Self {
22        Self::Start
23    }
24}
25
26/// Alignment along the cross axis (perpendicular to the layout direction).
27#[derive(Debug, Clone, Copy, PartialEq)]
28pub enum CrossAxisAlignment {
29    /// Align to the start (left or top).
30    Start,
31    /// Align to the center.
32    Center,
33    /// Align to the end (right or bottom).
34    End,
35    /// Stretch to fill the entire cross axis.
36    Stretch,
37}
38
39impl Default for CrossAxisAlignment {
40    fn default() -> Self {
41        Self::Start
42    }
43}
44
45/// Specifies the alignment of a child within its parent.
46#[derive(Debug, Clone, Copy, PartialEq)]
47pub enum Alignment {
48    TopStart,
49    TopCenter,
50    TopEnd,
51    CenterStart,
52    Center,
53    CenterEnd,
54    BottomStart,
55    BottomCenter,
56    BottomEnd,
57}
58
59impl Default for Alignment {
60    fn default() -> Self {
61        Self::Center
62    }
63}