tessera_foundation/alignment.rs
1//! Alignment types shared by foundational layout APIs.
2//!
3//! ## Usage
4//!
5//! Describe how containers position children along main, cross, or layered axes.
6
7/// Specifies how children are placed along the main axis in layout containers.
8#[derive(Debug, Default, Clone, Copy, PartialEq)]
9pub enum MainAxisAlignment {
10 /// Place children at the start (left or top).
11 #[default]
12 Start,
13 /// Center children along the main axis.
14 Center,
15 /// Place children at the end (right or bottom).
16 End,
17 /// Evenly distribute children, including space at the start and end.
18 SpaceEvenly,
19 /// Evenly distribute children, with no space at the start and end.
20 SpaceBetween,
21 /// Evenly distribute children, with half-space at the start and end.
22 SpaceAround,
23}
24
25/// Specifies how children are aligned along the cross axis in layout containers.
26#[derive(Debug, Default, Clone, Copy, PartialEq)]
27pub enum CrossAxisAlignment {
28 /// Align children to the start (left or top).
29 #[default]
30 Start,
31 /// Center children along the cross axis.
32 Center,
33 /// Align children to the end (right or bottom).
34 End,
35 /// Stretch children to fill the entire cross axis.
36 Stretch,
37}
38
39/// Specifies the alignment of a child within its parent container.
40#[derive(Debug, Default, Clone, Copy, PartialEq)]
41pub enum Alignment {
42 /// Top-left corner.
43 #[default]
44 TopStart,
45 /// Top edge, centered horizontally.
46 TopCenter,
47 /// Top-right corner.
48 TopEnd,
49 /// Center vertically, left edge.
50 CenterStart,
51 /// Center both vertically and horizontally.
52 Center,
53 /// Center vertically, right edge.
54 CenterEnd,
55 /// Bottom-left corner.
56 BottomStart,
57 /// Bottom edge, centered horizontally.
58 BottomCenter,
59 /// Bottom-right corner.
60 BottomEnd,
61}