Split the face into modules, comment it, and verify every field
Architecture
Fenix8V3View had grown to 632 lines mixing layout constants, font
metrics, icon drawing, data lookup and orchestration. Split into:
Layout the 500-canvas constants, scaling, font choice and text drawing
Icons the three bitmap icons plus the primitive glyphs
Settings every stored preference and its default, in one place
Fields unchanged in scope, but value() is now seven category
functions that each return null for ids they do not own --
the ids interleave, so dispatching on ranges does not work
View what is left: the drawing order
The view is down to 359 lines and no longer reaches for a property or a
font metric directly.
Verification
Added a harness that walks all 75 ids in the simulator and reports each
rendered value with its pixel width. It caught a real one: pushDistance
and pushes compile on every device but throw "Symbol Not Found" at
runtime on a fenix 8 -- they are wheelchair counters that only some
firmware carries. Every optional ActivityMonitor, UserProfile, Weather
and Activity member is now behind a `has` check.
The same run showed two date fields overflowing their slot, so long
values now step down a font size rather than running into the ring.
Always-on mode checked against the simulator's Always-On display mode:
band fill gone, unlit ticks gone, slots hidden, time and date dimmed.
Also: Chinese "Day Date" was missing its 日, since it built the string by
hand instead of going through the localised date format.
All 17 devices build.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
26
README.md
26
README.md
@@ -27,9 +27,12 @@ fenix8v3-watchface/
|
||||
│ ├── gen_icons.py # design/*.svg -> 各尺寸图标位图 + 启动图标
|
||||
│ └── gen_preview_svg.py # source/Themes.mc -> preview-themes.svg + preview.html
|
||||
├── source/
|
||||
│ ├── Fenix8V3App.mc # 应用入口
|
||||
│ ├── Fenix8V3View.mc # 渲染逻辑(含常亮模式)
|
||||
│ ├── Fenix8V3App.mc # 应用入口(12 行壳子)
|
||||
│ ├── Fenix8V3View.mc # 绘制顺序:进度环 / 各元素 / 常亮模式
|
||||
│ ├── Layout.mc # 500 画布常量、缩放、字号选择、文字绘制
|
||||
│ ├── Icons.mc # 图标:位图三件套 + 其余图元
|
||||
│ ├── Fields.mc # 75 项数据字段的取值与格式化
|
||||
│ ├── Settings.mc # 所有设置项的读取与默认值
|
||||
│ ├── FieldTable.mc # ⚠️ 自动生成:字段 id 表
|
||||
│ └── Themes.mc # ⚠️ 自动生成:七套主题配色
|
||||
├── resources/ # 英文文案 + 设置项定义(部分自动生成)
|
||||
@@ -50,6 +53,23 @@ python3 tools/gen_themes.py && python3 tools/gen_fields.py \
|
||||
|
||||
---
|
||||
|
||||
## 1.5 代码结构
|
||||
|
||||
一句话:**位置归 `Layout`,内容归 `Fields`,配色归 `Themes`,设置归 `Settings`,`Fenix8V3View` 只剩画的顺序。**
|
||||
|
||||
| 模块 | 负责 | 不负责 |
|
||||
|------|------|--------|
|
||||
| `Layout` | 500 基准画布的全部坐标常量、`px()` 缩放、极坐标换算、字号选择与自动缩字、渐变文字的分带绘制 | 具体画什么 |
|
||||
| `Icons` | 三个位图图标的加载与染色、电池、蓝牙、其余数据项的图元 | 图标该出现在哪个数据位(由字段 id 决定,但查表在这里) |
|
||||
| `Fields` | 75 项字段的取值、单位换算、本地化文案(星期/月份/标签) | 排版 |
|
||||
| `Settings` | 每个设置项的读取与默认值,包含空值回退 | 设置项的 UI 定义(在 `settings.xml`) |
|
||||
| `Fenix8V3View` | `onUpdate` 的绘制顺序、进度环、常亮模式 | 以上任何一项的细节 |
|
||||
|
||||
`Fields.value()` 按分类拆成 7 个函数(`dateTime` / `activity` / `body` / `system` / `environment` / `weather` / `custom`),每个在不认识 id 时返回 `null`,`value()` 依次尝试。id 是交错的(1、2、3 是活动,8、11、12 是身体,14 又是活动),所以按区间派发行不通。
|
||||
|
||||
`Fields.Ctx` 每次绘制构造一个,把 `ActivityMonitor` / `Weather` / `UserProfile` / `SensorHistory` 的查询**懒加载并缓存**——四个数据位可能都要天气,但只查一次;没有数据位用到 `UserProfile` 时就完全不查。
|
||||
|
||||
|
||||
## 2. 布局(500 基准,取自设计稿 SVG 路径的墨迹包围盒)
|
||||
|
||||
| 元素 | 位置 | 说明 |
|
||||
@@ -61,7 +81,7 @@ python3 tools/gen_themes.py && python3 tools/gen_fields.py \
|
||||
| 时间 | `cy=221.10`;小时右对齐 `x=211.40`,分钟左对齐 `x=276.02` | 竖向渐变,见 §4 |
|
||||
| 冒号 | `x=237.88`,`24.24×21.30`,`y=183.68 / 234.57` | 两块矩形 |
|
||||
| 日期带 | `y=286.30`,高 `44.19`,文字 `cy=308.10` | 蓝牙 `cx=36.88`、星期 `cx=178.05`、月日 `cx=298.28`、AM/PM 右对齐 `465.89` |
|
||||
| 底部数值 | `cy=366.76`;距离右对齐 `234.30`,步数左对齐 `267.40` | |
|
||||
| 底部数值 | `cy=366.76`;左格右对齐 `234.30`,右格左对齐 `267.40` | 过宽时自动降一档字号 |
|
||||
| 底部标签 | `cy=410.88`,同上对齐 | 跟随所选数据(`DST` / `STEP` / `距离` …) |
|
||||
|
||||
字号按设计稿的**字面高度(cap height)**选取:日期带与电量 `25.34`、上方数据与底部行 `31.50`、时间 `98.70`。
|
||||
|
||||
Reference in New Issue
Block a user