Use outline icons when icon color is white
This commit is contained in:
parent
624d75c033
commit
868c46f7d6
98
clock.py
98
clock.py
|
@ -567,6 +567,9 @@ class MyClockWidget(FloatLayout):
|
||||||
widget.saved_attrs = widget.height, widget.size_hint_y, widget.opacity, widget.disabled
|
widget.saved_attrs = widget.height, widget.size_hint_y, widget.opacity, widget.disabled
|
||||||
widget.height, widget.size_hint_y, widget.opacity, widget.disabled = 0, None, 0, True
|
widget.height, widget.size_hint_y, widget.opacity, widget.disabled = 0, None, 0, True
|
||||||
|
|
||||||
|
def is_widget_hidden(self, widget):
|
||||||
|
return hasattr(widget, 'saved_attrs')
|
||||||
|
|
||||||
def draw_numbers(self):
|
def draw_numbers(self):
|
||||||
"""
|
"""
|
||||||
Add number labels when added in widget hierarchy
|
Add number labels when added in widget hierarchy
|
||||||
|
@ -652,7 +655,7 @@ class MyClockWidget(FloatLayout):
|
||||||
def draw_paqi_expectation(self):
|
def draw_paqi_expectation(self):
|
||||||
self.draw_precipitation_paqi_expectation(self.paqi, self.paqi_thresholds, 0.32)
|
self.draw_precipitation_paqi_expectation(self.paqi, self.paqi_thresholds, 0.32)
|
||||||
|
|
||||||
def draw_icon_helper(self, color, img_source, label):
|
def paint_icon(self, color, img_source, label):
|
||||||
c = (int(256 * color[0]), int(256 * color[1]), int(256 * color[2]), int(256))
|
c = (int(256 * color[0]), int(256 * color[1]), int(256 * color[2]), int(256))
|
||||||
tmp = Image.new('RGBA', img_source.size, color = c)
|
tmp = Image.new('RGBA', img_source.size, color = c)
|
||||||
img_modified = ImageChops.multiply(tmp, img_source)
|
img_modified = ImageChops.multiply(tmp, img_source)
|
||||||
|
@ -665,38 +668,89 @@ class MyClockWidget(FloatLayout):
|
||||||
icon = self.ids[label]
|
icon = self.ids[label]
|
||||||
icon.texture = im.texture
|
icon.texture = im.texture
|
||||||
|
|
||||||
|
def draw_icon_helper(self, x, x_thresholds, x_label, L, color_prev, img):
|
||||||
|
N = min(L, len(x))
|
||||||
|
colors = self.calculate_colors(x[:N], x_thresholds)
|
||||||
|
color = colors[x.index(max(x[:N]))]
|
||||||
|
|
||||||
|
if color_prev != color:
|
||||||
|
# Color has changed
|
||||||
|
if color == [1, 1, 1]:
|
||||||
|
img = Image.open("icons/" + x_label + "_outline.png")
|
||||||
|
else:
|
||||||
|
if color_prev == [1, 1, 1]:
|
||||||
|
img = Image.open("icons/" + x_label + ".png")
|
||||||
|
|
||||||
|
self.pollen_color_prev = color
|
||||||
|
self.paint_icon(color, img, "icon_" + x_label)
|
||||||
|
|
||||||
|
return color
|
||||||
|
|
||||||
def draw_icon_uvi(self):
|
def draw_icon_uvi(self):
|
||||||
if hasattr(self, 'image_uvi') == False:
|
if hasattr(self, 'image_uvi') == False:
|
||||||
self.image_uvi = Image.open("icons/uvi.png")
|
self.image_uvi = Image.open("icons/uvi.png")
|
||||||
|
|
||||||
colors = self.calculate_colors(self.uvi[:1], self.uvi_thresholds)
|
if len(self.uvi) == 0:
|
||||||
color = colors[0]
|
if self.is_widget_hidden(self.ids["icon_uvi"]) == False:
|
||||||
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_uvi"], True])
|
||||||
|
return
|
||||||
|
|
||||||
if hasattr(self, 'uvi_color_prev') == False or self.uvi_color_prev != color:
|
if self.is_widget_hidden(self.ids["icon_uvi"]):
|
||||||
self.uvi_color_prev = color
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_uvi"], False])
|
||||||
self.draw_icon_helper(color, self.image_uvi, "icon_uvi")
|
|
||||||
|
if hasattr(self, 'uvi_color_prev') == False:
|
||||||
|
self.uvi_color_prev = []
|
||||||
|
|
||||||
|
if hasattr(self, 'uvi_color') == False:
|
||||||
|
self.uvi_color = []
|
||||||
|
|
||||||
|
color = self.draw_icon_helper(self.uvi, self.uvi_thresholds, "uvi", 1, self.uvi_color_prev, self.image_uvi)
|
||||||
|
self.uvi_color_prev = self.uvi_color
|
||||||
|
self.uvi_color = color
|
||||||
|
|
||||||
def draw_icon_pollen(self):
|
def draw_icon_pollen(self):
|
||||||
if hasattr(self, 'image_pollen') == False:
|
if hasattr(self, 'image_pollen') == False:
|
||||||
self.image_pollen = Image.open("icons/pollen.png")
|
self.image_pollen = Image.open("icons/pollen.png")
|
||||||
|
|
||||||
colors = self.calculate_colors(self.pollen[:12], self.pollen_thresholds)
|
if len(self.pollen) == 0:
|
||||||
color = colors[self.pollen.index(max(self.pollen[:12]))]
|
if self.is_widget_hidden(self.ids["icon_pollen"]) == False:
|
||||||
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_pollen"], True])
|
||||||
|
return
|
||||||
|
|
||||||
if hasattr(self, 'pollen_color_prev') == False or self.pollen_color_prev != color:
|
if self.is_widget_hidden(self.ids["icon_pollen"]):
|
||||||
self.pollen_color_prev = color
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_pollen"], False])
|
||||||
self.draw_icon_helper(color, self.image_pollen, "icon_pollen")
|
|
||||||
|
if hasattr(self, 'pollen_color_prev') == False:
|
||||||
|
self.pollen_color_prev = []
|
||||||
|
|
||||||
|
if hasattr(self, 'pollen_color') == False:
|
||||||
|
self.pollen_color = []
|
||||||
|
|
||||||
|
color = self.draw_icon_helper(self.pollen, self.pollen_thresholds, "pollen", 12, self.pollen_color_prev, self.image_pollen)
|
||||||
|
self.pollen_color_prev = self.pollen_color
|
||||||
|
self.pollen_color = color
|
||||||
|
|
||||||
def draw_icon_aqi(self):
|
def draw_icon_aqi(self):
|
||||||
if hasattr(self, 'image_aqi') == False:
|
if hasattr(self, 'image_aqi') == False:
|
||||||
self.image_aqi = Image.open("icons/aqi.png")
|
self.image_aqi = Image.open("icons/aqi.png")
|
||||||
|
|
||||||
colors = self.calculate_colors(self.aqi[:12], self.aqi_thresholds)
|
if len(self.aqi) == 0:
|
||||||
color = colors[self.aqi.index(max(self.aqi[:12]))]
|
if self.is_widget_hidden(self.ids["icon_aqi"]) == False:
|
||||||
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_aqi"], True])
|
||||||
|
return
|
||||||
|
|
||||||
if hasattr(self, 'aqi_color_prev') == False or self.aqi_color_prev != color:
|
if self.is_widget_hidden(self.ids["icon_aqi"]):
|
||||||
self.aqi_color_prev = color
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_aqi"], False])
|
||||||
self.draw_icon_helper(color, self.image_aqi, "icon_aqi")
|
|
||||||
|
if hasattr(self, 'aqi_color_prev') == False:
|
||||||
|
self.aqi_color_prev = []
|
||||||
|
|
||||||
|
if hasattr(self, 'aqi_color') == False:
|
||||||
|
self.aqi_color = []
|
||||||
|
|
||||||
|
color = self.draw_icon_helper(self.aqi, self.aqi_thresholds, "aqi", 12, self.aqi_color_prev, self.image_aqi)
|
||||||
|
self.aqi_color_prev = self.aqi_color
|
||||||
|
self.aqi_color = color
|
||||||
|
|
||||||
def draw_icons(self):
|
def draw_icons(self):
|
||||||
self.draw_icon_uvi()
|
self.draw_icon_uvi()
|
||||||
|
@ -1010,10 +1064,16 @@ class MyClockWidget(FloatLayout):
|
||||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["face_plate"], False])
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["face_plate"], False])
|
||||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["face"], False])
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["face"], False])
|
||||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["hands"], False])
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["hands"], False])
|
||||||
|
|
||||||
if self.view == "clock":
|
if self.view == "clock":
|
||||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_uvi"], False])
|
if len(self.uvi) > 0:
|
||||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_pollen"], False])
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_uvi"], False])
|
||||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_aqi"], False])
|
|
||||||
|
if len(self.pollen) > 0:
|
||||||
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_pollen"], False])
|
||||||
|
|
||||||
|
if len(self.aqi) > 0:
|
||||||
|
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["icon_aqi"], False])
|
||||||
|
|
||||||
if self.view == "set_alarm":
|
if self.view == "set_alarm":
|
||||||
t = self.settings.alarm_time
|
t = self.settings.alarm_time
|
||||||
|
|
Loading…
Reference in New Issue