wip
Signed-off-by: fab <fab@pop-os.localdomain>
This commit is contained in:
parent
753a9406e5
commit
b716741578
@ -24,6 +24,10 @@ impl Event {
|
|||||||
fn is_in_day(&self, day: NaiveDate) -> bool {
|
fn is_in_day(&self, day: NaiveDate) -> bool {
|
||||||
day >= self.begin && day <= self.end
|
day >= self.begin && day <= self.end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn span_days(&self) -> i64 {
|
||||||
|
(self.end - self.begin).num_days()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EventsCollection {
|
pub struct EventsCollection {
|
||||||
|
@ -83,11 +83,12 @@ impl CalendarParams {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
fn render_events_in_day(
|
fn render_events_in_row(
|
||||||
params: &CalendarParams,
|
params: &CalendarParams,
|
||||||
renderer: &mut impl text::Renderer,
|
renderer: &mut impl text::Renderer,
|
||||||
current_day: NaiveDate,
|
first_day: NaiveDate,
|
||||||
day_bounds: Rectangle,
|
num_days: i64,
|
||||||
|
row_bounds: Rectangle,
|
||||||
font_size: f32,
|
font_size: f32,
|
||||||
fg: Color,
|
fg: Color,
|
||||||
content: &str,
|
content: &str,
|
||||||
@ -103,33 +104,38 @@ fn render_events_in_day(
|
|||||||
Shaping::default());
|
Shaping::default());
|
||||||
let ev_height = params.ev_height;
|
let ev_height = params.ev_height;
|
||||||
let mut ev_y: f32 = 0.0;
|
let mut ev_y: f32 = 0.0;
|
||||||
let y = day_bounds.y + params.day_text_margin;
|
let y = row_bounds.y + params.day_text_margin;
|
||||||
for ev_day in events.for_day(current_day) {
|
|
||||||
if day_bounds.height - day_text_size.1 > ev_y + ev_height {
|
let mut event_stack = Vec::new();
|
||||||
let ev_bounds = Rectangle {
|
for i in 0..num_days {
|
||||||
y: y + ev_y + day_text_size.1,
|
let current_day = first_day + Duration::days(i);
|
||||||
height: ev_height,
|
for ev_day in events.for_day(current_day) {
|
||||||
..day_bounds
|
if day_bounds.height - day_text_size.1 > ev_y + ev_height {
|
||||||
};
|
let ev_bounds = Rectangle {
|
||||||
renderer.fill_quad(renderer::Quad {
|
y: y + ev_y + day_text_size.1,
|
||||||
|
height: ev_height,
|
||||||
|
..day_bounds
|
||||||
|
};
|
||||||
|
renderer.fill_quad(renderer::Quad {
|
||||||
|
bounds: ev_bounds,
|
||||||
|
border_radius: 0.0.into(),
|
||||||
|
border_width: 1.0,
|
||||||
|
border_color: params.day_other_month_fg,
|
||||||
|
},
|
||||||
|
params.ev_bg);
|
||||||
|
renderer.fill_text(Text {
|
||||||
|
content: ev_day.text.as_str(),
|
||||||
bounds: ev_bounds,
|
bounds: ev_bounds,
|
||||||
border_radius: 0.0.into(),
|
size: params.ev_fontsize,
|
||||||
border_width: 1.0,
|
line_height: LineHeight::default(),
|
||||||
border_color: params.day_other_month_fg,
|
color: fg,
|
||||||
},
|
font: renderer.default_font(),
|
||||||
params.ev_bg);
|
horizontal_alignment: alignment::Horizontal::Left,
|
||||||
renderer.fill_text(Text {
|
vertical_alignment: alignment::Vertical::Top,
|
||||||
content: ev_day.text.as_str(),
|
shaping: Shaping::default(),
|
||||||
bounds: ev_bounds,
|
});
|
||||||
size: params.ev_fontsize,
|
ev_y += ev_height
|
||||||
line_height: LineHeight::default(),
|
}
|
||||||
color: fg,
|
|
||||||
font: renderer.default_font(),
|
|
||||||
horizontal_alignment: alignment::Horizontal::Left,
|
|
||||||
vertical_alignment: alignment::Vertical::Top,
|
|
||||||
shaping: Shaping::default(),
|
|
||||||
});
|
|
||||||
ev_y += ev_height
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user