forked from reya/gpui-native-kit
36 lines
833 B
Rust
36 lines
833 B
Rust
//! Shared element constructors and small style helpers.
|
|
|
|
pub use gpui_native_theme::Size;
|
|
pub use gpui_native_utils::{h_flex, v_flex};
|
|
|
|
/// A handler told to clean up after a dismissed surface.
|
|
pub type DismissHandler = std::rc::Rc<dyn Fn(&mut gpui::App)>;
|
|
|
|
/// A component that can be told which size to render at.
|
|
pub trait Sizable: Sized {
|
|
/// Sets the size.
|
|
fn with_size(mut self, size: Size) -> Self {
|
|
self.apply_size(size);
|
|
self
|
|
}
|
|
|
|
/// Applies the size to the component's fields.
|
|
fn apply_size(&mut self, size: Size);
|
|
|
|
/// Sets `Size::Small`.
|
|
fn small(self) -> Self
|
|
where
|
|
Self: Sized,
|
|
{
|
|
self.with_size(Size::Small)
|
|
}
|
|
|
|
/// Sets `Size::Large`.
|
|
fn large(self) -> Self
|
|
where
|
|
Self: Sized,
|
|
{
|
|
self.with_size(Size::Large)
|
|
}
|
|
}
|