pub struct DatePicker<'a, Tz>{ /* private fields */ }
Expand description
Default values of fields are:
- sunday_first:
false
- movable:
false
- format_string:
"%Y-%m-%d"
- weekend_func:
date.weekday() == Weekday::Sat || date.weekday() == Weekday::Sun
Implementations§
Source§impl<'a, Tz> DatePicker<'a, Tz>
impl<'a, Tz> DatePicker<'a, Tz>
Sourcepub fn new<T: Hash>(id: T, date: &'a mut Date<Tz>) -> Self
pub fn new<T: Hash>(id: T, date: &'a mut Date<Tz>) -> Self
Create new date picker with unique id and mutable reference to date.
Examples found in repository?
examples/simple.rs (line 30)
25 fn update(&mut self, ctx: &egui::CtxRef, _frame: &epi::Frame) {
26 // ctx.set_debug_on_hover(true);
27 egui::CentralPanel::default().show(ctx, |ui| {
28 egui::Grid::new("exaamples_grid").show(ui, |ui| {
29 ui.label("Default");
30 ui.add(DatePicker::new("default", &mut self.date));
31 ui.end_row();
32 ui.label("Sunday first");
33 ui.add(DatePicker::new("sundayfirst", &mut self.date).sunday_first(true));
34 ui.end_row();
35 ui.label("Movable popup");
36 ui.add(DatePicker::new("movable", &mut self.date).movable(true));
37 ui.end_row();
38 ui.label("Different format");
39 ui.add(DatePicker::new("differentformat", &mut self.date).date_format(&"%d/%m/%Y"));
40 ui.end_row();
41 ui.label("Disable weekend highlight");
42 ui.add(
43 DatePicker::new("noweekendhighlight", &mut self.date).highlight_weekend(false),
44 );
45 ui.end_row();
46 ui.label("Different weekend color");
47 ui.add(
48 DatePicker::new("differentweekendcolor", &mut self.date)
49 .highlight_weekend_color(Color32::from_rgb(0, 196, 0)),
50 );
51 ui.end_row();
52 ui.label("Different weekend days, i.e. holidays, Christmas, etc");
53 ui.add(
54 DatePicker::new("differentweekenddays", &mut self.date)
55 .weekend_days(|date| date.day() % 2 == 0),
56 );
57 ui.end_row();
58 });
59 });
60 }
Sourcepub fn sunday_first(self, flag: bool) -> Self
pub fn sunday_first(self, flag: bool) -> Self
If flag is set to true then first day in calendar will be sunday otherwise monday. Default is false
Examples found in repository?
examples/simple.rs (line 33)
25 fn update(&mut self, ctx: &egui::CtxRef, _frame: &epi::Frame) {
26 // ctx.set_debug_on_hover(true);
27 egui::CentralPanel::default().show(ctx, |ui| {
28 egui::Grid::new("exaamples_grid").show(ui, |ui| {
29 ui.label("Default");
30 ui.add(DatePicker::new("default", &mut self.date));
31 ui.end_row();
32 ui.label("Sunday first");
33 ui.add(DatePicker::new("sundayfirst", &mut self.date).sunday_first(true));
34 ui.end_row();
35 ui.label("Movable popup");
36 ui.add(DatePicker::new("movable", &mut self.date).movable(true));
37 ui.end_row();
38 ui.label("Different format");
39 ui.add(DatePicker::new("differentformat", &mut self.date).date_format(&"%d/%m/%Y"));
40 ui.end_row();
41 ui.label("Disable weekend highlight");
42 ui.add(
43 DatePicker::new("noweekendhighlight", &mut self.date).highlight_weekend(false),
44 );
45 ui.end_row();
46 ui.label("Different weekend color");
47 ui.add(
48 DatePicker::new("differentweekendcolor", &mut self.date)
49 .highlight_weekend_color(Color32::from_rgb(0, 196, 0)),
50 );
51 ui.end_row();
52 ui.label("Different weekend days, i.e. holidays, Christmas, etc");
53 ui.add(
54 DatePicker::new("differentweekenddays", &mut self.date)
55 .weekend_days(|date| date.day() % 2 == 0),
56 );
57 ui.end_row();
58 });
59 });
60 }
Sourcepub fn movable(self, flag: bool) -> Self
pub fn movable(self, flag: bool) -> Self
If flag is set to true then date picker popup will be movable. Default is false
Examples found in repository?
examples/simple.rs (line 36)
25 fn update(&mut self, ctx: &egui::CtxRef, _frame: &epi::Frame) {
26 // ctx.set_debug_on_hover(true);
27 egui::CentralPanel::default().show(ctx, |ui| {
28 egui::Grid::new("exaamples_grid").show(ui, |ui| {
29 ui.label("Default");
30 ui.add(DatePicker::new("default", &mut self.date));
31 ui.end_row();
32 ui.label("Sunday first");
33 ui.add(DatePicker::new("sundayfirst", &mut self.date).sunday_first(true));
34 ui.end_row();
35 ui.label("Movable popup");
36 ui.add(DatePicker::new("movable", &mut self.date).movable(true));
37 ui.end_row();
38 ui.label("Different format");
39 ui.add(DatePicker::new("differentformat", &mut self.date).date_format(&"%d/%m/%Y"));
40 ui.end_row();
41 ui.label("Disable weekend highlight");
42 ui.add(
43 DatePicker::new("noweekendhighlight", &mut self.date).highlight_weekend(false),
44 );
45 ui.end_row();
46 ui.label("Different weekend color");
47 ui.add(
48 DatePicker::new("differentweekendcolor", &mut self.date)
49 .highlight_weekend_color(Color32::from_rgb(0, 196, 0)),
50 );
51 ui.end_row();
52 ui.label("Different weekend days, i.e. holidays, Christmas, etc");
53 ui.add(
54 DatePicker::new("differentweekenddays", &mut self.date)
55 .weekend_days(|date| date.day() % 2 == 0),
56 );
57 ui.end_row();
58 });
59 });
60 }
Sourcepub fn date_format(self, new_format: &impl ToString) -> Self
pub fn date_format(self, new_format: &impl ToString) -> Self
Set date format. See the chrono::format::strftime for the specification.
Examples found in repository?
examples/simple.rs (line 39)
25 fn update(&mut self, ctx: &egui::CtxRef, _frame: &epi::Frame) {
26 // ctx.set_debug_on_hover(true);
27 egui::CentralPanel::default().show(ctx, |ui| {
28 egui::Grid::new("exaamples_grid").show(ui, |ui| {
29 ui.label("Default");
30 ui.add(DatePicker::new("default", &mut self.date));
31 ui.end_row();
32 ui.label("Sunday first");
33 ui.add(DatePicker::new("sundayfirst", &mut self.date).sunday_first(true));
34 ui.end_row();
35 ui.label("Movable popup");
36 ui.add(DatePicker::new("movable", &mut self.date).movable(true));
37 ui.end_row();
38 ui.label("Different format");
39 ui.add(DatePicker::new("differentformat", &mut self.date).date_format(&"%d/%m/%Y"));
40 ui.end_row();
41 ui.label("Disable weekend highlight");
42 ui.add(
43 DatePicker::new("noweekendhighlight", &mut self.date).highlight_weekend(false),
44 );
45 ui.end_row();
46 ui.label("Different weekend color");
47 ui.add(
48 DatePicker::new("differentweekendcolor", &mut self.date)
49 .highlight_weekend_color(Color32::from_rgb(0, 196, 0)),
50 );
51 ui.end_row();
52 ui.label("Different weekend days, i.e. holidays, Christmas, etc");
53 ui.add(
54 DatePicker::new("differentweekenddays", &mut self.date)
55 .weekend_days(|date| date.day() % 2 == 0),
56 );
57 ui.end_row();
58 });
59 });
60 }
Sourcepub fn highlight_weekend(self, highlight: bool) -> Self
pub fn highlight_weekend(self, highlight: bool) -> Self
If highlight is true then weekends text color will be weekend_color
instead default text
color.
Examples found in repository?
examples/simple.rs (line 43)
25 fn update(&mut self, ctx: &egui::CtxRef, _frame: &epi::Frame) {
26 // ctx.set_debug_on_hover(true);
27 egui::CentralPanel::default().show(ctx, |ui| {
28 egui::Grid::new("exaamples_grid").show(ui, |ui| {
29 ui.label("Default");
30 ui.add(DatePicker::new("default", &mut self.date));
31 ui.end_row();
32 ui.label("Sunday first");
33 ui.add(DatePicker::new("sundayfirst", &mut self.date).sunday_first(true));
34 ui.end_row();
35 ui.label("Movable popup");
36 ui.add(DatePicker::new("movable", &mut self.date).movable(true));
37 ui.end_row();
38 ui.label("Different format");
39 ui.add(DatePicker::new("differentformat", &mut self.date).date_format(&"%d/%m/%Y"));
40 ui.end_row();
41 ui.label("Disable weekend highlight");
42 ui.add(
43 DatePicker::new("noweekendhighlight", &mut self.date).highlight_weekend(false),
44 );
45 ui.end_row();
46 ui.label("Different weekend color");
47 ui.add(
48 DatePicker::new("differentweekendcolor", &mut self.date)
49 .highlight_weekend_color(Color32::from_rgb(0, 196, 0)),
50 );
51 ui.end_row();
52 ui.label("Different weekend days, i.e. holidays, Christmas, etc");
53 ui.add(
54 DatePicker::new("differentweekenddays", &mut self.date)
55 .weekend_days(|date| date.day() % 2 == 0),
56 );
57 ui.end_row();
58 });
59 });
60 }
Sourcepub fn highlight_weekend_color(self, color: Color32) -> Self
pub fn highlight_weekend_color(self, color: Color32) -> Self
Set weekends highlighting color.
Examples found in repository?
examples/simple.rs (line 49)
25 fn update(&mut self, ctx: &egui::CtxRef, _frame: &epi::Frame) {
26 // ctx.set_debug_on_hover(true);
27 egui::CentralPanel::default().show(ctx, |ui| {
28 egui::Grid::new("exaamples_grid").show(ui, |ui| {
29 ui.label("Default");
30 ui.add(DatePicker::new("default", &mut self.date));
31 ui.end_row();
32 ui.label("Sunday first");
33 ui.add(DatePicker::new("sundayfirst", &mut self.date).sunday_first(true));
34 ui.end_row();
35 ui.label("Movable popup");
36 ui.add(DatePicker::new("movable", &mut self.date).movable(true));
37 ui.end_row();
38 ui.label("Different format");
39 ui.add(DatePicker::new("differentformat", &mut self.date).date_format(&"%d/%m/%Y"));
40 ui.end_row();
41 ui.label("Disable weekend highlight");
42 ui.add(
43 DatePicker::new("noweekendhighlight", &mut self.date).highlight_weekend(false),
44 );
45 ui.end_row();
46 ui.label("Different weekend color");
47 ui.add(
48 DatePicker::new("differentweekendcolor", &mut self.date)
49 .highlight_weekend_color(Color32::from_rgb(0, 196, 0)),
50 );
51 ui.end_row();
52 ui.label("Different weekend days, i.e. holidays, Christmas, etc");
53 ui.add(
54 DatePicker::new("differentweekenddays", &mut self.date)
55 .weekend_days(|date| date.day() % 2 == 0),
56 );
57 ui.end_row();
58 });
59 });
60 }
Sourcepub fn weekend_days(self, is_weekend: fn(&Date<Tz>) -> bool) -> Self
pub fn weekend_days(self, is_weekend: fn(&Date<Tz>) -> bool) -> Self
Set function, which will decide if date is a weekend day or not.
Examples found in repository?
examples/simple.rs (line 55)
25 fn update(&mut self, ctx: &egui::CtxRef, _frame: &epi::Frame) {
26 // ctx.set_debug_on_hover(true);
27 egui::CentralPanel::default().show(ctx, |ui| {
28 egui::Grid::new("exaamples_grid").show(ui, |ui| {
29 ui.label("Default");
30 ui.add(DatePicker::new("default", &mut self.date));
31 ui.end_row();
32 ui.label("Sunday first");
33 ui.add(DatePicker::new("sundayfirst", &mut self.date).sunday_first(true));
34 ui.end_row();
35 ui.label("Movable popup");
36 ui.add(DatePicker::new("movable", &mut self.date).movable(true));
37 ui.end_row();
38 ui.label("Different format");
39 ui.add(DatePicker::new("differentformat", &mut self.date).date_format(&"%d/%m/%Y"));
40 ui.end_row();
41 ui.label("Disable weekend highlight");
42 ui.add(
43 DatePicker::new("noweekendhighlight", &mut self.date).highlight_weekend(false),
44 );
45 ui.end_row();
46 ui.label("Different weekend color");
47 ui.add(
48 DatePicker::new("differentweekendcolor", &mut self.date)
49 .highlight_weekend_color(Color32::from_rgb(0, 196, 0)),
50 );
51 ui.end_row();
52 ui.label("Different weekend days, i.e. holidays, Christmas, etc");
53 ui.add(
54 DatePicker::new("differentweekenddays", &mut self.date)
55 .weekend_days(|date| date.day() % 2 == 0),
56 );
57 ui.end_row();
58 });
59 });
60 }
Trait Implementations§
Auto Trait Implementations§
impl<'a, Tz> Freeze for DatePicker<'a, Tz>
impl<'a, Tz> RefUnwindSafe for DatePicker<'a, Tz>
impl<'a, Tz> Send for DatePicker<'a, Tz>
impl<'a, Tz> Sync for DatePicker<'a, Tz>
impl<'a, Tz> Unpin for DatePicker<'a, Tz>
impl<'a, Tz> !UnwindSafe for DatePicker<'a, Tz>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more