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