Skip to content

Commit

Permalink
In the options ui, show only the currently selected theme
Browse files Browse the repository at this point in the history
* Closes #5101
  • Loading branch information
emilk committed Sep 18, 2024
1 parent 4dd89e2 commit ce3911b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/egui/src/memory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -383,6 +385,7 @@ impl Options {
reduce_texture_memory,
} = self;

use crate::containers::CollapsingHeader;
use crate::Widget as _;

CollapsingHeader::new("⚙ Options")
Expand All @@ -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")
Expand Down

0 comments on commit ce3911b

Please sign in to comment.