|
| 1 | +//! Theme Configuration |
| 2 | +//! |
| 3 | +//! Custom fonts and dark theme for professional DAW look |
| 4 | +
|
| 5 | +use eframe::egui::{self, Color32, FontData, FontDefinitions, FontFamily, Rounding, Style, Visuals}; |
| 6 | + |
| 7 | +/// Setup custom fonts for the DAW |
| 8 | +pub fn setup_custom_fonts(ctx: &egui::Context) { |
| 9 | + let mut fonts = FontDefinitions::default(); |
| 10 | + |
| 11 | + // You can add custom fonts here if needed |
| 12 | + // For now, we'll use the default fonts with adjusted sizes |
| 13 | + |
| 14 | + // Example of how to add a custom font: |
| 15 | + // fonts.font_data.insert( |
| 16 | + // "inter".to_owned(), |
| 17 | + // FontData::from_static(include_bytes!("../assets/fonts/Inter-Regular.ttf")), |
| 18 | + // ); |
| 19 | + // fonts.families.get_mut(&FontFamily::Proportional).unwrap() |
| 20 | + // .insert(0, "inter".to_owned()); |
| 21 | + |
| 22 | + ctx.set_fonts(fonts); |
| 23 | +} |
| 24 | + |
| 25 | +/// Setup dark theme optimized for DAW workflow |
| 26 | +pub fn setup_dark_theme(ctx: &egui::Context) { |
| 27 | + let mut style = Style::default(); |
| 28 | + |
| 29 | + // Dark background colors |
| 30 | + let bg_dark = Color32::from_rgb(25, 25, 28); |
| 31 | + let bg_medium = Color32::from_rgb(35, 35, 40); |
| 32 | + let bg_light = Color32::from_rgb(45, 45, 50); |
| 33 | + let bg_widget = Color32::from_rgb(55, 55, 60); |
| 34 | + |
| 35 | + // Accent colors |
| 36 | + let accent = Color32::from_rgb(100, 150, 255); |
| 37 | + let accent_hover = Color32::from_rgb(120, 170, 255); |
| 38 | + let accent_active = Color32::from_rgb(80, 130, 235); |
| 39 | + |
| 40 | + // Text colors |
| 41 | + let text_primary = Color32::from_rgb(230, 230, 230); |
| 42 | + let text_secondary = Color32::from_rgb(160, 160, 160); |
| 43 | + let text_disabled = Color32::from_rgb(100, 100, 100); |
| 44 | + |
| 45 | + // Configure visuals |
| 46 | + let visuals = Visuals { |
| 47 | + dark_mode: true, |
| 48 | + |
| 49 | + // Override colors |
| 50 | + override_text_color: Some(text_primary), |
| 51 | + |
| 52 | + // Widget visuals |
| 53 | + widgets: egui::style::Widgets { |
| 54 | + noninteractive: egui::style::WidgetVisuals { |
| 55 | + bg_fill: bg_medium, |
| 56 | + weak_bg_fill: bg_medium, |
| 57 | + bg_stroke: egui::Stroke::new(1.0, Color32::from_rgb(60, 60, 65)), |
| 58 | + rounding: Rounding::same(4.0), |
| 59 | + fg_stroke: egui::Stroke::new(1.0, text_secondary), |
| 60 | + expansion: 0.0, |
| 61 | + }, |
| 62 | + inactive: egui::style::WidgetVisuals { |
| 63 | + bg_fill: bg_widget, |
| 64 | + weak_bg_fill: bg_widget, |
| 65 | + bg_stroke: egui::Stroke::new(1.0, Color32::from_rgb(70, 70, 75)), |
| 66 | + rounding: Rounding::same(4.0), |
| 67 | + fg_stroke: egui::Stroke::new(1.0, text_primary), |
| 68 | + expansion: 0.0, |
| 69 | + }, |
| 70 | + hovered: egui::style::WidgetVisuals { |
| 71 | + bg_fill: Color32::from_rgb(65, 65, 70), |
| 72 | + weak_bg_fill: Color32::from_rgb(65, 65, 70), |
| 73 | + bg_stroke: egui::Stroke::new(1.0, accent_hover), |
| 74 | + rounding: Rounding::same(4.0), |
| 75 | + fg_stroke: egui::Stroke::new(1.0, text_primary), |
| 76 | + expansion: 1.0, |
| 77 | + }, |
| 78 | + active: egui::style::WidgetVisuals { |
| 79 | + bg_fill: accent_active, |
| 80 | + weak_bg_fill: accent_active, |
| 81 | + bg_stroke: egui::Stroke::new(1.0, accent), |
| 82 | + rounding: Rounding::same(4.0), |
| 83 | + fg_stroke: egui::Stroke::new(2.0, text_primary), |
| 84 | + expansion: 1.0, |
| 85 | + }, |
| 86 | + open: egui::style::WidgetVisuals { |
| 87 | + bg_fill: bg_light, |
| 88 | + weak_bg_fill: bg_light, |
| 89 | + bg_stroke: egui::Stroke::new(1.0, Color32::from_rgb(80, 80, 85)), |
| 90 | + rounding: Rounding::same(4.0), |
| 91 | + fg_stroke: egui::Stroke::new(1.0, text_primary), |
| 92 | + expansion: 0.0, |
| 93 | + }, |
| 94 | + }, |
| 95 | + |
| 96 | + // Selection |
| 97 | + selection: egui::style::Selection { |
| 98 | + bg_fill: accent.linear_multiply(0.3), |
| 99 | + stroke: egui::Stroke::new(1.0, accent), |
| 100 | + }, |
| 101 | + |
| 102 | + // Hyperlinks |
| 103 | + hyperlink_color: accent, |
| 104 | + |
| 105 | + // Backgrounds |
| 106 | + faint_bg_color: bg_dark, |
| 107 | + extreme_bg_color: Color32::from_rgb(15, 15, 18), |
| 108 | + code_bg_color: bg_medium, |
| 109 | + |
| 110 | + // Warnings |
| 111 | + warn_fg_color: Color32::from_rgb(255, 200, 50), |
| 112 | + error_fg_color: Color32::from_rgb(255, 80, 80), |
| 113 | + |
| 114 | + // Window |
| 115 | + window_rounding: Rounding::same(6.0), |
| 116 | + window_shadow: egui::epaint::Shadow { |
| 117 | + offset: [0, 4].into(), |
| 118 | + blur: 8.0, |
| 119 | + spread: 0.0, |
| 120 | + color: Color32::from_black_alpha(80), |
| 121 | + }, |
| 122 | + window_fill: bg_medium, |
| 123 | + window_stroke: egui::Stroke::new(1.0, Color32::from_rgb(60, 60, 65)), |
| 124 | + window_highlight_topmost: true, |
| 125 | + |
| 126 | + // Menu |
| 127 | + menu_rounding: Rounding::same(4.0), |
| 128 | + |
| 129 | + // Panel |
| 130 | + panel_fill: bg_dark, |
| 131 | + |
| 132 | + // Popup shadow |
| 133 | + popup_shadow: egui::epaint::Shadow { |
| 134 | + offset: [0, 2].into(), |
| 135 | + blur: 6.0, |
| 136 | + spread: 0.0, |
| 137 | + color: Color32::from_black_alpha(60), |
| 138 | + }, |
| 139 | + |
| 140 | + // Resize corner |
| 141 | + resize_corner_size: 12.0, |
| 142 | + |
| 143 | + // Text cursor |
| 144 | + text_cursor: egui::style::TextCursorStyle { |
| 145 | + stroke: egui::Stroke::new(2.0, accent), |
| 146 | + preview: false, |
| 147 | + blink: true, |
| 148 | + on_duration: 0.5, |
| 149 | + off_duration: 0.5, |
| 150 | + }, |
| 151 | + |
| 152 | + // Clip rect margin |
| 153 | + clip_rect_margin: 3.0, |
| 154 | + |
| 155 | + // Button frame |
| 156 | + button_frame: true, |
| 157 | + |
| 158 | + // Collapsing header frame |
| 159 | + collapsing_header_frame: true, |
| 160 | + |
| 161 | + // Indent |
| 162 | + indent_has_left_vline: true, |
| 163 | + |
| 164 | + // Striped |
| 165 | + striped: false, |
| 166 | + |
| 167 | + // Slider trailing fill |
| 168 | + slider_trailing_fill: true, |
| 169 | + |
| 170 | + // Handle shape |
| 171 | + handle_shape: egui::style::HandleShape::Circle, |
| 172 | + |
| 173 | + // Interact cursor |
| 174 | + interact_cursor: None, |
| 175 | + |
| 176 | + // Image loading spinners |
| 177 | + image_loading_spinners: true, |
| 178 | + |
| 179 | + // Numeric color space |
| 180 | + numeric_color_space: egui::style::NumericColorSpace::GammaByte, |
| 181 | + }; |
| 182 | + |
| 183 | + style.visuals = visuals; |
| 184 | + |
| 185 | + // Spacing |
| 186 | + style.spacing.item_spacing = egui::vec2(8.0, 4.0); |
| 187 | + style.spacing.window_margin = egui::Margin::same(8.0); |
| 188 | + style.spacing.button_padding = egui::vec2(8.0, 4.0); |
| 189 | + style.spacing.indent = 18.0; |
| 190 | + style.spacing.slider_width = 100.0; |
| 191 | + |
| 192 | + // Animation |
| 193 | + style.animation_time = 0.1; |
| 194 | + |
| 195 | + ctx.set_style(style); |
| 196 | +} |
| 197 | + |
| 198 | +/// Color palette for DAW elements |
| 199 | +pub struct DawColors; |
| 200 | + |
| 201 | +impl DawColors { |
| 202 | + // Track colors (for automatic assignment) |
| 203 | + pub const TRACK_COLORS: [Color32; 8] = [ |
| 204 | + Color32::from_rgb(100, 180, 255), // Blue |
| 205 | + Color32::from_rgb(255, 150, 100), // Orange |
| 206 | + Color32::from_rgb(150, 255, 150), // Green |
| 207 | + Color32::from_rgb(255, 150, 200), // Pink |
| 208 | + Color32::from_rgb(200, 150, 255), // Purple |
| 209 | + Color32::from_rgb(255, 255, 150), // Yellow |
| 210 | + Color32::from_rgb(150, 255, 255), // Cyan |
| 211 | + Color32::from_rgb(255, 180, 180), // Salmon |
| 212 | + ]; |
| 213 | + |
| 214 | + // Transport colors |
| 215 | + pub const PLAY: Color32 = Color32::from_rgb(100, 200, 100); |
| 216 | + pub const STOP: Color32 = Color32::from_rgb(200, 200, 200); |
| 217 | + pub const RECORD: Color32 = Color32::from_rgb(255, 80, 80); |
| 218 | + pub const LOOP: Color32 = Color32::from_rgb(100, 180, 255); |
| 219 | + |
| 220 | + // Meter colors |
| 221 | + pub const METER_GREEN: Color32 = Color32::from_rgb(50, 200, 100); |
| 222 | + pub const METER_YELLOW: Color32 = Color32::from_rgb(255, 200, 50); |
| 223 | + pub const METER_RED: Color32 = Color32::from_rgb(255, 50, 50); |
| 224 | + |
| 225 | + // Grid colors |
| 226 | + pub const GRID_BAR: Color32 = Color32::from_rgb(60, 60, 65); |
| 227 | + pub const GRID_BEAT: Color32 = Color32::from_rgb(40, 40, 45); |
| 228 | + pub const PLAYHEAD: Color32 = Color32::from_rgb(255, 100, 100); |
| 229 | + |
| 230 | + pub fn track_color(index: usize) -> Color32 { |
| 231 | + Self::TRACK_COLORS[index % Self::TRACK_COLORS.len()] |
| 232 | + } |
| 233 | + |
| 234 | + pub fn track_color_u32(index: usize) -> u32 { |
| 235 | + let c = Self::track_color(index); |
| 236 | + ((c.r() as u32) << 24) | ((c.g() as u32) << 16) | ((c.b() as u32) << 8) | 0xFF |
| 237 | + } |
| 238 | +} |
0 commit comments