Skip to main content

guise/layout/
mod.rs

1//! Layout primitives: vertical [`Stack`], horizontal [`Group`], and [`Center`].
2//! These map Mantine's flex helpers onto gpui's flex container.
3
4mod center;
5mod grid;
6mod group;
7mod stack;
8
9pub use center::Center;
10pub use grid::SimpleGrid;
11pub use group::Group;
12pub use stack::Stack;
13
14use gpui::prelude::*;
15use gpui::Div;
16
17use crate::style::FlexExt;
18
19/// Cross-axis alignment of flex children.
20#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21pub enum Align {
22    Start,
23    Center,
24    End,
25    Stretch,
26}
27
28/// Main-axis distribution of flex children.
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30pub enum Justify {
31    Start,
32    Center,
33    End,
34    Between,
35    Around,
36}
37
38pub(crate) fn apply_align(div: Div, align: Align) -> Div {
39    match align {
40        Align::Start => div.items_start(),
41        Align::Center => div.items_center(),
42        Align::End => div.items_end(),
43        Align::Stretch => div.items_stretch(),
44    }
45}
46
47pub(crate) fn apply_justify(div: Div, justify: Justify) -> Div {
48    match justify {
49        Justify::Start => div.justify_start(),
50        Justify::Center => div.justify_center(),
51        Justify::End => div.justify_end(),
52        Justify::Between => div.justify_between(),
53        Justify::Around => div.justify_around(),
54    }
55}