diff --git a/crates/egui_extras/src/datepicker/button.rs b/crates/egui_extras/src/datepicker/button.rs index a81747ff..839adebf 100644 --- a/crates/egui_extras/src/datepicker/button.rs +++ b/crates/egui_extras/src/datepicker/button.rs @@ -17,6 +17,7 @@ pub struct DatePickerButton<'a> { calendar_week: bool, show_icon: bool, format: String, + highlight_weekends: bool, } impl<'a> DatePickerButton<'a> { @@ -30,6 +31,7 @@ impl<'a> DatePickerButton<'a> { calendar_week: true, show_icon: true, format: "%Y-%m-%d".to_owned(), + highlight_weekends: true, } } @@ -83,6 +85,13 @@ impl<'a> DatePickerButton<'a> { self.format = format.into(); self } + + /// Highlight weekend days. (Default: true) + #[inline] + pub fn highlight_weekends(mut self, highlight_weekends: bool) -> Self { + self.highlight_weekends = highlight_weekends; + self + } } impl<'a> Widget for DatePickerButton<'a> { @@ -148,6 +157,7 @@ impl<'a> Widget for DatePickerButton<'a> { arrows: self.arrows, calendar: self.calendar, calendar_week: self.calendar_week, + highlight_weekends: self.highlight_weekends, } .draw(ui) }) diff --git a/crates/egui_extras/src/datepicker/popup.rs b/crates/egui_extras/src/datepicker/popup.rs index a787d3c5..c5bd41d5 100644 --- a/crates/egui_extras/src/datepicker/popup.rs +++ b/crates/egui_extras/src/datepicker/popup.rs @@ -33,6 +33,7 @@ pub(crate) struct DatePickerPopup<'a> { pub arrows: bool, pub calendar: bool, pub calendar_week: bool, + pub highlight_weekends: bool, } impl<'a> DatePickerPopup<'a> { @@ -304,8 +305,9 @@ impl<'a> DatePickerPopup<'a> { && popup_state.day == day.day() { ui.visuals().selection.bg_fill - } else if day.weekday() == Weekday::Sat - || day.weekday() == Weekday::Sun + } else if (day.weekday() == Weekday::Sat + || day.weekday() == Weekday::Sun) + && self.highlight_weekends { if ui.visuals().dark_mode { Color32::DARK_RED