Files
gpui-native-kit/crates/core/src/common.rs
T
reya be457c1bba Add xsmall controls for close affordances
- Add the xsmall size class and Sizable::xsmall().
- Use xsmall close buttons in tabs, dialogs, and alerts.
- Assert xsmall and medium button heights.
2026-11-16 19:05:44 +07:00

51 lines
1.3 KiB
Rust

//! Shared element constructors and small style helpers.
pub use gpui_native_theme::Size;
pub use gpui_native_utils::{StyledExt, 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)>;
/// Deferred draw priority of window-modal surfaces; default layer 0 stays for in-flow chrome like resize handles.
pub const DIALOG_LAYER: usize = 1;
/// Deferred draw priority of floating panels, so controls inside a dialog open above it.
pub const OVERLAY_LAYER: usize = 2;
/// Deferred draw priority of passive notifications, so they stay visible over dialogs.
pub const TOAST_LAYER: usize = 3;
/// 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::XSmall`.
fn xsmall(self) -> Self
where
Self: Sized,
{
self.with_size(Size::XSmall)
}
/// 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)
}
}