fix incorrect stacking of overlapping events from multiple calendars
sort the event collection after adding a calendar, as the drawing functions rely on the event collection to be sorted by begin date Signed-off-by: Fabrizio Iannetti <fabrizio.iannetti@gmail.com>
This commit is contained in:
parent
ab28f9227e
commit
d5b9799618
@ -95,6 +95,10 @@ impl EventsCollection {
|
||||
}
|
||||
events_in_day
|
||||
}
|
||||
|
||||
pub fn sort(&mut self) {
|
||||
self.events.sort_by_key(|event| event.begin);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EventsCollection {
|
||||
|
@ -39,5 +39,7 @@ pub fn load_calendar(calendar_path: &std::path::Path, events: &mut EventsCollect
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
events.sort();
|
||||
}
|
||||
|
||||
|
@ -131,17 +131,20 @@ fn render_events_in_row(
|
||||
// update event bars
|
||||
for cell in row_grid {
|
||||
ev_y = y;
|
||||
println!("col={}", cell.pos_x);
|
||||
for ev_bar in ev_bars.iter_mut() {
|
||||
if ev_bar.ev.begin == current_day || (ev_bar.ev.begin < first_day && current_day == first_day) {
|
||||
// start of event
|
||||
ev_bar.bounds.x = cell.x;
|
||||
ev_bar.bounds.y = ev_y;
|
||||
println!("start[{}] y={}", ev_bar.ev.text, ev_y);
|
||||
}
|
||||
if ev_bar.ev.end == current_day {
|
||||
// end of event -> set width
|
||||
ev_bar.bounds.width = cell.x + cell.width - ev_bar.bounds.x;
|
||||
}
|
||||
if ev_bar.ev.is_in_day(current_day) {
|
||||
println!("ev_y {}->{}", ev_y, ev_y+ ev_height);
|
||||
ev_y += ev_height;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user