feat(v2): migrate UI from Walk to Gio

Rewrites internal/ui/window.go in Gio, keeping the Window interface
(NewWindow/Run/Present/PresentAlert/ReportIssue) and the pure-Go ViewModel.
Background updates mutate shared state under a lock and Invalidate; the Gio
loop renders the latest frame. Dual tabs, widget.Image for render's RGBA, a
self-drawn confirm dialog and a MessageBeep sound. Drops lxn/walk (and the
TTM_ADDTOOL/comctl class of problems). Verified via GOOS=windows CGO_ENABLED=0
build of the UI packages; full app build needs Windows+CGo for onnxruntime.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ila
2026-07-23 14:26:19 +08:00
co-authored by Claude Opus 4.8
parent 18e1331f8f
commit 4188a2b06c
6 changed files with 340 additions and 147 deletions
+9
View File
@@ -559,3 +559,12 @@
- 阻塞:真实窗口/声音/弹窗目视需 Windows。
- 决策:后台 `Present/PresentAlert/ReportIssue` 只在带锁共享区更新最新帧/状态/待弹窗并 `Invalidate()`,Gio 事件循环在独立 goroutine 只渲染最新帧(取代 Walk 的 `main.Synchronize`);声音用 Windows `MessageBeep` syscall(`sound_windows.go` + 非 Windows 空实现),弹窗自绘遮罩。`ViewModel` 逻辑复用、`spec_test.go` 不受影响。
- 下一步:写 Gio `window.go` + sound 文件,交叉编译通过后接 `cmd/silver-pose` 验证。
## 【2026-07-23】T-306 V2 UI 从 Walk 迁移到 Gio(代码完成 + 交叉编译验证)
- 状态:DOING(迁移代码完成 + Windows 交叉编译通过;窗口/声音/弹窗目视需 Windows)
- 变更:用 Gio 重写 `v2/internal/ui/window.go`,保持 `Window` 公开接口(`NewWindow/Run/Present/PresentAlert/ReportIssue`)与 `spec.go` 的 `ViewModel`/`MonitorWindowSpec` 不变。后台 `Present/PresentAlert/ReportIssue` 只在带锁共享区更新最新帧/状态/待弹窗并 `Invalidate()`;Gio 事件循环在独立 goroutine 渲染最新帧(取代 Walk 的 `main.Synchronize`)。双 Tab(监控/设置)、`widget.Image` 贴 render 的 `*image.RGBA`、确认弹窗自绘遮罩+“我已知晓”、声音用 `MessageBeep`(`sound_windows.go` syscall + `sound_other.go` 空实现)。`cmd/silver-pose`/`monitor`/`alert` 未改。`go mod tidy` 移除 `lxn/walk`、`lxn/win`、`govaluate.v3`,新增 `golang.org/x/sys`(声音)。
- 验证:`GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./internal/ui/... ./cmd/ui-spike/... ./cmd/gio-spike/...` → 全部退出码 0(Gio Windows 版无 CGo,可对真实 Windows API 型检)。`grep lxn/walk` 全仓库无剩余引用。`cmd/silver-pose` 全量构建需 Windows + `CGO_ENABLED=1`(onnxruntime_go 依赖 CGo,迁移前即如此),本环境无 mingw 故不构建。
- 阻塞:真实窗口显示、声音、弹窗目视需 Windows。`go run ./cmd/ui-spike` 为 CGo-free,可单独目视迁移后的 Gio 窗口外壳;`go run ./cmd/silver-pose` 需 `CGO_ENABLED=1` 起全量管线。
- 决策:`internal/ui` 正式由 Walk 迁至 Gio,彻底消除 comctl/manifest(`TTM_ADDTOOL`)问题;UI 只渲染已判定的最新帧,事件计算仍在后台。
- 下一步:用户 Windows 目视 `go run ./cmd/ui-spike`(外壳)与 `go run ./cmd/silver-pose`(全量,`CGO_ENABLED=1`)确认起窗、贴视频、双 Tab、确认弹窗与声音;通过则 T-306 与 T-304 一并推进 DONE。