Refine calendar event data display, prevent overlapping and display
event's end time.
This commit is contained in:
+18
-12
@@ -1170,31 +1170,37 @@ display:
|
||||
break;
|
||||
}
|
||||
|
||||
const int group_y = agenda_y;
|
||||
int event_y = group_y;
|
||||
const int day_number = day["day"] | 0;
|
||||
const char *weekday = day["weekday"] | "";
|
||||
const bool is_today = (day["today"] | 0) == 1;
|
||||
it.printf(30, agenda_y, id(sub_sensor_font), TextAlign::TOP_CENTER, "%d", day_number);
|
||||
it.printf(30, agenda_y + 28, id(footer_font), TextAlign::TOP_CENTER, "%s", weekday);
|
||||
it.print(68, agenda_y + 2, id(footer_font), TextAlign::TOP_LEFT, is_today ? "HEUTE" : "");
|
||||
it.line(58, agenda_y, 58, agenda_y + 32 + events.size() * 35);
|
||||
agenda_y += 36;
|
||||
it.printf(30, group_y, id(sub_sensor_font), TextAlign::TOP_CENTER, "%d", day_number);
|
||||
it.printf(30, group_y + 28, id(footer_font), TextAlign::TOP_CENTER, "%s", weekday);
|
||||
|
||||
for (JsonVariant event_variant : events) {
|
||||
if (agenda_y + 33 > 345) {
|
||||
if (event_y + 33 > 345) {
|
||||
has_hidden_events = true;
|
||||
break;
|
||||
}
|
||||
JsonObject event = event_variant.as<JsonObject>();
|
||||
const char *title = event["title"] | "Ohne Titel";
|
||||
const char *time = event["time"] | "";
|
||||
const char *end_time = event["end"] | "";
|
||||
const char *meta = event["meta"] | "";
|
||||
it.printf(72, agenda_y, id(sensor_unit), TextAlign::TOP_LEFT, "%s", title);
|
||||
it.printf(350, agenda_y, id(sensor_unit), TextAlign::TOP_RIGHT, "%s", time);
|
||||
it.printf(72, agenda_y + 20, id(footer_font), TextAlign::TOP_LEFT, "%s", meta);
|
||||
agenda_y += 35;
|
||||
it.printf(72, event_y, id(sensor_unit), TextAlign::TOP_LEFT, "%s", title);
|
||||
it.printf(350, event_y, id(sensor_unit), TextAlign::TOP_RIGHT, "%s", time);
|
||||
it.printf(72, event_y + 20, id(footer_font), TextAlign::TOP_LEFT, "%s", meta);
|
||||
if (end_time[0] != '\0') {
|
||||
it.printf(350, event_y + 20, id(footer_font), TextAlign::TOP_RIGHT, "%s", end_time);
|
||||
}
|
||||
event_y += 35;
|
||||
has_events = true;
|
||||
}
|
||||
agenda_y += 5;
|
||||
|
||||
int group_bottom = event_y;
|
||||
if (group_bottom < group_y + 36) group_bottom = group_y + 36;
|
||||
it.line(58, group_y, 58, group_bottom);
|
||||
agenda_y = group_bottom + 5;
|
||||
if (has_hidden_events) break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user