From dae1979dd334ace310b6e3ef02e98281ed7dfb8e Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:37:57 +0900 Subject: [PATCH] Add back `Context::set_visuals()` (#5100) My opinion is, it would be better to keep `Context::set_visuals()` so that you don't get confused. * Related #4744 --- crates/egui/src/context.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 13f1d7c4453..c8875dc3bf0 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1869,6 +1869,19 @@ impl Context { self.style_mut_of(theme, |style| style.visuals = visuals); } + /// The [`crate::Visuals`] used by all subsequent windows, panels etc. + /// + /// You can also use [`Ui::visuals_mut`] to change the visuals of a single [`Ui`]. + /// + /// Example: + /// ``` + /// # let mut ctx = egui::Context::default(); + /// ctx.set_visuals(egui::Visuals { panel_fill: egui::Color32::RED, ..Default::default() }); + /// ``` + pub fn set_visuals(&self, visuals: crate::Visuals) { + self.style_mut_of(self.theme(), |style| style.visuals = visuals); + } + /// The number of physical pixels for each logical point. /// /// This is calculated as [`Self::zoom_factor`] * [`Self::native_pixels_per_point`]