Skip to content

Commit aba86e3

Browse files
committed
style: sync 0-offset directional alignments
1 parent ba9a253 commit aba86e3

1 file changed

Lines changed: 43 additions & 20 deletions

File tree

assets/apps/watch.py

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,19 @@ def _build_watch(self):
138138

139139
# 3. Inner Metallic Bezel Ring with Subtle Amber Accent
140140
inner_bezel_size = int(size * 0.95)
141-
self.bezel_ring = lv.obj(self.bezel)
141+
self.bezel_ring = lv.obj(self.parent)
142142
self.bezel_ring.set_size(inner_bezel_size, inner_bezel_size)
143143
self.bezel_ring.center()
144144
self.bezel_ring.set_style_radius(lv.RADIUS_CIRCLE, 0)
145145
self.bezel_ring.set_style_bg_color(_color(0x151A20), 0)
146146
self.bezel_ring.set_style_border_color(_color(0xF54E00), 0)
147147
self.bezel_ring.set_style_border_width(1, 0)
148148
self.bezel_ring.set_style_border_opa(lv.OPA._60, 0)
149+
self.bezel_ring.set_style_pad_all(0, 0)
149150
_plain(self.bezel_ring)
150151

151152
# 4. Dial Face (Underlay for background elements)
152-
self.face = lv.obj(self.bezel_ring)
153+
self.face = lv.obj(self.parent)
153154
self.face.set_size(dial_size, dial_size)
154155
self.face.center()
155156
self.face.set_style_radius(lv.RADIUS_CIRCLE, 0)
@@ -158,36 +159,56 @@ def _build_watch(self):
158159
self.face.set_style_bg_grad_dir(lv.GRAD_DIR.VER, 0)
159160
self.face.set_style_border_color(_color(0x28323D), 0)
160161
self.face.set_style_border_width(1, 0)
162+
self.face.set_style_pad_all(0, 0)
161163
_plain(self.face)
162164

163-
# 5. Roman Hour Numerals (XII, III, VI, IX) - Polar-centered with zero padding
164-
numerals = {0: "XII", 3: "III", 6: "VI", 9: "IX"}
165-
num_radius = int(dial_size * 0.36)
166-
for hour, label_text in numerals.items():
167-
lbl = lv.label(self.face)
168-
lbl.set_text(label_text)
169-
lbl.set_style_text_color(_color(0xE2E8F0), 0)
170-
_set_font(lbl, 14)
171-
angle = math.radians(hour * 30 - 90)
172-
nx = int(math.cos(angle) * num_radius)
173-
ny = int(math.sin(angle) * num_radius)
174-
lbl.align(lv.ALIGN.CENTER, nx, ny)
165+
# 5. Roman Hour Numerals (XII, III, VI, IX)
166+
# XII & VI: horizontal center aligned to parent (x_offset = 0), calculated y_offset
167+
# IX & III: vertical center aligned to parent (y_offset = 0), calculated x_offset
168+
num_inset = int(dial_size * 0.08)
169+
170+
self.lbl_xii = lv.label(self.face)
171+
self.lbl_xii.set_text("XII")
172+
self.lbl_xii.set_style_text_color(_color(0xE2E8F0), 0)
173+
_set_font(self.lbl_xii, 14)
174+
self.lbl_xii.align(lv.ALIGN.TOP_MID, 0, num_inset)
175+
176+
self.lbl_vi = lv.label(self.face)
177+
self.lbl_vi.set_text("VI")
178+
self.lbl_vi.set_style_text_color(_color(0xE2E8F0), 0)
179+
_set_font(self.lbl_vi, 14)
180+
self.lbl_vi.align(lv.ALIGN.BOTTOM_MID, 0, -num_inset)
181+
182+
self.lbl_ix = lv.label(self.face)
183+
self.lbl_ix.set_text("IX")
184+
self.lbl_ix.set_style_text_color(_color(0xE2E8F0), 0)
185+
_set_font(self.lbl_ix, 14)
186+
self.lbl_ix.align(lv.ALIGN.LEFT_MID, num_inset, 0)
187+
188+
self.lbl_iii = lv.label(self.face)
189+
self.lbl_iii.set_text("III")
190+
self.lbl_iii.set_style_text_color(_color(0xE2E8F0), 0)
191+
_set_font(self.lbl_iii, 14)
192+
self.lbl_iii.align(lv.ALIGN.RIGHT_MID, -num_inset, 0)
175193

176194
# 6. Brand Label (Upper Dial Quadrant)
195+
# Horizontal center aligned to parent (x_offset = 0), calculated y_offset
196+
brand_top_offset = int(dial_size * 0.25)
177197
self.brand_lbl = lv.label(self.face)
178198
self.brand_lbl.set_text("PYDEVICES")
179199
self.brand_lbl.set_style_text_color(_color(0xF54E00), 0)
180200
_set_font(self.brand_lbl, 11)
181-
self.brand_lbl.align(lv.ALIGN.CENTER, 0, -int(dial_size * 0.22))
201+
self.brand_lbl.align(lv.ALIGN.TOP_MID, 0, brand_top_offset)
182202

183203
# 7. Digital Readout Sub-Dial (Lower Dial Quadrant) - Created on dial face behind hands
204+
# Horizontal center aligned to parent (x_offset = 0), calculated y_offset
184205
pill_w = int(dial_size * 0.46)
185-
pill_h = int(dial_size * 0.16)
186-
pill_center_y = int(dial_size * 0.22)
206+
pill_h = int(dial_size * 0.18)
207+
pill_bottom_offset = int(dial_size * 0.18)
187208

188209
self.pill = lv.obj(self.face)
189210
self.pill.set_size(pill_w, pill_h)
190-
self.pill.align(lv.ALIGN.CENTER, 0, pill_center_y)
211+
self.pill.align(lv.ALIGN.BOTTOM_MID, 0, -pill_bottom_offset)
191212
self.pill.set_style_radius(max(4, int(pill_h * 0.18)), 0)
192213
self.pill.set_style_bg_color(_color(0x080B0E), 0)
193214
self.pill.set_style_bg_opa(lv.OPA._90, 0)
@@ -199,17 +220,19 @@ def _build_watch(self):
199220
except AttributeError:
200221
pass
201222

223+
# Digital Time & Date inside sub-dial:
224+
# Both horizontal centers aligned to parent pill (x_offset = 0), calculated y_offsets
202225
self.digital_time = lv.label(self.pill)
203226
self.digital_time.set_text("00:00:00")
204227
self.digital_time.set_style_text_color(_color(0xF8FAFC), 0)
205228
_set_font(self.digital_time, 13)
206-
self.digital_time.align(lv.ALIGN.TOP_MID, 0, int(pill_h * 0.10))
229+
self.digital_time.align(lv.ALIGN.TOP_MID, 0, 4)
207230

208231
self.digital_date = lv.label(self.pill)
209232
self.digital_date.set_text("FRI OCT 24")
210233
self.digital_date.set_style_text_color(_color(0x94A3B8), 0)
211234
_set_font(self.digital_date, 10)
212-
self.digital_date.align(lv.ALIGN.BOTTOM_MID, 0, -int(pill_h * 0.10))
235+
self.digital_date.align(lv.ALIGN.BOTTOM_MID, 0, -4)
213236

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

0 commit comments

Comments
 (0)