diff --git a/Calendar/AgendaListPanel.py b/Calendar/AgendaListPanel.py index 64397c0..8a8eb79 100644 --- a/Calendar/AgendaListPanel.py +++ b/Calendar/AgendaListPanel.py @@ -4,17 +4,20 @@ from WeatherHeaderDesign import WeatherHeaderDesign from settings import general_settings from PIL import ImageDraw from Assets import colors +from RssPostListDesign import RssPostListDesign agenda_ypadding = 5 weatherheader_height = 0.113 -seperatorplace = (0, 0.113) seperator_width = 1 +infolist_size = (1, 0.24) +infolist_padding = 5 class AgendaListPanel (PanelDesign): '''Lists upcoming events in chronological order and groups them by days''' def __init__(self, size): super(AgendaListPanel, self).__init__(size) self.weather_size = (0, 0) + self.info_size = (0, 0) if general_settings["weather-info"]: self.weather_size = (self.size[0], self.size[1] * weatherheader_height) @@ -22,30 +25,45 @@ class AgendaListPanel (PanelDesign): self.weather = weather def add_calendar (self, calendar): - size = (self.size[0], self.size[1] - self.weather_size[1]) - - agenda = AgendaListDesign(size, calendar) - agenda.pos = (0, agenda_ypadding + self.weather_size[1]) - self.draw_design(agenda) + self.calendar = calendar def add_rssfeed (self, rss): - pass + if general_settings["info-area"] != "rss": + return + + self.info_size = self.__abs_pos__(infolist_size) + pos = (0, self.size[1] - self.info_size[1] + infolist_padding) + + list = RssPostListDesign(self.info_size, rss) + list.pos = pos + self.draw_design(list) + + self.__draw_seperator__(1-infolist_size[1], colors["fg"]) def add_taks (self, tasks): pass def __finish_image__(self): - if general_settings["weather-info"] == False: - return - header = WeatherHeaderDesign(self.weather_size, self.weather) - self.draw_design(header) - self.__draw_seperator__() + self.__draw_calendar__() + if general_settings["weather-info"]: + self.__draw_weather__() - def __draw_seperator__ (self): - """Draw a line seperating the weather and Calendar section""" - ImageDraw.Draw(self.__image__).line([ self.__abs_pos__(seperatorplace), self.__abs_pos__((1, seperatorplace[1])) ], fill=colors["hl"], width=seperator_width) + def __draw_seperator__ (self, height, color): + ImageDraw.Draw(self.__image__).line([ self.__abs_pos__((0, height)), self.__abs_pos__((1, height)) ], fill=color, width=seperator_width) def __abs_pos__ (self, pos, size = None): if size is None: size = self.size - return (int(pos[0] * size[0]), int(pos[1] * size[1])) \ No newline at end of file + return (int(pos[0] * size[0]), int(pos[1] * size[1])) + + def __draw_calendar__(self): + size = (self.size[0], self.size[1] - self.weather_size[1] - self.info_size[1] - agenda_ypadding) + + agenda = AgendaListDesign(size, self.calendar) + agenda.pos = (0, agenda_ypadding + self.weather_size[1]) + self.draw_design(agenda) + + def __draw_weather__(self): + header = WeatherHeaderDesign(self.weather_size, self.weather) + self.draw_design(header) + self.__draw_seperator__(weatherheader_height, colors["hl"]) \ No newline at end of file