Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove date button from Scene demo, so as not to fail tests each day #5657

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.