Repository navigation
fix(desktop): #1794 标题栏窗口按钮按标题栏文字色着色并使用共享名称 - #1812
Closed
xiaoyumuxi wants to merge 1 commit into
Closed
xiaoyumuxi wants to merge 1 commit into
xiaoyumuxi wants to merge 1 commit into
Conversation
Windows 与 Linux 的最小化、最大化/还原、关闭按钮由 Viva 画在自定义标题栏里。 没有样式时,Viva 按窗口清屏色推字形颜色;Lithe 没设清屏色,Viva 的默认值是深色, 于是字形是白色,浅色标题栏上看不见。 新增 windowcontrols.Style:字形用标题栏文字色,悬停和按下底色用同一颜色的 10% 和 18% 透明度,关闭按钮保留 Viva 的红色;按钮名称取共享 i18n 的 window.minimize/maximize/restore/close(该四条词条加入 desktop 平台)。 工作台、设置窗口和日志窗口都接上这个样式,随外观和语言切换。 功能矩阵 window-controls 的 Windows 状态改为部分实现:命令面板的窗口操作 尚未接入,原生窗口中的按钮行为待在 Windows 与 Linux 验证。
Collaborator
Author
|
改动已直接推入 #1799(e82b29c59),不再单独开 PR,关闭。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
在 Windows 和 Linux 上,Viva 客户端用的是自定义标题栏:最小化、最大化/还原、关闭这三个按钮由 Viva 画、由 Viva 判定点击。
应用不提供样式时,Viva 根据窗口的清屏色(
Config.ClearColor)亮度来选字形颜色。Lithe 没有设置清屏色,而 Viva 的默认清屏色是深色,于是字形是白色。在浅色外观下,白色按钮落在浅色标题栏上,看不见。修法是在应用这一层配置 Viva 已经提供的
app.Config.WindowControls,按每个窗口标题栏实际的文字色来画按钮。Viva 的回退逻辑不需要改:它不知道应用把标题栏画成什么颜色,这个颜色只有应用知道。改动 / Changes
desktop/internal/windowcontrolsStyle(ink, text)返回app.WindowControlsStyle:WindowControls,所以按钮会跟着外观和语言切换。workbench/app.go:工作台,颜色取a.colors.Text。settingswindow/window.go:设置窗口,颜色取w.pal.text。logwindow/window.go:日志窗口,颜色取w.pal.tx。shared/i18n/messages.json:window.minimize、window.maximize、window.restore、window.close这四条已有词条加入desktop平台。已运行generate-i18n.mjs,并提交了生成的shared.generated.go。desktop/internal/i18n:Messages新增Window WindowMessages(Minimize/Maximize/Restore/Close),由windowMessages(language)从共享词条读取,中英文目录都已接入。windowcontrols/style_test.go有三个用例:字形、悬停和按下的颜色取自标题栏文字色,且不改关闭按钮;中英文的按钮名称;没有文字色和目录时返回零值样式。TestWindowControlsFollowTheTitleBar,检查配置里有WindowControls,并且返回的字形颜色等于当前外观的标题栏文字色、名称跟随当前语言。设置窗口和日志窗口在测试中途切换外观并重绘;工作台从深色/中文切到浅色/英文。workbench/app_test.go的 harness 新增config字段,保存交给 driver 的那份配置。测试读取同一份回调,不再第二次调用Config()(它会重新赋值a.fields)。window-controls的 Windows 侧由“尚未盘点”改为partial/pending,证据换成当前的 Viva 代码。说明里写明:命令面板的窗口操作尚未接入,原生窗口中的按钮行为还没在 Windows 和 Linux 上验证。macOS 不变。不在本 PR 范围内 / Out of scope
INFO显示成INFC:这是 Viva 在 Windows 上的问题。等宽的 semibold 文字交给 GDI 画,GDI 为 Consolas 合成出来的 600 字重比格子宽。已向上游提交 windows: leave medium and semibold fixed-pitch runs to Direct2D vivaui/viva#188,Lithe 这边不加绕过代码;上游合入后要单独升级 Viva 依赖。math.MaxUint16),标题栏右侧已按app.TitlebarInsets()让出位置。具体的异常现象需要在 Windows 和 Linux 桌面上实测后再定位。类型专属:fix
复现与根因
WindowControls,Viva 只能按默认的深色清屏色推出白色字形:检查项
已先写回归测试,确认它在修复前失败、修复后通过。测试路径:
desktop/internal/logwindow/window_test.godesktop/internal/settingswindow/general_view_test.godesktop/internal/workbench/app_test.go(三处都是TestWindowControlsFollowTheTitleBar)把三个窗口文件换回 base 版本后,修复前的失败输出是:
[N/A] 无法自动化时的手动步骤:已有自动化测试。原生窗口中的目视检查见“未能执行的检查”。
已搜索全部使用方:
WindowCustomTitlebar只有工作台、设置窗口、日志窗口三处使用,已全部接上;i18n.Messages新字段已加入中英文目录,TestCatalogsAreComplete通过。已检查另一平台:macOS 由系统绘制红绿灯按钮,不受影响;Linux 和 Windows 走同一条 Viva 绘制路径,本 PR 一并修复。
只改了修复所需的代码。顺带发现的 Viva 字形问题已在上游提交 windows: leave medium and semibold fixed-pitch runs to Direct2D vivaui/viva#188。
[N/A] 行为约束 Note:修复只是配置 Viva 已有的接口,没有新增行为约束;三个窗口的回归测试防止复发。
范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/window-controls.json:Windows 侧为partial/pending,证据换成当前 Viva 代码;macOS 未改动。./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(validated 252 platform capabilities)和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/feature/1794-viva-workbench-shell HEAD(passed)。.artifacts/下生成的矩阵视图。统一日志系统 / Structured logging
N/A:没有新增或改动生命周期、终态、降级或失败路径,也没有日志调用。
界面文案 / i18n
window.*词条,加入desktop平台后运行了node scripts/i18n/generate-i18n.mjs,并提交了生成结果,没有手改生成文件。node scripts/i18n/verify-app-language-localization.mjs(passed)和node scripts/i18n/generate-i18n.mjs --check(exit 0,en-US 和 zh-CN 均为 10524/10524)。没有放宽脚本,也没有扩大豁免名单。逻辑归属 / Logic placement
性能与内存 / Performance and memory
WindowControls,它只组装一个值类型结构体:没有分配、I/O 或轮询。没有新增后台功能、子进程、缓存、定时器或依赖。设置 / Settings
N/A:没有新增或修改设置项、设置页或对话框选项。
插件与共享契约 / Plugin and shared contracts
N/A:没有改动
shared/contracts/、插件能力或宿主方法。发行包与资源 / Bundle and resources
N/A:没有新增或修改运行时资源、缓存或下载物。已顺带运行
./scripts/macos/verify/verify-runtime-bundle-immutability.sh,结果通过。无用代码与重构 / Dead code and refactoring
验证 / Verification
./scripts/desktop/desktop-go.sh test ./... -count=1./scripts/desktop/desktop-go.sh test -race ./internal/windowcontrols/ ./internal/logwindow/ ./internal/settingswindow/ ./internal/workbench/ -count=1-run TestWindowControlsFollowTheTitleBarnode scripts/i18n/verify-app-language-localization.mjsnode scripts/i18n/generate-i18n.mjs --checknode --test --test-timeout=60000 scripts/i18n/test-i18n.mjs./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/feature/1794-viva-workbench-shell HEAD./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh./scripts/macos/verify/verify-runtime-bundle-immutability.shgofmt -l(改动的包)未能执行的检查和原因:
Windows 和 Linux 原生窗口的目视检查:没有执行,所以也没有截图或录屏。待检查的是浅色/深色、中/英文下按钮能否看清,以及最小化、最大化/还原、关闭是否正常。
controlsDrawnByViva为 false),无头 driver 也就画不出来。因此,功能矩阵的验证状态保持
pending。Windows 和 Linux 上的
go test:没有执行。改动没有平台专属的 Go 文件,覆盖范围与 macOS 上的测试相同。提交前确认 / Final checks
preview创建:这是 [Feature] Windows/macOS 统一 Viva 工作台与原生编辑器,保留 Rust Core 和插件体系(分阶段重构) #1794 Viva 客户端迁移的后续修复,从feature/1794-viva-workbench-shell创建,目标分支也是它。