diff --git a/crates/egui/src/widgets/mod.rs b/crates/egui/src/widgets/mod.rs index 7c1c1287fea2..8dbc8454f1de 100644 --- a/crates/egui/src/widgets/mod.rs +++ b/crates/egui/src/widgets/mod.rs @@ -4,8 +4,6 @@ //! * `ui.add(Label::new("Text").text_color(color::red));` //! * `if ui.add(Button::new("Click me")).clicked() { … }` -use theme_switch::ThemeSwitch; - use crate::*; mod button; @@ -43,6 +41,7 @@ pub use self::{ slider::{Slider, SliderOrientation}, spinner::Spinner, text_edit::{TextBuffer, TextEdit}, + theme_switch::ThemeSwitch, }; // ---------------------------------------------------------------------------- diff --git a/crates/egui_demo_lib/src/demo/widget_gallery.rs b/crates/egui_demo_lib/src/demo/widget_gallery.rs index 2f59c7caee02..1626488ad9b5 100644 --- a/crates/egui_demo_lib/src/demo/widget_gallery.rs +++ b/crates/egui_demo_lib/src/demo/widget_gallery.rs @@ -1,3 +1,5 @@ +use egui::{ThemePreference, ThemeSwitch}; + #[derive(Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] enum Enum { @@ -18,6 +20,7 @@ pub struct WidgetGallery { string: String, color: egui::Color32, animate_progress_bar: bool, + theme: ThemePreference, #[cfg(feature = "chrono")] #[cfg_attr(feature = "serde", serde(skip))] @@ -36,6 +39,7 @@ impl Default for WidgetGallery { string: Default::default(), color: egui::Color32::LIGHT_BLUE.linear_multiply(0.5), animate_progress_bar: false, + theme: ThemePreference::System, #[cfg(feature = "chrono")] date: None, } @@ -119,6 +123,7 @@ impl WidgetGallery { animate_progress_bar, #[cfg(feature = "chrono")] date, + theme, } = self; ui.add(doc_link_label("Label", "label")); @@ -248,6 +253,10 @@ impl WidgetGallery { }); ui.end_row(); + ui.add(doc_link_label("ThemeSwitch", "ThemeSwitch")); + ui.add(ThemeSwitch::new(theme)); + ui.end_row(); + ui.add(doc_link_label_with_crate("egui_plot", "Plot", "plot")); example_plot(ui); ui.end_row();