From ce3911bc0dd9e6bef9e0c858c755b27ec65a7af7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 18 Sep 2024 11:13:55 +0200 Subject: [PATCH] In the options ui, show only the currently selected theme * Closes https://github.com/emilk/egui/pull/5101 --- crates/egui/src/memory/mod.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/egui/src/memory/mod.rs b/crates/egui/src/memory/mod.rs index cf0d2b87..8d7476a2 100644 --- a/crates/egui/src/memory/mod.rs +++ b/crates/egui/src/memory/mod.rs @@ -362,6 +362,8 @@ impl Options { impl Options { /// Show the options in the ui. pub fn ui(&mut self, ui: &mut crate::Ui) { + let theme = self.theme(); + let Self { dark_style, // covered above light_style, @@ -383,6 +385,7 @@ impl Options { reduce_texture_memory, } = self; + use crate::containers::CollapsingHeader; use crate::Widget as _; CollapsingHeader::new("⚙ Options") @@ -408,18 +411,16 @@ impl Options { ui.checkbox(reduce_texture_memory, "Reduce texture memory"); }); - use crate::containers::CollapsingHeader; CollapsingHeader::new("🎑 Style") .default_open(true) .show(ui, |ui| { theme_preference.radio_buttons(ui); - CollapsingHeader::new("Dark") - .default_open(true) - .show(ui, |ui| std::sync::Arc::make_mut(dark_style).ui(ui)); - CollapsingHeader::new("Light") - .default_open(true) - .show(ui, |ui| std::sync::Arc::make_mut(light_style).ui(ui)); + std::sync::Arc::make_mut(match theme { + Theme::Dark => dark_style, + Theme::Light => light_style, + }) + .ui(ui); }); CollapsingHeader::new("✒ Painting")