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