Skip to content

Commit d2ccdfc

Browse files
committed
fix: sync layout-updated watchface
1 parent f2c982e commit d2ccdfc

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

assets/apps/watch.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def _clean_obj(parent):
7272
obj.remove_flag(lv.obj.FLAG.SCROLLABLE)
7373
except AttributeError:
7474
pass
75+
try:
76+
obj.update_layout()
77+
except AttributeError:
78+
pass
7579
return obj
7680

7781

@@ -81,7 +85,6 @@ def _clean_label(parent, text, color, font_size):
8185
lbl.remove_style_all()
8286
except AttributeError:
8387
pass
84-
lbl.set_text(text)
8588
font, _ = _font_for(font_size)
8689
if font is not None:
8790
lbl.set_style_text_font(font, 0)
@@ -100,6 +103,11 @@ def _clean_label(parent, text, color, font_size):
100103
lbl.set_style_outline_width(0, 0)
101104
except AttributeError:
102105
pass
106+
lbl.set_text(text)
107+
try:
108+
lbl.update_layout()
109+
except AttributeError:
110+
pass
103111
return lbl
104112

105113

@@ -176,6 +184,10 @@ def _build_watch(self):
176184
self.parent.remove_flag(lv.obj.FLAG.SCROLLABLE)
177185
except AttributeError:
178186
pass
187+
try:
188+
self.parent.update_layout()
189+
except AttributeError:
190+
pass
179191

180192
# 2. Outer Watch Bezel / Casing
181193
self.bezel = _clean_obj(self.parent)
@@ -188,6 +200,10 @@ def _build_watch(self):
188200
self.bezel.set_style_bg_opa(lv.OPA.COVER, 0)
189201
self.bezel.set_style_border_color(_color(0x3B444E), 0)
190202
self.bezel.set_style_border_width(max(2, int(size * 0.017)), 0)
203+
try:
204+
self.bezel.update_layout()
205+
except AttributeError:
206+
pass
191207

192208
# 3. Inner Metallic Bezel Ring with Subtle Amber Accent
193209
inner_bezel_size = int(size * 0.95)
@@ -200,6 +216,10 @@ def _build_watch(self):
200216
self.bezel_ring.set_style_border_color(_color(0xF54E00), 0)
201217
self.bezel_ring.set_style_border_width(1, 0)
202218
self.bezel_ring.set_style_border_opa(lv.OPA._60, 0)
219+
try:
220+
self.bezel_ring.update_layout()
221+
except AttributeError:
222+
pass
203223

204224
# 4. Dial Face (Underlay for background elements)
205225
self.face = _clean_obj(self.parent)
@@ -212,6 +232,10 @@ def _build_watch(self):
212232
self.face.set_style_bg_opa(lv.OPA.COVER, 0)
213233
self.face.set_style_border_color(_color(0x28323D), 0)
214234
self.face.set_style_border_width(1, 0)
235+
try:
236+
self.face.update_layout()
237+
except AttributeError:
238+
pass
215239

216240
# 5. Roman Hour Numerals (XII, III, VI, IX)
217241
# XII & VI: horizontal center aligned to parent (x_offset = 0), calculated y_offset
@@ -220,21 +244,41 @@ def _build_watch(self):
220244

221245
self.lbl_xii = _clean_label(self.face, "XII", 0xE2E8F0, 14)
222246
self.lbl_xii.align(lv.ALIGN.TOP_MID, 0, num_inset)
247+
try:
248+
self.lbl_xii.update_layout()
249+
except AttributeError:
250+
pass
223251

224252
self.lbl_vi = _clean_label(self.face, "VI", 0xE2E8F0, 14)
225253
self.lbl_vi.align(lv.ALIGN.BOTTOM_MID, 0, -num_inset)
254+
try:
255+
self.lbl_vi.update_layout()
256+
except AttributeError:
257+
pass
226258

227259
self.lbl_ix = _clean_label(self.face, "IX", 0xE2E8F0, 14)
228260
self.lbl_ix.align(lv.ALIGN.LEFT_MID, num_inset, 0)
261+
try:
262+
self.lbl_ix.update_layout()
263+
except AttributeError:
264+
pass
229265

230266
self.lbl_iii = _clean_label(self.face, "III", 0xE2E8F0, 14)
231267
self.lbl_iii.align(lv.ALIGN.RIGHT_MID, -num_inset, 0)
268+
try:
269+
self.lbl_iii.update_layout()
270+
except AttributeError:
271+
pass
232272

233273
# 6. Brand Label (Upper Dial Quadrant)
234274
# Horizontal center aligned to parent (x_offset = 0), calculated y_offset
235275
brand_top_offset = int(dial_size * 0.25)
236276
self.brand_lbl = _clean_label(self.face, "PYDEVICES", 0xF54E00, 11)
237277
self.brand_lbl.align(lv.ALIGN.TOP_MID, 0, brand_top_offset)
278+
try:
279+
self.brand_lbl.update_layout()
280+
except AttributeError:
281+
pass
238282

239283
# 7. Digital Readout Sub-Dial (Lower Dial Quadrant) - Created on dial face behind hands
240284
# Horizontal center aligned to parent (x_offset = 0), calculated y_offset
@@ -250,14 +294,26 @@ def _build_watch(self):
250294
self.pill.set_style_bg_opa(lv.OPA._90, 0)
251295
self.pill.set_style_border_color(_color(0x28333E), 0)
252296
self.pill.set_style_border_width(1, 0)
297+
try:
298+
self.pill.update_layout()
299+
except AttributeError:
300+
pass
253301

254302
# Digital Time & Date inside sub-dial:
255303
# Both horizontal centers aligned to parent pill (x_offset = 0), calculated y_offsets
256304
self.digital_time = _clean_label(self.pill, "00:00:00", 0xF8FAFC, 13)
257305
self.digital_time.align(lv.ALIGN.TOP_MID, 0, 4)
306+
try:
307+
self.digital_time.update_layout()
308+
except AttributeError:
309+
pass
258310

259311
self.digital_date = _clean_label(self.pill, "FRI OCT 24", 0x94A3B8, 10)
260312
self.digital_date.align(lv.ALIGN.BOTTOM_MID, 0, -4)
313+
try:
314+
self.digital_date.update_layout()
315+
except AttributeError:
316+
pass
261317

262318
# 8. Scale for Ticks & Analog Needles - Created AFTER dial & digital sub-dial
263319
# This guarantees that the tick ring and all rotating hands draw in FRONT of the digital display!

0 commit comments

Comments
 (0)