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 Info,
16 Modified,
17 Conflict,
18 Ignored,
19 Muted,
20 Placeholder,
21 Player(u32),
22 Selected,
23 Success,
24 Warning,
25}
26
27impl Color {
28 pub fn color(&self, cx: &WindowContext) -> Hsla {
29 match self {
30 Color::Default => cx.theme().colors().text,
31 Color::Muted => cx.theme().colors().text_muted,
32 Color::Created => cx.theme().status().created,
33 Color::Modified => cx.theme().status().modified,
34 Color::Conflict => cx.theme().status().conflict,
35 Color::Ignored => cx.theme().status().ignored,
36 Color::Deleted => cx.theme().status().deleted,
37 Color::Disabled => cx.theme().colors().text_disabled,
38 Color::Hidden => cx.theme().status().hidden,
39 Color::Info => cx.theme().status().info,
40 Color::Placeholder => cx.theme().colors().text_placeholder,
41 Color::Accent => cx.theme().colors().text_accent,
42 Color::Player(i) => cx.theme().styles.player.color_for_participant(*i).cursor,
43 Color::Error => cx.theme().status().error,
44 Color::Selected => cx.theme().colors().text_accent,
45 Color::Success => cx.theme().status().success,
46 Color::Warning => cx.theme().status().warning,
47 }
48 }
49}