color.rs

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