aboutsummaryrefslogtreecommitdiff
path: root/karlgui/src/views/calendar.rs
diff options
context:
space:
mode:
Diffstat (limited to 'karlgui/src/views/calendar.rs')
-rw-r--r--karlgui/src/views/calendar.rs136
1 files changed, 71 insertions, 65 deletions
diff --git a/karlgui/src/views/calendar.rs b/karlgui/src/views/calendar.rs
index 0530def..a145f4a 100644
--- a/karlgui/src/views/calendar.rs
+++ b/karlgui/src/views/calendar.rs
@@ -25,77 +25,83 @@ impl Calendar {
let height = 1500.0;
ScrollArea::vertical().show(ui, |ui| {
- ui.horizontal(|ui| {
- ui.vertical(|ui| {
- for h in 0..24 {
- ui.add_sized(
- Vec2::new(50.0, height / 24.0),
- Label::new(&format!("{h:02}:00")),
- );
- }
- });
- for d in 0..7 {
- ScrollArea::horizontal().show(ui, |ui| {
- let time = start_dt + Duration::days(d as i64);
- let time_end = time + Duration::days(1) - Duration::seconds(1);
- let instances_here = instances
- .iter()
- .map(|(id, rs)| {
- (
- id,
- rs.iter()
- .filter(|r| r.overlaps(time..time_end))
- .collect::<Vec<_>>(),
- )
- })
- .filter(|(_, l)| l.len() != 0);
-
- ui.vertical(|ui| {
- ui.heading(weekday_to_str(
- time.date().weekday().num_days_from_monday().into(),
- ));
- ui.horizontal(|ui| {
- for (id, rs) in instances_here {
- let task = g.tasks.get(id).unwrap();
+ StripBuilder::new(ui)
+ .size(Size::exact(50.0))
+ .sizes(Size::remainder(), 7)
+ .horizontal(|mut ui| {
+ ui.cell(|ui| {
+ for h in 0..24 {
+ ui.add_sized(
+ Vec2::new(50.0, height / 24.0),
+ Label::new(&format!("{h:02}:00")),
+ );
+ }
+ });
+ for d in 0..7 {
+ ui.cell(|ui| {
+ let time = start_dt + Duration::days(d as i64);
+ let time_end = time + Duration::days(1) - Duration::seconds(1);
+ let instances_here = instances
+ .iter()
+ .map(|(id, rs)| {
+ (
+ id,
+ rs.iter()
+ .filter(|r| r.overlaps(time..time_end))
+ .collect::<Vec<_>>(),
+ )
+ })
+ .filter(|(_, l)| l.len() != 0);
- let (rect, response) = ui.allocate_exact_size(
- Vec2::new(10.0, height),
- Sense::hover(),
- );
+ ui.vertical(|ui| {
+ ui.heading(weekday_to_str(
+ time.date().weekday().num_days_from_monday().into(),
+ ));
+ ui.horizontal(|ui| {
+ for (id, rs) in instances_here {
+ let task = g.tasks.get(id).unwrap();
- for r in &rs {
- let r = r.start.unwrap_or(time)..r.end.unwrap_or(time_end);
- let rect_start = (r.start.hour() as f32
- + (r.start.minute() as f32 / 60.0))
- / 24.0
- * height;
- let rect_end = (r.end.hour() as f32
- + (r.end.minute() as f32 / 60.0))
- / 24.0
- * height;
- ui.painter().rect(
- Rect::from_two_pos(
- rect.min + Vec2::new(0.0, rect_start),
- rect.min + Vec2::new(10.0, rect_end),
- ),
- 0.0,
- Color32::KHAKI,
- Stroke::new(0.0, Color32::WHITE),
+ let (rect, response) = ui.allocate_exact_size(
+ Vec2::new(10.0, height),
+ Sense::hover(),
);
- }
- response.on_hover_ui_at_pointer(|ui| {
- ui.heading(&task.name);
- if let Some(d) = &task.description {
- ui.label(d);
+ for r in &rs {
+ let r =
+ r.start.unwrap_or(time)..r.end.unwrap_or(time_end);
+ let rect_start = (r.start.hour() as f32
+ + (r.start.minute() as f32 / 60.0))
+ / 24.0
+ * height;
+ let rect_end = (r.end.hour() as f32
+ + (r.end.minute() as f32 / 60.0))
+ / 24.0
+ * height;
+ ui.painter().rect(
+ Rect::from_two_pos(
+ rect.min + Vec2::new(0.0, rect_start),
+ rect.min + Vec2::new(10.0, rect_end),
+ ),
+ 0.0,
+ Color32::KHAKI,
+ Stroke::new(0.0, Color32::WHITE),
+ );
}
- });
- }
- })
+
+ response.on_hover_ui_at_pointer(|ui| {
+ ui.heading(&task.name);
+ if let Some(d) = &task.description {
+ ui.label(d);
+ }
+ });
+ }
+ })
+ });
+ // });
+ // });
});
- });
- }
- });
+ }
+ });
});
// TableBuilder::new(ui)