Skip to main content

altui_core/layout/
flex.rs

1/// Controls how free space is distributed along the main axis.
2///
3/// Flex is applied after all constraints are resolved and only affects
4/// positioning, not sizing.
5///
6/// The main axis depends on layout direction:
7/// * horizontal → X axis
8/// * vertical → Y axis
9#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Hash)]
10pub enum Flex {
11    /// Legacy behavior preserved for backward compatibility.
12    ///
13    /// The exact behavior is implementation-defined and may change.
14    Legacy,
15
16    /// Packs elements toward the start of the area.
17    ///
18    /// ```text
19    /// |[A][B][C]        |
20    /// ```
21    #[default]
22    Start,
23
24    /// Packs elements toward the end of the area.
25    ///
26    /// ```text
27    /// |        [A][B][C]|
28    /// ```
29    End,
30
31    /// Centers elements as a group.
32    ///
33    /// ```text
34    /// |    [A][B][C]    |
35    /// ```
36    Center,
37
38    /// Distributes free space only between elements.
39    ///
40    /// No gap is added before the first or after the last element.
41    ///
42    /// ```text
43    /// |[A]    [B]    [C]|
44    /// ```
45    SpaceBetween,
46
47    /// Distributes free space evenly around all elements.
48    ///
49    /// The gap before the first element, between elements, and after
50    /// the last element is equal.
51    ///
52    /// ```text
53    /// |  [A]  [B]  [C]  |
54    /// ```
55    SpaceAround,
56}