2023-11-06 18:46:10 +00:00
|
|
|
use gpui::{div, Div};
|
2023-10-02 22:59:44 +00:00
|
|
|
|
2023-10-06 21:07:59 +00:00
|
|
|
use crate::prelude::*;
|
2023-10-02 22:59:44 +00:00
|
|
|
|
2023-10-17 11:32:49 +00:00
|
|
|
pub trait Stack: Styled + Sized {
|
2023-10-02 22:59:44 +00:00
|
|
|
/// Horizontally stacks elements.
|
|
|
|
fn h_stack(self) -> Self {
|
|
|
|
self.flex().flex_row().items_center()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Vertically stacks elements.
|
|
|
|
fn v_stack(self) -> Self {
|
|
|
|
self.flex().flex_col()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-26 13:54:43 +00:00
|
|
|
impl<V: 'static> Stack for Div<V> {}
|
2023-10-02 22:59:44 +00:00
|
|
|
|
|
|
|
/// Horizontally stacks elements.
|
|
|
|
///
|
|
|
|
/// Sets `flex()`, `flex_row()`, `items_center()`
|
2023-10-26 13:54:43 +00:00
|
|
|
pub fn h_stack<V: 'static>() -> Div<V> {
|
2023-10-02 22:59:44 +00:00
|
|
|
div().h_stack()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Vertically stacks elements.
|
|
|
|
///
|
|
|
|
/// Sets `flex()`, `flex_col()`
|
2023-10-26 13:54:43 +00:00
|
|
|
pub fn v_stack<V: 'static>() -> Div<V> {
|
2023-10-02 22:59:44 +00:00
|
|
|
div().v_stack()
|
|
|
|
}
|