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 {
/// 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")