prelude.rs

 1pub use gpui::{
 2    div, Element, ElementId, InteractiveElement, ParentElement, RenderOnce, SharedString, Styled,
 3    ViewContext, WindowContext,
 4};
 5
 6pub use crate::StyledExt;
 7pub use crate::{ButtonVariant, Color};
 8pub use theme::ActiveTheme;
 9
10use strum::EnumIter;
11
12#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]
13pub enum IconSide {
14    #[default]
15    Left,
16    Right,
17}
18
19#[derive(Default, PartialEq, Copy, Clone, EnumIter, strum::Display)]
20pub enum InteractionState {
21    /// An element that is enabled and not hovered, active, focused, or disabled.
22    ///
23    /// This is often referred to as the "default" state.
24    #[default]
25    Enabled,
26    /// An element that is hovered.
27    Hovered,
28    /// An element has an active mouse down or touch start event on it.
29    Active,
30    /// An element that is focused using the keyboard.
31    Focused,
32    /// An element that is disabled.
33    Disabled,
34    /// A toggleable element that is selected, like the active button in a
35    /// button toggle group.
36    Selected,
37}
38
39impl InteractionState {
40    pub fn if_enabled(&self, enabled: bool) -> Self {
41        if enabled {
42            *self
43        } else {
44            InteractionState::Disabled
45        }
46    }
47}
48
49#[derive(Debug, Default, PartialEq, Eq, Hash, Clone, Copy)]
50pub enum Selection {
51    #[default]
52    Unselected,
53    Indeterminate,
54    Selected,
55}
56
57impl Selection {
58    pub fn inverse(&self) -> Self {
59        match self {
60            Self::Unselected | Self::Indeterminate => Self::Selected,
61            Self::Selected => Self::Unselected,
62        }
63    }
64}