diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index 3b303dce1eee..a8108db3f2c4 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -53,7 +53,7 @@ pub struct CreationContext<'s> { /// The egui Context. /// /// You can use this to customize the look of egui, e.g to call [`egui::Context::set_fonts`], - /// [`egui::Context::set_visuals`] etc. + /// [`egui::Context::set_dark_visuals`] etc. pub egui_ctx: egui::Context, /// Information about the surrounding environment. diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index d9f107c6d6f1..2b3e2930779d 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1625,7 +1625,7 @@ impl Context { self.options(|opt| opt.style().clone()) } - /// Mutate the [`Style`] used by all subsequent windows, panels etc. + /// Mutate the [`Style`]s used by all subsequent windows, panels etc. in both dark and light mode. /// /// Example: /// ``` @@ -1634,30 +1634,93 @@ impl Context { /// style.spacing.item_spacing = egui::vec2(10.0, 20.0); /// }); /// ``` - pub fn style_mut(&self, mutate_style: impl FnOnce(&mut Style)) { - self.options_mut(|opt| mutate_style(std::sync::Arc::make_mut(&mut opt.style))); + pub fn style_mut(&self, mut mutate_style: impl FnMut(&mut Style)) { + self.options_mut(|opt| { + mutate_style(std::sync::Arc::make_mut(&mut opt.dark_style)); + mutate_style(std::sync::Arc::make_mut(&mut opt.light_style)); + }); + } + + /// The [`Style`] used by all subsequent windows, panels etc in dark mode. + pub fn dark_style(&self) -> Arc