1use gpui::{Hsla, WindowContext};
2use theme::ActiveTheme;
3
4/// Sets a color that has a consistent meaning across all themes.
5#[derive(Debug, Default, PartialEq, Copy, Clone)]
6pub enum Color {
7 #[default]
8 Default,
9 Accent,
10 Created,
11 Deleted,
12 Disabled,
13 Error,
14 Hidden,
15 Hint,
16 Info,
17 Modified,
18 Conflict,
19 Ignored,
20 Muted,
21 Placeholder,
22 Player(u32),
23 Selected,
24 Success,
25 Warning,
26}
27
28impl Color {
29 pub fn color(&self, cx: &WindowContext) -> Hsla {
30 match self {
31 Color::Default => cx.theme().colors().text,
32 Color::Muted => cx.theme().colors().text_muted,
33 Color::Created => cx.theme().status().created,
34 Color::Modified => cx.theme().status().modified,
35 Color::Conflict => cx.theme().status().conflict,
36 Color::Ignored => cx.theme().status().ignored,
37 Color::Deleted => cx.theme().status().deleted,
38 Color::Disabled => cx.theme().colors().text_disabled,
39 Color::Hidden => cx.theme().status().hidden,
40 Color::Hint => cx.theme().status().hint,
41 Color::Info => cx.theme().status().info,
42 Color::Placeholder => cx.theme().colors().text_placeholder,
43 Color::Accent => cx.theme().colors().text_accent,
44 Color::Player(i) => cx.theme().styles.player.color_for_participant(*i).cursor,
45 Color::Error => cx.theme().status().error,
46 Color::Selected => cx.theme().colors().text_accent,
47 Color::Success => cx.theme().status().success,
48 Color::Warning => cx.theme().status().warning,
49 }
50 }
51}