Skip to main content

guise/layout/
mod.rs

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