stack.rs

 1use gpui::{div, Div};
 2
 3use crate::prelude::*;
 4
 5pub trait Stack: Styled + Sized {
 6    /// Horizontally stacks elements.
 7    fn h_stack(self) -> Self {
 8        self.flex().flex_row().items_center()
 9    }
10
11    /// Vertically stacks elements.
12    fn v_stack(self) -> Self {
13        self.flex().flex_col()
14    }
15}
16
17impl<V: 'static> Stack for Div<V> {}
18
19/// Horizontally stacks elements.
20///
21/// Sets `flex()`, `flex_row()`, `items_center()`
22pub fn h_stack<V: 'static>() -> Div<V> {
23    div().h_stack()
24}
25
26/// Vertically stacks elements.
27///
28/// Sets `flex()`, `flex_col()`
29pub fn v_stack<V: 'static>() -> Div<V> {
30    div().v_stack()
31}