In the options ui, show only the currently selected theme

* Closes https://github.com/emilk/egui/pull/5101
This commit is contained in:
Emil Ernerfeldt 2024-09-18 11:13:55 +02:00
parent 4dd89e2052
commit ce3911bc0d
1 changed files with 8 additions and 7 deletions

View File

@ -362,6 +362,8 @@ impl Options {
impl Options { impl Options {
/// Show the options in the ui. /// Show the options in the ui.
pub fn ui(&mut self, ui: &mut crate::Ui) { pub fn ui(&mut self, ui: &mut crate::Ui) {
let theme = self.theme();
let Self { let Self {
dark_style, // covered above dark_style, // covered above
light_style, light_style,
@ -383,6 +385,7 @@ impl Options {
reduce_texture_memory, reduce_texture_memory,
} = self; } = self;
use crate::containers::CollapsingHeader;
use crate::Widget as _; use crate::Widget as _;
CollapsingHeader::new("⚙ Options") CollapsingHeader::new("⚙ Options")
@ -408,18 +411,16 @@ impl Options {
ui.checkbox(reduce_texture_memory, "Reduce texture memory"); ui.checkbox(reduce_texture_memory, "Reduce texture memory");
}); });
use crate::containers::CollapsingHeader;
CollapsingHeader::new("🎑 Style") CollapsingHeader::new("🎑 Style")
.default_open(true) .default_open(true)
.show(ui, |ui| { .show(ui, |ui| {
theme_preference.radio_buttons(ui); theme_preference.radio_buttons(ui);
CollapsingHeader::new("Dark") std::sync::Arc::make_mut(match theme {
.default_open(true) Theme::Dark => dark_style,
.show(ui, |ui| std::sync::Arc::make_mut(dark_style).ui(ui)); Theme::Light => light_style,
CollapsingHeader::new("Light") })
.default_open(true) .ui(ui);
.show(ui, |ui| std::sync::Arc::make_mut(light_style).ui(ui));
}); });
CollapsingHeader::new("✒ Painting") CollapsingHeader::new("✒ Painting")