color.rs

 1use gpui::{Hsla, WindowContext};
 2use theme::ActiveTheme;
 3
 4#[derive(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    Muted,
17    Placeholder,
18    Player(u32),
19    Selected,
20    Success,
21    Warning,
22}
23
24impl Color {
25    pub fn color(&self, cx: &WindowContext) -> Hsla {
26        match self {
27            Color::Default => cx.theme().colors().text,
28            Color::Muted => cx.theme().colors().text_muted,
29            Color::Created => cx.theme().status().created,
30            Color::Modified => cx.theme().status().modified,
31            Color::Deleted => cx.theme().status().deleted,
32            Color::Disabled => cx.theme().colors().text_disabled,
33            Color::Hidden => cx.theme().status().hidden,
34            Color::Info => cx.theme().status().info,
35            Color::Placeholder => cx.theme().colors().text_placeholder,
36            Color::Accent => cx.theme().colors().text_accent,
37            Color::Player(i) => cx.theme().styles.player.0[i.clone() as usize].cursor,
38            Color::Error => cx.theme().status().error,
39            Color::Selected => cx.theme().colors().text_accent,
40            Color::Success => cx.theme().status().success,
41            Color::Warning => cx.theme().status().warning,
42        }
43    }
44}