diff --git a/crates/egui_demo_lib/src/demo/scene.rs b/crates/egui_demo_lib/src/demo/scene.rs index a7d268e1..ba0dc597 100644 --- a/crates/egui_demo_lib/src/demo/scene.rs +++ b/crates/egui_demo_lib/src/demo/scene.rs @@ -11,7 +11,7 @@ pub struct SceneDemo { impl Default for SceneDemo { fn default() -> Self { Self { - widget_gallery: Default::default(), + widget_gallery: widget_gallery::WidgetGallery::default().with_date_button(false), // disable date button so that we don't fail the snapshot test scene_rect: Rect::ZERO, // `egui::Scene` will initialize this to something valid } } diff --git a/crates/egui_demo_lib/src/demo/widget_gallery.rs b/crates/egui_demo_lib/src/demo/widget_gallery.rs index cfe74689..c51a9efd 100644 --- a/crates/egui_demo_lib/src/demo/widget_gallery.rs +++ b/crates/egui_demo_lib/src/demo/widget_gallery.rs @@ -22,6 +22,8 @@ pub struct WidgetGallery { #[cfg(feature = "chrono")] #[cfg_attr(feature = "serde", serde(skip))] date: Option, + + with_date_button: bool, } impl Default for WidgetGallery { @@ -38,10 +40,23 @@ impl Default for WidgetGallery { animate_progress_bar: false, #[cfg(feature = "chrono")] date: None, + #[cfg(feature = "chrono")] + with_date_button: true, } } } +impl WidgetGallery { + #[inline] + pub fn with_date_button(mut self, _with_date_button: bool) -> Self { + #[cfg(feature = "chrono")] + { + self.with_date_button = _with_date_button; + } + self + } +} + impl crate::Demo for WidgetGallery { fn name(&self) -> &'static str { "🗄 Widget Gallery" @@ -124,6 +139,8 @@ impl WidgetGallery { animate_progress_bar, #[cfg(feature = "chrono")] date, + #[cfg(feature = "chrono")] + with_date_button, } = self; ui.add(doc_link_label("Label", "label")); @@ -226,7 +243,7 @@ impl WidgetGallery { ui.end_row(); #[cfg(feature = "chrono")] - { + if *with_date_button { let date = date.get_or_insert_with(|| chrono::offset::Utc::now().date_naive()); ui.add(doc_link_label_with_crate( "egui_extras", diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Scene.png b/crates/egui_demo_lib/tests/snapshots/demos/Scene.png index d9f483ec..ae1d6acf 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Scene.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Scene.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d076f5365bfa87b7e61d3808b8b9b367157ea6e55ccf665720cbd2237d53793d -size 35563 +oid sha256:93f2bf32b0607b56a9eebefdc07b55d66988251eeb0ccf7799c2836281d5d5fb +size 35573