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