Skip to content

Commit

Permalink
Expose, add to widget gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
bash committed Jul 8, 2024
1 parent ecda534 commit ff1c567
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions crates/egui/src/widgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,6 +41,7 @@ pub use self::{
slider::{Slider, SliderOrientation},
spinner::Spinner,
text_edit::{TextBuffer, TextEdit},
theme_switch::ThemeSwitch,
};

// ----------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions crates/egui_demo_lib/src/demo/widget_gallery.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use egui::{ThemePreference, ThemeSwitch};

#[derive(Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
enum Enum {
Expand All @@ -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))]
Expand All @@ -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,
}
Expand Down Expand Up @@ -119,6 +123,7 @@ impl WidgetGallery {
animate_progress_bar,
#[cfg(feature = "chrono")]
date,
theme,
} = self;

ui.add(doc_link_label("Label", "label"));
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ff1c567

Please sign in to comment.