More work on theme support
This commit is contained in:
parent
3b315320e7
commit
b59e7476c2
132
clock.py
132
clock.py
|
@ -139,16 +139,21 @@ Builder.load_string('''
|
|||
size: 0.1*min(root.size), 0.1*min(root.size)
|
||||
|
||||
FloatLayout
|
||||
id: settings_menu
|
||||
id: settings_menu_background
|
||||
size_hint: None, None
|
||||
pos_hint: {"center_x":0.5, "center_y":0.5}
|
||||
size: 0.8*min(root.size), 0.7*min(root.size)
|
||||
size: 0.8*min(root.size), 0.8*min(root.size)
|
||||
canvas:
|
||||
Color:
|
||||
rgb: root.theme.color_shade
|
||||
Rectangle:
|
||||
size: self.size
|
||||
pos: self.pos
|
||||
FloatLayout
|
||||
id: settings_menu
|
||||
size_hint: None, None
|
||||
pos_hint: {"center_x":0.5, "center_y":0.5}
|
||||
size: 0.8*min(root.size), 0.7*min(root.size)
|
||||
GridLayout:
|
||||
rows: 9
|
||||
cols: 2
|
||||
|
@ -160,6 +165,7 @@ Builder.load_string('''
|
|||
font_size: root.height*0.05
|
||||
text_size: self.size
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_label_0
|
||||
Slider:
|
||||
id: volume_slider
|
||||
min: 0
|
||||
|
@ -175,6 +181,7 @@ Builder.load_string('''
|
|||
font_size: root.height*0.05
|
||||
text_size: self.size
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_label_1
|
||||
Button:
|
||||
id: settings_menu_wake_up_sound_select_button
|
||||
on_press: root.settings_menu_wake_up_sound_select_button_cb()
|
||||
|
@ -190,6 +197,7 @@ Builder.load_string('''
|
|||
font_size: root.height*0.05
|
||||
text_size: self.size
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_label_2
|
||||
Slider:
|
||||
id: wake_up_bightness_slider
|
||||
min: 0
|
||||
|
@ -205,6 +213,7 @@ Builder.load_string('''
|
|||
font_size: root.height*0.05
|
||||
text_size: self.size
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_label_3
|
||||
Slider:
|
||||
id: reading_light_brightness_slider
|
||||
min: 1
|
||||
|
@ -220,6 +229,7 @@ Builder.load_string('''
|
|||
font_size: root.height*0.05
|
||||
text_size: self.size
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_label_4
|
||||
Slider:
|
||||
id: display_brightness_slider
|
||||
min: 0
|
||||
|
@ -235,6 +245,7 @@ Builder.load_string('''
|
|||
font_size: root.height*0.05
|
||||
text_size: self.size
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_label_5
|
||||
Button:
|
||||
id: settings_menu_theme_select_button
|
||||
on_press: root.settings_menu_theme_select_button_cb()
|
||||
|
@ -244,7 +255,7 @@ Builder.load_string('''
|
|||
background_normal: ''
|
||||
background_color: root.theme.color_button
|
||||
FloatLayout
|
||||
id: settings_menu_wake_up_sound
|
||||
id: settings_menu_wake_up_sound_background
|
||||
size_hint: None, None
|
||||
pos_hint: {"center_x":0.5, "center_y":0.5}
|
||||
size: 0.8*min(root.size), 0.8*min(root.size)
|
||||
|
@ -254,6 +265,11 @@ Builder.load_string('''
|
|||
Rectangle:
|
||||
size: self.size
|
||||
pos: self.pos
|
||||
FloatLayout
|
||||
id: settings_menu_wake_up_sound
|
||||
size_hint: None, None
|
||||
pos_hint: {"center_x":0.5, "center_y":0.5}
|
||||
size: 0.8*min(root.size), 0.8*min(root.size)
|
||||
BoxLayout:
|
||||
orientation: "vertical"
|
||||
pos_hint: {"center_x":0.5, "center_y":0.5}
|
||||
|
@ -261,6 +277,7 @@ Builder.load_string('''
|
|||
text: "Select wake up sound"
|
||||
font_size: root.height*0.05
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_wake_up_sound_label_top
|
||||
GridLayout:
|
||||
cols: 2
|
||||
CheckBox:
|
||||
|
@ -275,6 +292,7 @@ Builder.load_string('''
|
|||
font_size: root.height*0.05
|
||||
color: root.theme.color_font
|
||||
active: True
|
||||
id: settings_menu_wake_up_sound_label_0
|
||||
CheckBox:
|
||||
group: "settings_menu_wake_up_sound"
|
||||
on_active: root.settings_menu_wake_up_sound_cb(self, self.active, "NPO Radio 1")
|
||||
|
@ -286,6 +304,7 @@ Builder.load_string('''
|
|||
text_size: self.size
|
||||
font_size: root.height*0.05
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_wake_up_sound_label_1
|
||||
Button:
|
||||
id: settings_menu_wake_up_sound_Ok_button
|
||||
on_press: root.settings_menu_wake_up_sound_Ok_button_cb()
|
||||
|
@ -295,7 +314,7 @@ Builder.load_string('''
|
|||
background_normal: ''
|
||||
background_color: root.theme.color_button
|
||||
FloatLayout
|
||||
id: settings_menu_theme
|
||||
id: settings_menu_theme_background
|
||||
size_hint: None, None
|
||||
pos_hint: {"center_x":0.5, "center_y":0.5}
|
||||
size: 0.8*min(root.size), 0.8*min(root.size)
|
||||
|
@ -305,6 +324,11 @@ Builder.load_string('''
|
|||
Rectangle:
|
||||
size: self.size
|
||||
pos: self.pos
|
||||
FloatLayout
|
||||
id: settings_menu_theme
|
||||
size_hint: None, None
|
||||
pos_hint: {"center_x":0.5, "center_y":0.5}
|
||||
size: 0.8*min(root.size), 0.8*min(root.size)
|
||||
BoxLayout:
|
||||
orientation: "vertical"
|
||||
pos_hint: {"center_x":0.5, "center_y":0.5}
|
||||
|
@ -312,6 +336,7 @@ Builder.load_string('''
|
|||
text: "Select theme"
|
||||
font_size: root.height*0.05
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_theme_label_top
|
||||
GridLayout:
|
||||
cols: 2
|
||||
CheckBox:
|
||||
|
@ -326,6 +351,7 @@ Builder.load_string('''
|
|||
font_size: root.height*0.05
|
||||
color: root.theme.color_font
|
||||
active: True
|
||||
id: settings_menu_theme_label_0
|
||||
CheckBox:
|
||||
group: "settings_menu_theme"
|
||||
on_active: root.settings_menu_theme_cb(self, self.active, "Light")
|
||||
|
@ -337,6 +363,20 @@ Builder.load_string('''
|
|||
text_size: self.size
|
||||
font_size: root.height*0.05
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_theme_label_1
|
||||
CheckBox:
|
||||
group: "settings_menu_theme"
|
||||
on_active: root.settings_menu_theme_cb(self, self.active, "Automatic")
|
||||
id: settings_menu_theme_Automatic
|
||||
Label:
|
||||
text: "Automatic"
|
||||
halign: "left"
|
||||
valign: "middle"
|
||||
text_size: self.size
|
||||
font_size: root.height*0.05
|
||||
color: root.theme.color_font
|
||||
id: settings_menu_theme_label_Automatic
|
||||
id: settings_menu_theme_label_2
|
||||
Button:
|
||||
id: settings_menu_theme_Ok_button
|
||||
on_press: root.settings_menu_theme_Ok_button_cb()
|
||||
|
@ -364,6 +404,7 @@ class Theme():
|
|||
self.color_font = [1, 1, 1]
|
||||
self.color_numbers = [1, 1, 1]
|
||||
self.color_button = [.2, .2, .2, 1]
|
||||
self.color_funky = [.5, .2, .1, 0.2]
|
||||
|
||||
self.icon_light_off = 'icons/dark/light_off.png'
|
||||
self.icon_light_reading = 'icons/dark/light_reading.png'
|
||||
|
@ -387,6 +428,7 @@ class Theme():
|
|||
self.color_font = [0, 0, 0]
|
||||
self.color_numbers = [0, 0, 0]
|
||||
self.color_button = [.8, .8, .8, 1]
|
||||
self.color_funky = [.1, .2, .5, 0.2]
|
||||
|
||||
self.icon_light_off = 'icons/light/light_off.png'
|
||||
self.icon_light_reading = 'icons/light/light_reading.png'
|
||||
|
@ -450,7 +492,8 @@ class TouchEvent():
|
|||
self.processed = False
|
||||
|
||||
class MyClockWidget(FloatLayout):
|
||||
theme = ObjectProperty(Theme("Light"))
|
||||
theme_selected = "Dark"
|
||||
theme = ObjectProperty(Theme(theme_selected))
|
||||
|
||||
grabbed = ""
|
||||
face_numbers = []
|
||||
|
@ -484,6 +527,7 @@ class MyClockWidget(FloatLayout):
|
|||
# - "settings_menu_wake_up_sound"
|
||||
# - "settings_menu_theme"
|
||||
view = "clock"
|
||||
view_prev = ""
|
||||
view_active_since = time.time()
|
||||
|
||||
# ugly workaround for issue where input is processed twice (specifically:
|
||||
|
@ -854,15 +898,73 @@ class MyClockWidget(FloatLayout):
|
|||
self.draw_list_curr_frame.append(["Line", hands.canvas, [hands.center_x, hands.center_y, seconds_hand.x, seconds_hand.y], 1, "round"])
|
||||
self.update_face()
|
||||
|
||||
def update_settings_menu(self):
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_background"], False])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu"], False])
|
||||
|
||||
background = self.ids["settings_menu_background"]
|
||||
self.draw_list_curr_frame.append(["canvas.clear()", background])
|
||||
with background.canvas:
|
||||
rgb = self.theme.color_shade
|
||||
self.draw_list_curr_frame.append(["Color", background.canvas, rgb[0], rgb[1], rgb[2]])
|
||||
self.draw_list_curr_frame.append(["Rectangle", background.canvas, background.size, background.pos, ""])
|
||||
|
||||
for s in ["label_0", "label_1", "label_2", "label_3", "label_4", "label_5", "theme_select_button", "wake_up_sound_select_button"]:
|
||||
i = self.ids["settings_menu_" + s]
|
||||
i.color = self.theme.color_font
|
||||
i = self.ids["settings_menu_theme_select_button"]
|
||||
i.background_color = self.theme.color_button
|
||||
i = self.ids["settings_menu_wake_up_sound_select_button"]
|
||||
i.background_color = self.theme.color_button
|
||||
|
||||
def update_settings_menu_wake_up_sound(self):
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_wake_up_sound_background"], False])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_wake_up_sound"], False])
|
||||
|
||||
background = self.ids["settings_menu_wake_up_sound_background"]
|
||||
self.draw_list_curr_frame.append(["canvas.clear()", background])
|
||||
with background.canvas:
|
||||
rgb = self.theme.color_shade
|
||||
self.draw_list_curr_frame.append(["Color", background.canvas, rgb[0], rgb[1], rgb[2]])
|
||||
self.draw_list_curr_frame.append(["Rectangle", background.canvas, background.size, background.pos, ""])
|
||||
|
||||
for s in ["label_top", "label_0", "label_1", "Ok_button"]:
|
||||
i = self.ids["settings_menu_wake_up_sound_" + s]
|
||||
i.color = self.theme.color_font
|
||||
i = self.ids["settings_menu_wake_up_sound_Ok_button"]
|
||||
i.background_color = self.theme.color_button
|
||||
|
||||
def update_settings_menu_theme(self):
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_theme_background"], False])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_theme"], False])
|
||||
|
||||
background = self.ids["settings_menu_theme_background"]
|
||||
self.draw_list_curr_frame.append(["canvas.clear()", background])
|
||||
with background.canvas:
|
||||
rgb = self.theme.color_shade
|
||||
self.draw_list_curr_frame.append(["Color", background.canvas, rgb[0], rgb[1], rgb[2]])
|
||||
self.draw_list_curr_frame.append(["Rectangle", background.canvas, background.size, background.pos, ""])
|
||||
|
||||
for s in ["label_top", "label_0", "label_1", "label_2", "Ok_button"]:
|
||||
i = self.ids["settings_menu_theme_" + s]
|
||||
i.color = self.theme.color_font
|
||||
i = self.ids["settings_menu_theme_Ok_button"]
|
||||
i.background_color = self.theme.color_button
|
||||
|
||||
def update_settings(self):
|
||||
if self.view == "settings_menu":
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu"], False])
|
||||
self.update_settings_menu()
|
||||
elif self.view == "settings_menu_wake_up_sound":
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_wake_up_sound"], False])
|
||||
self.update_settings_menu_wake_up_sound()
|
||||
elif self.view == "settings_menu_theme":
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_theme"], False])
|
||||
self.update_settings_menu_theme()
|
||||
|
||||
def draw_display(self):
|
||||
t = time.time()
|
||||
if (self.view != self.view_prev) or (t - self.view_active_since < self.time_to_ignore_inputs_after_view_change):
|
||||
self.draw_list_last_frame = [] # force redraw when view has changed
|
||||
self.view_prev = self.view
|
||||
|
||||
if self.draw_list_curr_frame != self.draw_list_last_frame:
|
||||
for i in self.draw_list_curr_frame:
|
||||
if i[0] == "self.hide_widget":
|
||||
|
@ -871,7 +973,10 @@ class MyClockWidget(FloatLayout):
|
|||
i[1].canvas.clear()
|
||||
elif i[0] == "Color":
|
||||
with i[1]:
|
||||
Color(i[2], i[3], i[4])
|
||||
if len(i) == 5:
|
||||
Color(i[2], i[3], i[4])
|
||||
else:
|
||||
Color(i[2], i[3], i[4], i[5])
|
||||
elif i[0] == "Rectangle":
|
||||
with i[1]:
|
||||
Rectangle(size=i[2], pos=i[3], source=i[4])
|
||||
|
@ -917,8 +1022,11 @@ class MyClockWidget(FloatLayout):
|
|||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["face_plate"], True])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["face"], True])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["hands"], True])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_background"], True])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu"], True])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_wake_up_sound_background"], True])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_wake_up_sound"], True])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_theme_background"], True])
|
||||
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_theme"], True])
|
||||
|
||||
self.update_background()
|
||||
|
@ -1014,7 +1122,11 @@ class MyClockWidget(FloatLayout):
|
|||
else:
|
||||
print("You deselected " + theme)
|
||||
|
||||
self.theme = Theme(theme)
|
||||
self.theme_selected = theme
|
||||
if theme == "Automatic":
|
||||
self.theme = Theme("Light")
|
||||
else:
|
||||
self.theme = Theme(theme)
|
||||
|
||||
def volume_slider_value(self, *args):
|
||||
alarm_settings = App.get_running_app().alarm_settings
|
||||
|
|
Loading…
Reference in New Issue