diff options
author | metamuffin <yvchraiqi@protonmail.com> | 2022-08-17 20:51:05 +0200 |
---|---|---|
committer | metamuffin <yvchraiqi@protonmail.com> | 2022-08-17 20:51:05 +0200 |
commit | 136b93291ce3e14b1f38364b467adb764d0eb792 (patch) | |
tree | e53c9990bd9a66c079ac8f26c97b13170509a39a | |
parent | 8042ecfca4e3a731742b8f486253dc56c2bb2a24 (diff) | |
download | karlender-136b93291ce3e14b1f38364b467adb764d0eb792.tar karlender-136b93291ce3e14b1f38364b467adb764d0eb792.tar.bz2 karlender-136b93291ce3e14b1f38364b467adb764d0eb792.tar.zst |
fix week view
-rw-r--r-- | karlgui/src/globals.rs | 2 | ||||
-rw-r--r-- | karlgui/src/views/calendar.rs | 37 |
2 files changed, 24 insertions, 15 deletions
diff --git a/karlgui/src/globals.rs b/karlgui/src/globals.rs index 48af280..fca2e86 100644 --- a/karlgui/src/globals.rs +++ b/karlgui/src/globals.rs @@ -73,7 +73,7 @@ impl Globals { self.client.send_sync(ServerboundPacket::ListInstances { task, range: Some(start.timestamp())..Some(end.timestamp()), - limit: 100, + limit: 4069, }); &None } diff --git a/karlgui/src/views/calendar.rs b/karlgui/src/views/calendar.rs index 1e869af..6bec067 100644 --- a/karlgui/src/views/calendar.rs +++ b/karlgui/src/views/calendar.rs @@ -28,8 +28,8 @@ impl Calendar { .column(Size::exact(50.0)) .columns(Size::remainder(), 7) .header(50.0, |mut tr| { + tr.col(|_| {}); for d in 0..7 { - tr.col(|_| {}); tr.col(|ui| { ui.heading(weekday_to_str( (start_dt + Duration::days(d as i64)) @@ -44,9 +44,9 @@ impl Calendar { .body(|mut tb| { tb.row(height, |mut tr| { tr.col(|ui| { + let (response, p) = + ui.allocate_painter(Vec2::new(50.0, height), Sense::hover()); for h in 0..24 { - let (response, p) = - ui.allocate_painter(Vec2::new(50.0, height), Sense::hover()); p.text( response.rect.min + Vec2::new(0.0, h as f32 / 24.0 * height), egui::Align2::LEFT_TOP, @@ -90,23 +90,32 @@ impl Calendar { + (r.end.minute() as f32 / 60.0)) / 24.0 * height; + let rect = Rect::from_two_pos( + rect.min + Vec2::new(0.0, rect_start), + rect.min + Vec2::new(10.0, rect_end), + ); + + if let Some(p) = response.hover_pos() { + if rect.contains(p) { + response.clone().on_hover_ui_at_pointer(|ui| { + ui.heading(&task.name); + ui.label(&format!( + "from {} to {}", + r.start, r.end + )); + if let Some(d) = &task.description { + ui.label(d); + } + }); + } + } ui.painter().rect( - Rect::from_two_pos( - rect.min + Vec2::new(0.0, rect_start), - rect.min + Vec2::new(10.0, rect_end), - ), + rect, 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); - } - }); } }); }); |