Browse Source

In the options ui, show only the currently selected theme

* Closes https://github.com/emilk/egui/pull/5101
pull/4875/merge
Emil Ernerfeldt 2 months ago
parent
commit
ce3911bc0d
  1. 15
      crates/egui/src/memory/mod.rs

15
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")

Loading…
Cancel
Save