Skip to content

Commit

Permalink
Remove date button from Scene demo, so as not to fail tests each day (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk authored Jan 30, 2025
1 parent ee5f0d6 commit 04fca9c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
19 changes: 18 additions & 1 deletion crates/egui_demo_lib/src/demo/widget_gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub struct WidgetGallery {
#[cfg(feature = "chrono")]
#[cfg_attr(feature = "serde", serde(skip))]
date: Option<chrono::NaiveDate>,

with_date_button: bool,
}

impl Default for WidgetGallery {
Expand All @@ -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"
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_demo_lib/tests/snapshots/demos/Scene.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 04fca9c

Please sign in to comment.