···11//! gpuikit
2233+use gpui::App;
34pub use gpuikit_theme as theme;
4566+pub mod elements;
57pub mod error;
68pub mod fs;
79pub mod layout;
810pub mod resource;
1111+pub mod traits;
1212+pub mod utils;
9131010-pub mod style {
1111- use gpuikit_theme::Theme;
1212-1313- pub trait Themed {
1414- fn themed(self, theme: &Theme) -> Self;
1515- }
1616-1717- // todo: is Themed useful?
1818- //
1919- // I could see most gpuikit components being something like:
2020- //
2121- // pub trait Component: IntoElement + Themed {}
2222- //
2323- // where Themed eventually gets more style helpers...
1414+/// Initialize gpuikit - this sets up & loads themes, sets up global state, etc.
1515+///
1616+/// This must be called as soon as possible after your `gpui::Application` is created,
1717+/// as calling a gpuikit component before initialization will panic.
1818+pub fn init(cx: &mut App) {
1919+ gpuikit_theme::init(cx);
2020+ utils::element_manager::init(cx);
2421}
+3
crates/gpuikit/src/traits.rs
···11+pub mod button;
22+pub mod clickable;
33+pub mod visual_focus;
+9
crates/gpuikit/src/traits/button.rs
···11+use super::clickable::Clickable;
22+33+/// A button is a clickable element that dispatches some
44+/// handler when clicked.
55+pub trait Button: Clickable {
66+ type Variant;
77+88+ fn variant(&self) -> Self::Variant;
99+}
+10
crates/gpuikit/src/traits/clickable.rs
···11+use gpui::{App, ClickEvent, Window};
22+33+/// Trait for elements that can be clicked
44+pub trait Clickable {
55+ /// Check if this element is disabled
66+ fn disabled(&self) -> bool;
77+88+ /// Set the click handler
99+ fn on_click(self, handler: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static) -> Self;
1010+}
+14
crates/gpuikit/src/traits/visual_focus.rs
···11+/// Indicates what kind of visual focus style an element should use
22+///
33+/// - Ring: A focus ring is drawn around the element
44+/// - Highlight: Element is highlighted (e.g. background color change)
55+pub enum FocusStyle {
66+ Ring,
77+ Highlight,
88+}
99+1010+// A trait for elements that can receive visual focus
1111+// usually denoted by a focus ring or highlight
1212+pub trait VisualFocus: gpui::Focusable {
1313+ fn focus_style(&self) -> FocusStyle;
1414+}