| 1 | use egui::Color32; |
| 2 | |
| 3 | pub struct CatppuccinMocha; |
| 4 | |
| 5 | impl CatppuccinMocha { |
| 6 | |
| 7 | pub const BASE: Color32 = Color32::from_rgb(30, 30, 46); |
| 8 | pub const MANTLE: Color32 = Color32::from_rgb(24, 24, 37); |
| 9 | pub const CRUST: Color32 = Color32::from_rgb(17, 17, 27); |
| 10 | pub const SURFACE0: Color32 = Color32::from_rgb(49, 50, 68); |
| 11 | pub const SURFACE1: Color32 = Color32::from_rgb(69, 71, 90); |
| 12 | pub const SURFACE2: Color32 = Color32::from_rgb(88, 91, 112); |
| 13 | pub const OVERLAY0: Color32 = Color32::from_rgb(108, 112, 134); |
| 14 | pub const OVERLAY1: Color32 = Color32::from_rgb(127, 132, 156); |
| 15 | pub const TEXT: Color32 = Color32::from_rgb(205, 214, 244); |
| 16 | pub const SUBTEXT0: Color32 = Color32::from_rgb(166, 173, 200); |
| 17 | pub const SUBTEXT1: Color32 = Color32::from_rgb(186, 194, 222); |
| 18 | |
| 19 | |
| 20 | pub const BLUE: Color32 = Color32::from_rgb(137, 180, 250); |
| 21 | pub const GREEN: Color32 = Color32::from_rgb(166, 227, 161); |
| 22 | pub const PEACH: Color32 = Color32::from_rgb(250, 179, 135); |
| 23 | pub const MAUVE: Color32 = Color32::from_rgb(203, 166, 247); |
| 24 | pub const RED: Color32 = Color32::from_rgb(243, 139, 168); |
| 25 | pub const YELLOW: Color32 = Color32::from_rgb(249, 226, 175); |
| 26 | pub const TEAL: Color32 = Color32::from_rgb(148, 226, 213); |
| 27 | pub const LAVENDER: Color32 = Color32::from_rgb(180, 190, 254); |
| 28 | pub const FLAMINGO: Color32 = Color32::from_rgb(242, 205, 205); |
| 29 | pub const ROSEWATER: Color32 = Color32::from_rgb(245, 224, 220); |
| 30 | pub const SKY: Color32 = Color32::from_rgb(137, 220, 235); |
| 31 | pub const SAPPHIRE: Color32 = Color32::from_rgb(116, 199, 236); |
| 32 | pub const MAROON: Color32 = Color32::from_rgb(235, 160, 172); |
| 33 | pub const PINK: Color32 = Color32::from_rgb(245, 194, 231); |
| 34 | |
| 35 | pub fn apply(ctx: &egui::Context) { |
| 36 | let mut style = (*ctx.style()).clone(); |
| 37 | let visuals = &mut style.visuals; |
| 38 | |
| 39 | visuals.dark_mode = true; |
| 40 | visuals.override_text_color = Some(Self::TEXT); |
| 41 | visuals.panel_fill = Self::BASE; |
| 42 | visuals.window_fill = Self::BASE; |
| 43 | visuals.extreme_bg_color = Self::CRUST; |
| 44 | visuals.faint_bg_color = Self::MANTLE; |
| 45 | visuals.code_bg_color = Self::SURFACE0; |
| 46 | |
| 47 | visuals.widgets.noninteractive.bg_fill = Self::BASE; |
| 48 | visuals.widgets.noninteractive.fg_stroke.color = Self::SUBTEXT0; |
| 49 | visuals.widgets.noninteractive.bg_stroke.color = Self::SURFACE1; |
| 50 | |
| 51 | visuals.widgets.inactive.bg_fill = Self::SURFACE0; |
| 52 | visuals.widgets.inactive.fg_stroke.color = Self::TEXT; |
| 53 | visuals.widgets.inactive.bg_stroke.color = Self::SURFACE1; |
| 54 | |
| 55 | visuals.widgets.hovered.bg_fill = Self::SURFACE1; |
| 56 | visuals.widgets.hovered.fg_stroke.color = Self::TEXT; |
| 57 | visuals.widgets.hovered.bg_stroke.color = Self::BLUE; |
| 58 | |
| 59 | visuals.widgets.active.bg_fill = Self::SURFACE2; |
| 60 | visuals.widgets.active.fg_stroke.color = Self::TEXT; |
| 61 | visuals.widgets.active.bg_stroke.color = Self::BLUE; |
| 62 | |
| 63 | visuals.selection.bg_fill = Color32::from_rgba_premultiplied(137, 180, 250, 40); |
| 64 | visuals.selection.stroke.color = Self::BLUE; |
| 65 | |
| 66 | visuals.hyperlink_color = Self::BLUE; |
| 67 | visuals.warn_fg_color = Self::YELLOW; |
| 68 | visuals.error_fg_color = Self::RED; |
| 69 | |
| 70 | visuals.window_stroke.color = Self::SURFACE1; |
| 71 | visuals.window_shadow.color = Color32::from_rgba_premultiplied(0, 0, 0, 60); |
| 72 | |
| 73 | ctx.set_style(style); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | pub fn type_color(type_name: &str) -> Color32 { |
| 78 | match type_name { |
| 79 | "i64" | "u64" | "f64" => CatppuccinMocha::PEACH, |
| 80 | "String" => CatppuccinMocha::GREEN, |
| 81 | "bool" => CatppuccinMocha::MAUVE, |
| 82 | "null" | "None" => CatppuccinMocha::OVERLAY0, |
| 83 | s if s.starts_with("Vec<") => CatppuccinMocha::YELLOW, |
| 84 | s if s.starts_with("Option<") || s.ends_with("?") => CatppuccinMocha::FLAMINGO, |
| 85 | "Mixed" => CatppuccinMocha::YELLOW, |
| 86 | s if s.contains("DateTime") || s.contains("Date") || s.contains("Time") => { |
| 87 | CatppuccinMocha::BLUE |
| 88 | } |
| 89 | _ => CatppuccinMocha::LAVENDER, |
| 90 | } |
| 91 | } |