feat: add clear color method and update theme background for macOS dark mode

This commit is contained in:
Jan Kammerath committed 2026-10-28 11:13:16 +01:00
1 parent bff57d7f5c
commit d4fe0cb27b
2 files changed
+19 -3

No files matched your search

+14
View File
@@ -346,6 +346,10 @@ impl eframe::App for BogusMipsApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
self.ui(ctx);
}
fn clear_color(&self, _visuals: &egui::Visuals) -> [f32; 4] {
theme::BACKGROUND.to_normalized_gamma_f32()
}
}
impl BogusMipsApp {
@@ -435,6 +439,16 @@ mod tests {
let _ = ctx.run(egui::RawInput::default(), |ctx| app.ui(ctx));
}
#[test]
fn uses_macos_dark_background() {
let ctx = egui::Context::default();
let _app = BogusMipsApp::with_context(&ctx, None);
let visuals = ctx.style().visuals.clone();
let expected = egui::Color32::from_rgb(0x2f, 0x31, 0x33);
assert_eq!(visuals.panel_fill, expected);
assert_eq!(visuals.window_fill, expected);
}
#[test]
fn renders_welcome_screen() {
let ctx = egui::Context::default();
+5 -3
View File
@@ -1,11 +1,13 @@
use eframe::egui::{self, Color32};
/// Window and panel background, matching macOS dark mode.
pub const BACKGROUND: Color32 = Color32::from_rgb(0x2f, 0x31, 0x33);
pub fn apply_dark(ctx: &egui::Context) {
ctx.set_theme(egui::Theme::Dark);
ctx.style_mut_of(egui::Theme::Dark, |style| {
let bg = Color32::from_rgb(0x1e, 0x1e, 0x22);
style.visuals.panel_fill = bg;
style.visuals.window_fill = bg;
style.visuals.panel_fill = BACKGROUND;
style.visuals.window_fill = BACKGROUND;
style.visuals.override_text_color = Some(Color32::from_rgb(0xe6, 0xe6, 0xe6));
});
}