feat(ui): 统一实现卡片背景趋势与大数值布局
This commit is contained in:
@@ -12,7 +12,7 @@ Kymo 是 macOS 菜单栏资源监控工具。菜单栏常驻品牌图标,点
|
|||||||
- 网络:接口切换、收发速率与累计字节、路径状态、本地和公网 IP 及复制。
|
- 网络:接口切换、收发速率与累计字节、路径状态、本地和公网 IP 及复制。
|
||||||
- 进程:PID、名称、CPU、内存 footprint、CPU 平均功率、线程数和路径;支持搜索、列排序及复制,功率缺失始终排末。
|
- 进程:PID、名称、CPU、内存 footprint、CPU 平均功率、线程数和路径;支持搜索、列排序及复制,功率缺失始终排末。
|
||||||
|
|
||||||
面板支持固定显示、保持唤醒、暂停 / 恢复采样。概览采用三列两行网格,首行 CPU / GPU / 内存,次行电池 / 存储 / 网络,同一行卡片等高;常规 960×514pt,小屏退为两列或单列,高度不足时滚动;进程页独占内容区。概览停止进程 / footprint / 功率读取,进程页卸载资源图表并停用概览慢读取与公网任务,基础趋势跨页连续。保留彩色卡片,数字、曲线和进度条随采样直接更新,不播放应用自定义动画或背景模糊特效;后台记录独立控制。面板刷新默认 2 秒;默认隐藏停止采样,可显式开启后台趋势并配置间隔(新配置 30 秒)。设置窗口提供系统 / 浅色 / 深色外观、简体中文 / 繁體中文 / English 和关于信息。
|
面板支持固定显示、保持唤醒、暂停 / 恢复采样。概览采用三列两行网格,首行 CPU / GPU / 内存,次行电池 / 存储 / 网络,同一行卡片等高;常规 960×630pt,小屏退为两列或单列,高度不足时滚动;进程页独占内容区。概览停止进程 / footprint / 功率读取,进程页卸载资源图表并停用概览慢读取与公网任务,基础趋势跨页连续。彩色卡片采用大数值与底部背景趋势,淡色面积按真实连续段绘制,悬浮可查询各序列历史;数字、曲线和进度条随采样直接更新,不播放应用自定义动画或背景模糊特效;后台记录独立控制。面板刷新默认 2 秒;默认隐藏停止采样,可显式开启后台趋势并配置间隔(新配置 30 秒)。设置窗口提供系统 / 浅色 / 深色外观、简体中文 / 繁體中文 / English 和关于信息。
|
||||||
|
|
||||||
部分硬件指标依赖机型、驱动与权限,缺失值显示为 `--` 或对应状态。GPU 不提供逐核占用;耗电进程显示系统归属的 CPU 能量区间平均功率,注明可读覆盖范围,不代表完整应用总耗电。指标口径和限制见[监控指标](docs/monitoring.md)。
|
部分硬件指标依赖机型、驱动与权限,缺失值显示为 `--` 或对应状态。GPU 不提供逐核占用;耗电进程显示系统归属的 CPU 能量区间平均功率,注明可读覆盖范围,不代表完整应用总耗电。指标口径和限制见[监控指标](docs/monitoring.md)。
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -9,6 +9,7 @@
|
|||||||
| [开发指南](development.md) | 构建、修改入口、本地化和诊断参数 |
|
| [开发指南](development.md) | 构建、修改入口、本地化和诊断参数 |
|
||||||
| [测试与验证](testing.md) | 统一检查入口、覆盖范围、实际交互与验收边界 |
|
| [测试与验证](testing.md) | 统一检查入口、覆盖范围、实际交互与验收边界 |
|
||||||
| [测试分发](free-test-distribution.md) | 本地 Release 打包、签名与安装支持范围 |
|
| [测试分发](free-test-distribution.md) | 本地 Release 打包、签名与安装支持范围 |
|
||||||
| [卡片背景趋势设计稿](designs/card-background-trends-v1/README.md) | 待评审:浅色 / 深色概览与网络悬浮交互,尚未实施 |
|
| [UI 设计规范](ui-design-standard.md) | 概览卡片尺寸、字体、颜色、背景趋势、交互与信息契约 |
|
||||||
|
| [卡片背景趋势设计稿](designs/card-background-trends-v1/README.md) | 已采纳的浅色 / 深色风格参考,具体实现以设计规范和代码为准 |
|
||||||
|
|
||||||
修改实现时直接更新相应主题;大型变更的临时方案按 [AGENTS.md](../AGENTS.md) 存放在本目录,完成后将有效结论归入主题文档并清理失效记录。
|
修改实现时直接更新相应主题;大型变更的临时方案按 [AGENTS.md](../AGENTS.md) 存放在本目录,完成后将有效结论归入主题文档并清理失效记录。
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ App 装配依赖,方向为 Features → UI → Core → 系统 API。Features
|
|||||||
|
|
||||||
入口 kymoApp.main() 启动 NSApplication,由 ApplicationLifecycle 管理;应用以 accessory 模式启动,通过 NSHostingSceneRepresentation 注册 Settings。
|
入口 kymoApp.main() 启动 NSApplication,由 ApplicationLifecycle 管理;应用以 accessory 模式启动,通过 NSHostingSceneRepresentation 注册 Settings。
|
||||||
|
|
||||||
MenuPanelController 拥有模板品牌 NSStatusItem 和无边框、可成为 key 的非激活 MonitoringPanel。左键切换面板,右键提供打开 / 隐藏、设置和退出。窗口以状态项所在屏幕可见区域为边界,水平居中,边缘至少留 16pt;最大宽 960pt,常规高 514pt,按卡片内容预算调整,最大高 800pt,并受实际屏幕限制。
|
MenuPanelController 拥有模板品牌 NSStatusItem 和无边框、可成为 key 的非激活 MonitoringPanel。左键切换面板,右键提供打开 / 隐藏、设置和退出。窗口以状态项所在屏幕可见区域为边界,水平居中,边缘至少留 16pt;最大宽 960pt,常规高 630pt,按卡片内容预算调整,最大高 800pt,并受实际屏幕限制。
|
||||||
|
|
||||||
每次显式打开进入概览。概览采用三列两行网格:首行 CPU / GPU / 内存,次行电池 / 存储 / 网络。同一行按最高卡片的内容预算等高对齐;两行 CPU 核心与一行风扇时,两行卡片高度分别为 204pt 和 208pt,列宽 308pt。宽度小于 900pt 退为两列三行,小于 560pt 退为单列并将页签另放一行;重排保持上述逐行阅读顺序,高度不足时滚动。进程页独占中间内容区,两页共用窗口尺寸。底栏显示设备信息、开机时间和刷新间隔。
|
每次显式打开进入概览。概览采用三列两行网格:首行 CPU / GPU / 内存,次行电池 / 存储 / 网络。同一行按最高卡片的内容预算等高对齐;两行 CPU 核心与一行风扇时,两行卡片均高 264pt,列宽 308pt;标题、主数值、前景详情和底部 72pt 背景曲线采用统一几何规范。宽度小于 900pt 退为两列三行,小于 560pt 退为单列并将页签另放一行;重排保持上述逐行阅读顺序,高度不足时滚动。进程页独占中间内容区,两页共用窗口尺寸。底栏显示设备信息、开机时间和刷新间隔。
|
||||||
|
|
||||||
核心数由静态拓扑、硬件核数及快照共同确定;核心单元格按宽度增加行数,避免文字挤压。风扇在本次打开保留已发现槽位。实际卡片宽度和窗口 contentLayoutRect 驱动布局;仅结构预算变化才请求调整窗口高度。
|
核心数由静态拓扑、硬件核数及快照共同确定;核心单元格按宽度增加行数,避免文字挤压。风扇在本次打开保留已发现槽位。实际卡片宽度和窗口 contentLayoutRect 驱动布局;仅结构预算变化才请求调整窗口高度。
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ SystemSampler actor 持有差分基线。CPU / 内存 Mach 查询取得的 host
|
|||||||
|
|
||||||
## 展示与本地状态
|
## 展示与本地状态
|
||||||
|
|
||||||
ResourceCard 通过 NativeContentHost 使用固定尺寸的独立 NSHostingView,完整传递字体、颜色、语言及外观环境;更新沿用挂载身份,卸载清空子宿主内容。图表锚点和提示层在同一卡片宿主内处理。NativePanelCurve 绘制静态曲线、网格和悬浮标记,只在数据、几何或外观变化时更新。数字和进度条直接展示最终值;不创建应用自定义动画、面积渐变、遮罩、背景模糊或装饰阴影。
|
ResourceCard 通过 NativeContentHost 使用固定尺寸的独立 NSHostingView,完整传递字体、颜色、语言及外观环境;更新沿用挂载身份,卸载清空子宿主内容。图表锚点和提示层在同一卡片宿主内处理。NativePanelCurve 绘制静态曲线、逐连续段闭合的低透明度实色面积和悬浮标记,只在数据、几何或外观变化时更新;悬浮沿用曲线 / 面积几何。ResourceCard 独立排列标题、大数值和详情,将 72pt 趋势贴合卡片底部,并统一 20pt 圆角、16pt 内边距和静态轻阴影。概览不显示常驻图例、坐标轴、网格或起止时间;CPU / GPU / 内存 / 电池仅绘制主序列,存储 / 网络绘制双序列,全部已有序列仍可悬浮查询。数字和进度条直接展示最终值;曲线绘图不创建动画、渐变或遮罩图层,卡片圆角裁切由宿主处理,不使用背景模糊。样式、指标前景契约和异常状态见 [UI 设计规范](ui-design-standard.md)。
|
||||||
|
|
||||||
概览与设置共享 NeutralTabPicker,使用静态 AppKit 按钮组;保留 tabGroup / tabButton 语义、选中值与键盘导航。绑定仅传递选择,页面和采样生命周期由上层负责。
|
概览与设置共享 NeutralTabPicker,使用静态 AppKit 按钮组;保留 tabGroup / tabButton 语义、选中值与键盘导航。绑定仅传递选择,页面和采样生命周期由上层负责。
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
用户已确认背景趋势设计图,并要求先制定标准再统一实现。目标是让六张资源卡片遵循统一的“大数值 + 前景详情 + 底部背景趋势”结构,保留数据口径与已有功能。标准见 [UI 设计规范](ui-design-standard.md)。
|
用户已确认背景趋势设计图,并要求先制定标准再统一实现。目标是让六张资源卡片遵循统一的“大数值 + 前景详情 + 底部背景趋势”结构,保留数据口径与已有功能。标准见 [UI 设计规范](ui-design-standard.md)。
|
||||||
|
|
||||||
## 现状与影响范围
|
## 变更前现状与影响范围
|
||||||
|
|
||||||
当前 ResourceCard 将主值放在标题行,PanelTrendChart 自带图例 / 轴 / 网格 / 时间,卡片常规高约 204–208pt。涉及 UI/Components(卡片、样式)、UI/Charts(曲线、填充、提示)、Features/MenuBar(六卡内容、几何预算)、kymoTests 与 tools/check.py(检查入口)及 docs。Core 采样、XPC、App 生命周期、Settings 与进程业务不变;资源色继续使用 Assets。
|
变更前 ResourceCard 将主值放在标题行,PanelTrendChart 自带图例 / 轴 / 网格 / 时间,卡片常规高约 204–208pt。涉及 UI/Components(卡片、样式)、UI/Charts(曲线、填充、提示)、Features/MenuBar(六卡内容、几何预算)、kymoTests 与 tools/check.py(检查入口)及 docs。Core 采样、XPC、App 生命周期、Settings 与进程业务不变;资源色继续使用 Assets。
|
||||||
|
|
||||||
## 设计方案
|
## 设计方案
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ ResourceCard 统一容纳独立前景和底部 chart,主值与单位分层。N
|
|||||||
1. 制定规范与计划,先提交文档。
|
1. 制定规范与计划,先提交文档。
|
||||||
2. 实现统一卡片、背景曲线与面积;迁移六张卡片及动态尺寸。
|
2. 实现统一卡片、背景曲线与面积;迁移六张卡片及动态尺寸。
|
||||||
3. 更新行为检查并构建;检查浅深色、三语、硬件行数与窄屏。
|
3. 更新行为检查并构建;检查浅深色、三语、硬件行数与窄屏。
|
||||||
4. 在隔离应用副本中核对展示与交互;同步架构、指标、测试文档,清理测试产物,提交实现。
|
4. 在隔离应用副本中核对展示与交互;同步架构、指标、测试文档,清理测试产物,提交实现,并输出独立目录的本地测试分发包。
|
||||||
|
|
||||||
用户未设置阶段暂停点,各阶段按顺序连续执行。
|
用户未设置阶段暂停点,各阶段按顺序连续执行。
|
||||||
|
|
||||||
@@ -36,6 +36,28 @@ ResourceCard 统一容纳独立前景和底部 chart,主值与单位分层。N
|
|||||||
## 进度与验证记录
|
## 进度与验证记录
|
||||||
|
|
||||||
- [x] 规范与实施计划制定。
|
- [x] 规范与实施计划制定。
|
||||||
- [ ] 统一组件与六卡迁移。
|
- [x] 统一组件与六卡迁移。
|
||||||
- [ ] 构建与自动检查。
|
- [x] 构建与自动检查。
|
||||||
- [ ] 实际应用核对与文档同步。
|
- [x] 本机可执行的实际应用核对与文档同步,人工验收边界见下。
|
||||||
|
|
||||||
|
### 本轮证据(2026-11-15)
|
||||||
|
|
||||||
|
- 规范 / 计划先提交为 3971562,随后实施。未新增依赖,Core、XPC 与采样口径未改动。
|
||||||
|
- Debug 与 Release xcodebuild 均通过;仅有工具链“无 AppIntents 依赖,跳过元数据提取”提示,无 Swift 编译警告。
|
||||||
|
- tools/check.py 通过 14 项独立 Swift 检查:PanelLayoutChecks、CPUCoreGridChecks、PanelCurveChecks、NativeMetricDrawingChecks、ResourceCardChecks、NativeContentHostChecks、PanelWindowChecks、MemoryHeaderChecks、PanelAssetChecks、LocalizationChecks、LanguageScopeChecks、TabPickerChecks、NativeProcessTableChecks、DetailDemandChecks;145 个资源键三语 / 参数检查与主应用 entitlement 检查通过。
|
||||||
|
- 主值单位排版、单位对比度与提示定位细化后,重新运行 ResourceCardChecks、NativeMetricDrawingChecks,通过。生产卡片在 266 / 308 / 460pt、浅深色、三语与长双速率 / 百分比下挂载检查通过;原生图区均为贴底 72pt,前景与图区隔离。
|
||||||
|
- 使用随机 bundle ID 的独立 Debug 副本,主应用 / XPC 保持签名认证。面板自身截图核对:简体浅 / 深色 960×630,英文两列 800×500,繁体深色单列 480×500;未采集桌面。
|
||||||
|
- 原生 AX 操作确认:暂停 / 恢复(恢复首帧出现差分缺失符合既有规则)、网络从全部切到 en0、本地卷弹出层打开 / Cancel 关闭、繁体单列滚动条从 0 变化、进程页与概览切换及卡片恢复。
|
||||||
|
- 曾遇到 Mac 锁屏;用户解锁后继续验证。锁屏前的英文两列已完成展示检查,锁屏期间没有继续投递原生交互。
|
||||||
|
|
||||||
|
### 未验证与人工验收
|
||||||
|
|
||||||
|
- UI 工具对图表 AX 元素的点击未取得有效悬浮证据(采集时 hoveredPlots 为 0),不能将它当成真实指针悬浮已通过。自动检查覆盖了悬浮标记、缺失点与几何缓存;请在任一卡片底部趋势移动鼠标,核对时间 / 各序列值提示、定位点、离开后消失、主数值保持实时且提示不盖住复制控件。
|
||||||
|
- 长 IPv6 使用既有全文提示 / 选择 / 复制路径,但本轮未遇到真实长 IPv6 环境;真实多显示器、主观外观与长期 CPU / 内存 / 能耗仍需对应环境验收。短时资源或截图不作长期性能结论。
|
||||||
|
- 分发包按实现提交输出至 dist 的独立子目录,保留已有产物,不自动改版本号。没有安装替换用户当前运行的 /Applications/kymo.app。
|
||||||
|
|
||||||
|
### 分发与清理
|
||||||
|
|
||||||
|
- 本地 Release 包:`dist/background-trends-v1/kymo-1.2-14-arm64-adhoc.zip`,arm64,最低 macOS 27.0;主应用与 XPC 原始签名 / 解压签名、Hardened Runtime、权限和归档内容检查通过,SHA-256 复核通过。
|
||||||
|
- SHA-256:`05af0be97d93a96d2e47583f595fbdd26a3dd117023177b6fe1ff0d60bfc6aa1`。本地 ad-hoc 签名,未公证;不代表其他 Mac 默认 Gatekeeper 放行。
|
||||||
|
- 随机测试副本、其容器、局部截图、临时脚本与 DerivedData 已清理。仅终止本轮测试路径下的进程,未操作用户安装副本;分发产物位于 Git 忽略目录。
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
日期:2026-11-15。基于当前三列两行概览与用户提供的下载卡片参考图。
|
日期:2026-11-15。基于当前三列两行概览与用户提供的下载卡片参考图。
|
||||||
|
|
||||||
**状态:待评审设计,不是应用截图,未实施。** 本次仅新增设计交付;现有 UI、采样、进程页、设置与分发包均未修改。当前实现仍以 architecture.md 为准。
|
**状态:用户已确认并采纳。图片是风格参考,不是应用截图。** 可执行标准见 [UI 设计规范](../../ui-design-standard.md),实施与验证见 [实施计划](../../card-background-trends-plan.md),当前实现以 [架构](../../architecture.md) 和代码为准。
|
||||||
|
|
||||||
## 设计图
|
## 设计图
|
||||||
|
|
||||||
@@ -43,9 +43,9 @@
|
|||||||
- 图片由内置 image_gen 生成,用于评审风格与层级,不是像素级组件规格;图中的数据为示例,IP 使用文档示例地址。
|
- 图片由内置 image_gen 生成,用于评审风格与层级,不是像素级组件规格;图中的数据为示例,IP 使用文档示例地址。
|
||||||
- CPU 核心区的格子是生成图中的粗略示意,数量及填色不作为实现依据。落地时应保留真实逐核数值 / 短条及拓扑分组,不把“能效核 4 / 性能核 10”做成亮灯数量。
|
- CPU 核心区的格子是生成图中的粗略示意,数量及填色不作为实现依据。落地时应保留真实逐核数值 / 短条及拓扑分组,不把“能效核 4 / 性能核 10”做成亮灯数量。
|
||||||
- 背景曲线需表达真实数值、时间和缺失状态,不能为了装饰随意改变振幅、补点或添加动态波纹。
|
- 背景曲线需表达真实数值、时间和缺失状态,不能为了装饰随意改变振幅、补点或添加动态波纹。
|
||||||
- 目前实现不使用面积渐变或装饰阴影;如采用本方案,需单独确认静态填充、阴影与性能预算,并同步更新架构约束。本次没有变更这些约束。
|
- 已采纳静态实色透明填充与轻阴影;不使用面积渐变或动画。具体参数与性能约束以 UI 设计规范为准。
|
||||||
- 生成图中的品牌图标、硬件图标、箭头与刷新控件是视觉示意;实际采用仓库品牌素材、现有系统图标和可编辑刷新控件。
|
- 生成图中的品牌图标、硬件图标、箭头与刷新控件是视觉示意;实际采用仓库品牌素材、现有系统图标和可编辑刷新控件。
|
||||||
- 卡片尺寸仅表达比例;精确字号、圆角、主数值溢出、三语、窄屏、悬浮定位、图表多序列尺度及缺失状态需在实施阶段细化与验证。
|
- 效果图中的卡片尺寸仅表达比例;精确字号、圆角、主值适配、三语、窄屏、悬浮、多序列尺度及缺失状态已归入 UI 设计规范,验证结果见实施计划。
|
||||||
|
|
||||||
## 生成方式与提示词
|
## 生成方式与提示词
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ Debug 或显式 KYMO_AUDIT 构建可设置 KYMO_RESOURCE_AUDIT=1 驱动三轮真
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| KYMO_AUDIT_QUICK=1 | 缩短隐藏等待并跳过暂停阶段 |
|
| KYMO_AUDIT_QUICK=1 | 缩短隐藏等待并跳过暂停阶段 |
|
||||||
| KYMO_AUDIT_PAGE=processes | 每轮打开后进入进程页 |
|
| KYMO_AUDIT_PAGE=processes | 每轮打开后进入进程页 |
|
||||||
| KYMO_AUDIT_CAPTURE=1 | 第一轮打开 10 秒后输出本应用面板 PNG 的 JSON 事件 |
|
| KYMO_AUDIT_CAPTURE=1 | 第一轮打开 10 秒后输出本应用面板 PNG 的 JSON 事件;与 INTERACTIVE / SIZE 组合时截取对应视口 |
|
||||||
| KYMO_AUDIT_INTERACTIVE=1 | 打开固定面板供人工 / UI 工具操作,不自动退出 |
|
| KYMO_AUDIT_INTERACTIVE=1 | 打开固定面板供人工 / UI 工具操作,不自动退出 |
|
||||||
| KYMO_AUDIT_SIZE=480x500 | 交互模式限制测试视口,不覆盖自动尺寸;最小 480×360pt |
|
| KYMO_AUDIT_SIZE=480x500 | 交互模式限制测试视口,不覆盖自动尺寸;最小 480×360pt |
|
||||||
| KYMO_XPC_AUDIT=1 | 运行请求重复 / 并发完成、超时及取消检查后退出 |
|
| KYMO_XPC_AUDIT=1 | 运行请求重复 / 并发完成、超时及取消检查后退出 |
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
趋势图跳过无值节点,按真实时间连接前后有效点;有效 0 仍绘制,暂停 / 休眠等显式断点及真实采样空档仍断线。连接只影响曲线外观:缺失时刻悬浮读数为 `--`,原历史不补值。
|
趋势图跳过无值节点,按真实时间连接前后有效点;有效 0 仍绘制,暂停 / 休眠等显式断点及真实采样空档仍断线。连接只影响曲线外观:缺失时刻悬浮读数为 `--`,原历史不补值。
|
||||||
|
|
||||||
|
概览趋势贴合卡片底部,不显示常驻坐标轴、网格或图例。CPU / GPU / 内存 / 电池默认显示总量或电量主曲线,悬浮保留各原有序列读数(电池功率独立标 W);存储与网络显示读写 / 收发双曲线。静态淡色面积仅在真实连续段内闭合,不跨暂停或长空档;单点只显示真实点。悬浮不会替换上方实时主数值。
|
||||||
|
|
||||||
## 数据来源
|
## 数据来源
|
||||||
|
|
||||||
| 指标 | 实现与来源 | 口径与边界 |
|
| 指标 | 实现与来源 | 口径与边界 |
|
||||||
|
|||||||
+2
-1
@@ -38,7 +38,8 @@ python3 tools/check.py --list
|
|||||||
| NetworkAddressChecks、ProcessIconCacheChecks | 沙盒下地址格式 / 速率;图标位图、尺寸、共享、过期、LRU 与严格预算 |
|
| NetworkAddressChecks、ProcessIconCacheChecks | 沙盒下地址格式 / 速率;图标位图、尺寸、共享、过期、LRU 与严格预算 |
|
||||||
| AppearancePreferencesChecks、LocalizationChecks、PresentationChecks | 外观与偏好隔离、语言持久化、编译资源、窗口显式 / 系统外观切换 |
|
| AppearancePreferencesChecks、LocalizationChecks、PresentationChecks | 外观与偏好隔离、语言持久化、编译资源、窗口显式 / 系统外观切换 |
|
||||||
| CodeIdentityChecks、PanelAssetChecks、KeepAwakeChecks | 签名身份拒绝边界、编译颜色及对比度、真实 IOPM 断言开关与释放 |
|
| CodeIdentityChecks、PanelAssetChecks、KeepAwakeChecks | 签名身份拒绝边界、编译颜色及对比度、真实 IOPM 断言开关与释放 |
|
||||||
| NativeMetricDrawingChecks(--gui) | 实际曲线像素、直接稳定更新、缺失点接续与真实断点、悬浮缓存、无动画 / 渐变 / 遮罩、卸载 |
|
| NativeMetricDrawingChecks(--gui) | 实际曲线 / 静态面积像素、单点无虚构填充、隐藏序列隔离、缺失点接续与真实断点、悬浮缓存、无动画 / 渐变 / 遮罩、卸载 |
|
||||||
|
| ResourceCardChecks(--gui) | 生产卡片与曲线真实挂载,266 / 308 / 460pt、浅深色及三语下的贴边图区、前景隔离和卸载 |
|
||||||
| NativeContentHostChecks(--gui) | 数字更新、父环境继承、挂载身份、有限尺寸和卸载 |
|
| NativeContentHostChecks(--gui) | 数字更新、父环境继承、挂载身份、有限尺寸和卸载 |
|
||||||
| NativeProcessTableChecks(--gui) | 原生虚拟表格、原地更新、身份选择、排序 / 列序 / 复制 / 三语列头、合成 Esc 投递 |
|
| NativeProcessTableChecks(--gui) | 原生虚拟表格、原地更新、身份选择、排序 / 列序 / 复制 / 三语列头、合成 Esc 投递 |
|
||||||
| TabPickerChecks、LanguageScopeChecks、SettingsWindowChecks(--gui) | 原生页签选择与键盘、已挂载语言即时切换、设置焦点 / 最小化恢复 / Dock 生命周期 |
|
| TabPickerChecks、LanguageScopeChecks、SettingsWindowChecks(--gui) | 原生页签选择与键盘、已挂载语言即时切换、设置焦点 / 最小化恢复 / Dock 生命周期 |
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ struct MemoryDetailsView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 3) {
|
VStack(alignment: .leading, spacing: 3) {
|
||||||
CardSeparator()
|
|
||||||
CapacityBar(values: values.map { Double($0) }, colors: colors, total: Double(memory.total))
|
CapacityBar(values: values.map { Double($0) }, colors: colors, total: Double(memory.total))
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
ForEach(0..<4) { index in
|
ForEach(0..<4) { index in
|
||||||
|
|||||||
@@ -6,24 +6,37 @@ extension MenuPanelView {
|
|||||||
ResourceCard(
|
ResourceCard(
|
||||||
title: "metric.network", symbol: "network", color: Color("MetricNetwork"), value: "↓ " + MetricFormat.rate(total(\.download)),
|
title: "metric.network", symbol: "network", color: Color("MetricNetwork"), value: "↓ " + MetricFormat.rate(total(\.download)),
|
||||||
secondaryValue: "↑ " + MetricFormat.rate(total(\.upload)), valueColor: Color("MetricMemory"),
|
secondaryValue: "↑ " + MetricFormat.rate(total(\.upload)), valueColor: Color("MetricMemory"),
|
||||||
secondaryValueColor: Color("SeriesUpload")
|
secondaryValueColor: Color("SeriesUpload"), headerAccessory: AnyView(networkInterfacePicker),
|
||||||
) {
|
chart: {
|
||||||
PanelTrendChart(
|
PanelTrendChart(
|
||||||
dates: networkDates, first: networkDownloads, second: networkUploads, color: Color("MetricMemory"),
|
dates: networkDates, first: networkDownloads, second: networkUploads, color: Color("MetricMemory"),
|
||||||
secondColor: Color("SeriesUpload"), fixedScale: nil, firstLabel: "network.download", secondLabel: "network.upload",
|
secondColor: Color("SeriesUpload"), fixedScale: nil, firstLabel: "network.download", secondLabel: "network.upload",
|
||||||
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: networkIntervals, showsLegendValues: false
|
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: networkIntervals, visibleSeriesCount: 2
|
||||||
).id(selectedInterface)
|
).id(selectedInterface)
|
||||||
CardSeparator()
|
}
|
||||||
HStack(alignment: .top, spacing: 8) {
|
) {
|
||||||
|
HStack(spacing: 12) {
|
||||||
networkTotal(
|
networkTotal(
|
||||||
"network.received", value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received }),
|
"network.received", value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received }),
|
||||||
symbol: "arrow.down", color: Color("MetricMemory"))
|
symbol: "arrow.down", color: Color("MetricMemory"))
|
||||||
Divider().frame(height: 32)
|
|
||||||
networkTotal(
|
networkTotal(
|
||||||
"network.sent", value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent }),
|
"network.sent", value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent }),
|
||||||
symbol: "arrow.up", color: Color("SeriesUpload"))
|
symbol: "arrow.up", color: Color("SeriesUpload"))
|
||||||
Divider().frame(height: 32)
|
}
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(spacing: 4) {
|
||||||
|
networkAddress("network.public", address: publicIPAddress)
|
||||||
|
networkAddress(
|
||||||
|
"network.local",
|
||||||
|
address: addressInterface?.addresses.first(where: { !$0.contains(":") }) ?? addressInterface?.addresses.first)
|
||||||
|
}
|
||||||
|
.font(PanelStyle.label)
|
||||||
|
.accessibilityElement(children: .contain)
|
||||||
|
.accessibilityLabel(Text("network.addresses"))
|
||||||
|
}
|
||||||
|
.modifier(PanelPublicIPRefresh(metrics: metrics, address: $publicIPAddress))
|
||||||
|
}
|
||||||
|
|
||||||
|
private var networkInterfacePicker: some View {
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
Circle().fill(networkStatusColor).frame(width: 5, height: 5)
|
Circle().fill(networkStatusColor).frame(width: 5, height: 5)
|
||||||
Picker("panel.interface", selection: $selectedInterface) {
|
Picker("panel.interface", selection: $selectedInterface) {
|
||||||
@@ -31,25 +44,13 @@ extension MenuPanelView {
|
|||||||
ForEach(snapshot.network ?? [], id: \.identity) { item in
|
ForEach(snapshot.network ?? [], id: \.identity) { item in
|
||||||
Text(verbatim: item.name).tag(item.identity)
|
Text(verbatim: item.name).tag(item.identity)
|
||||||
}
|
}
|
||||||
}.labelsHidden().controlSize(.mini).fixedSize()
|
}.labelsHidden().controlSize(.mini).frame(maxWidth: 100)
|
||||||
}
|
}
|
||||||
Text(networkStatusLabel).help(Text(networkStatusLabel))
|
.help(Text(networkStatusLabel))
|
||||||
}.frame(maxWidth: .infinity, alignment: .leading)
|
|
||||||
}.font(PanelStyle.label).lineLimit(1)
|
|
||||||
CardSeparator()
|
|
||||||
HStack(spacing: 8) {
|
|
||||||
networkAddress("network.public", address: publicIPAddress)
|
|
||||||
Divider().frame(height: 15)
|
|
||||||
networkAddress(
|
|
||||||
"network.local",
|
|
||||||
address: addressInterface?.addresses.first(where: { !$0.contains(":") }) ?? addressInterface?.addresses.first)
|
|
||||||
}.font(PanelStyle.label)
|
|
||||||
.modifier(CardInset())
|
|
||||||
.accessibilityElement(children: .contain)
|
.accessibilityElement(children: .contain)
|
||||||
.accessibilityLabel(Text("network.addresses"))
|
.accessibilityValue(Text(networkStatusLabel))
|
||||||
}
|
|
||||||
.modifier(PanelPublicIPRefresh(metrics: metrics, address: $publicIPAddress))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func networkAddress(_ title: LocalizedStringKey, address: String?) -> some View {
|
func networkAddress(_ title: LocalizedStringKey, address: String?) -> some View {
|
||||||
HStack(spacing: 3) {
|
HStack(spacing: 3) {
|
||||||
Text(title).foregroundStyle(.secondary)
|
Text(title).foregroundStyle(.secondary)
|
||||||
|
|||||||
@@ -10,6 +10,15 @@ extension MenuPanelView {
|
|||||||
}.frame(height: 14)
|
}.frame(height: 14)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func inlineMetric(_ title: LocalizedStringKey, _ value: String) -> some View {
|
||||||
|
HStack(spacing: 4) {
|
||||||
|
Text(title).foregroundStyle(.secondary)
|
||||||
|
MetricText(value: value).fontWeight(.medium)
|
||||||
|
}
|
||||||
|
.font(.system(size: 11)).lineLimit(1).minimumScaleFactor(0.8)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
|
||||||
func batteryPowerLabel(_ battery: BatteryMetrics) -> LocalizedStringKey {
|
func batteryPowerLabel(_ battery: BatteryMetrics) -> LocalizedStringKey {
|
||||||
if battery.charging { return "battery.chargePower" }
|
if battery.charging { return "battery.chargePower" }
|
||||||
if !battery.externalPower { return "battery.dischargePower" }
|
if !battery.externalPower { return "battery.dischargePower" }
|
||||||
@@ -24,15 +33,20 @@ extension MenuPanelView {
|
|||||||
value: MetricFormat.percent(snapshot.cpu?.usage),
|
value: MetricFormat.percent(snapshot.cpu?.usage),
|
||||||
status: temperature.map { "\(Int($0.rounded()))°C" },
|
status: temperature.map { "\(Int($0.rounded()))°C" },
|
||||||
statusWarning: highTemperature,
|
statusWarning: highTemperature,
|
||||||
warningText: highTemperature ? Text("cpu.temperature.high", tableName: "CPUDetails") : nil
|
warningText: highTemperature ? Text("cpu.temperature.high", tableName: "CPUDetails") : nil,
|
||||||
) {
|
chart: {
|
||||||
PanelTrendChart(
|
PanelTrendChart(
|
||||||
dates: samples.map(\.date), first: samples.map(\.cpu),
|
dates: samples.map(\.date), first: samples.map(\.cpu),
|
||||||
second: samples.map(\.cpuUser), third: samples.map(\.cpuSystem),
|
second: samples.map(\.cpuUser), third: samples.map(\.cpuSystem),
|
||||||
color: Color("MetricCPU"), secondColor: Color("SeriesUser"), thirdColor: Color("SeriesSystem"),
|
color: Color("MetricCPU"), secondColor: Color("SeriesUser"), thirdColor: Color("SeriesSystem"),
|
||||||
firstLabel: "gpu.totalUtilization", secondLabel: "cpu.user", thirdLabel: "cpu.system", expectedInterval: chartInterval,
|
firstLabel: "gpu.totalUtilization", secondLabel: "cpu.user", thirdLabel: "cpu.system", expectedInterval: chartInterval,
|
||||||
boundaryDates: chartBoundaries, intervals: chartIntervals)
|
boundaryDates: chartBoundaries, intervals: chartIntervals)
|
||||||
CardSeparator()
|
}
|
||||||
|
) {
|
||||||
|
HStack(spacing: 12) {
|
||||||
|
inlineMetric("cpu.user", MetricFormat.percent(snapshot.cpu?.user))
|
||||||
|
inlineMetric("cpu.system", MetricFormat.percent(snapshot.cpu?.system))
|
||||||
|
}.frame(height: 14)
|
||||||
if let cpu = snapshot.cpu {
|
if let cpu = snapshot.cpu {
|
||||||
CPUCoreGrid(
|
CPUCoreGrid(
|
||||||
values: cpu.cores, kinds: CPUCoreTopology.cores,
|
values: cpu.cores, kinds: CPUCoreTopology.cores,
|
||||||
@@ -48,17 +62,22 @@ extension MenuPanelView {
|
|||||||
return ResourceCard(
|
return ResourceCard(
|
||||||
title: "metric.gpu", symbol: "square.grid.2x2", color: Color("MetricGPU"), value: MetricFormat.percent(snapshot.gpuUsage),
|
title: "metric.gpu", symbol: "square.grid.2x2", color: Color("MetricGPU"), value: MetricFormat.percent(snapshot.gpuUsage),
|
||||||
status: snapshot.gpuTemperature.map { "\(Int($0.rounded()))°C" },
|
status: snapshot.gpuTemperature.map { "\(Int($0.rounded()))°C" },
|
||||||
detail: snapshot.gpu?.coreCount.map { String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), $0) }
|
detail: snapshot.gpu?.coreCount.map { String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), $0) },
|
||||||
) {
|
chart: {
|
||||||
PanelTrendChart(
|
PanelTrendChart(
|
||||||
dates: samples.map(\.date), first: samples.map(\.gpu),
|
dates: samples.map(\.date), first: samples.map(\.gpu),
|
||||||
second: samples.map(\.gpuRenderer), third: samples.map(\.gpuTiler),
|
second: samples.map(\.gpuRenderer), third: samples.map(\.gpuTiler),
|
||||||
color: Color("MetricGPU"), secondColor: Color("MetricCPU"), thirdColor: Color("SeriesSystem"),
|
color: Color("MetricGPU"), secondColor: Color("MetricCPU"), thirdColor: Color("SeriesSystem"),
|
||||||
firstLabel: "gpu.totalUtilization", secondLabel: "gpu.renderer", thirdLabel: "gpu.tiler",
|
firstLabel: "gpu.totalUtilization", secondLabel: "gpu.renderer", thirdLabel: "gpu.tiler",
|
||||||
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals)
|
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
HStack(spacing: 12) {
|
||||||
|
inlineMetric("gpu.renderer", MetricFormat.percent(snapshot.gpu?.renderer))
|
||||||
|
inlineMetric("gpu.tiler", MetricFormat.percent(snapshot.gpu?.tiler))
|
||||||
|
}.frame(height: 14)
|
||||||
let fans = displayedFans
|
let fans = displayedFans
|
||||||
if !fans.isEmpty {
|
if !fans.isEmpty {
|
||||||
CardSeparator()
|
|
||||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 10), count: min(2, fans.count)), spacing: 4) {
|
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 10), count: min(2, fans.count)), spacing: 4) {
|
||||||
ForEach(fans) { fan in
|
ForEach(fans) { fan in
|
||||||
FanSpeedIndicator(
|
FanSpeedIndicator(
|
||||||
@@ -68,12 +87,9 @@ extension MenuPanelView {
|
|||||||
.frame(height: 16)
|
.frame(height: 16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.modifier(CardInset())
|
|
||||||
} else if snapshot.fans == nil {
|
} else if snapshot.fans == nil {
|
||||||
CardSeparator()
|
|
||||||
Text("metric.waiting").font(PanelStyle.label)
|
Text("metric.waiting").font(PanelStyle.label)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading).frame(height: 16)
|
.frame(maxWidth: .infinity, alignment: .leading).frame(height: 16)
|
||||||
.modifier(CardInset())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,22 +102,22 @@ extension MenuPanelView {
|
|||||||
String(format: "%.1f / %.0f GiB", Double($0.used) / 1_073_741_824, Double($0.total) / 1_073_741_824)
|
String(format: "%.1f / %.0f GiB", Double($0.used) / 1_073_741_824, Double($0.total) / 1_073_741_824)
|
||||||
} ?? "--",
|
} ?? "--",
|
||||||
status: snapshot.memory.map { MetricFormat.percent($0.usage) },
|
status: snapshot.memory.map { MetricFormat.percent($0.usage) },
|
||||||
detail: header.title, detailColor: header.color, detailHelp: header.help
|
detail: header.title, detailColor: header.color, detailHelp: header.help,
|
||||||
) {
|
chart: {
|
||||||
PanelTrendChart(
|
PanelTrendChart(
|
||||||
dates: samples.map(\.date),
|
dates: samples.map(\.date),
|
||||||
first: samples.map { $0.memory.map { $0 * Double(snapshot.memory?.total ?? 1) } },
|
first: samples.map { $0.memory.map { $0 * Double(snapshot.memory?.total ?? 1) } },
|
||||||
second: samples.map(\.memoryApp), third: samples.map(\.memoryWired), fourth: samples.map(\.memoryCompressed),
|
second: samples.map(\.memoryApp), third: samples.map(\.memoryWired), fourth: samples.map(\.memoryCompressed),
|
||||||
color: Color("MetricCPU"), secondColor: Color("MemoryApplication"),
|
color: Color("MemoryApplication"), secondColor: Color("MemoryApplication"),
|
||||||
thirdColor: Color("MemoryWired"), fourthColor: Color("MemoryCompressed"), fixedScale: Double(snapshot.memory?.total ?? 1),
|
thirdColor: Color("MemoryWired"), fourthColor: Color("MemoryCompressed"), fixedScale: Double(snapshot.memory?.total ?? 1),
|
||||||
scaleLabel: MetricFormat.memory(snapshot.memory?.total), firstValueFormat: .memory, firstLabel: "gpu.totalUtilization",
|
firstValueFormat: .memory, firstLabel: "gpu.totalUtilization",
|
||||||
secondLabel: "memory.app", thirdLabel: "memory.wired", fourthLabel: "memory.compressed",
|
secondLabel: "memory.app", thirdLabel: "memory.wired", fourthLabel: "memory.compressed",
|
||||||
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals,
|
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals)
|
||||||
showsLegendValues: cardContentWidth >= 340)
|
}
|
||||||
|
) {
|
||||||
if let memory = snapshot.memory {
|
if let memory = snapshot.memory {
|
||||||
MemoryDetailsView(memory: memory)
|
MemoryDetailsView(memory: memory)
|
||||||
} else {
|
} else {
|
||||||
CardSeparator()
|
|
||||||
Text("metric.waiting").foregroundStyle(.secondary)
|
Text("metric.waiting").foregroundStyle(.secondary)
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
}
|
}
|
||||||
@@ -114,15 +130,19 @@ extension MenuPanelView {
|
|||||||
String(
|
String(
|
||||||
format: "%.0f / %.0f GB", Double($0.total - min($0.total, $0.available)) / 1_000_000_000,
|
format: "%.0f / %.0f GB", Double($0.total - min($0.total, $0.available)) / 1_000_000_000,
|
||||||
Double($0.total) / 1_000_000_000)
|
Double($0.total) / 1_000_000_000)
|
||||||
} ?? "--"
|
} ?? "--",
|
||||||
) {
|
chart: {
|
||||||
|
|
||||||
PanelTrendChart(
|
PanelTrendChart(
|
||||||
dates: samples.map(\.date), first: samples.map(\.read), second: samples.map(\.write), color: Color("MetricDisk"),
|
dates: samples.map(\.date), first: samples.map(\.read), second: samples.map(\.write), color: Color("MetricDisk"),
|
||||||
secondColor: Color("MetricNetwork"), fixedScale: nil, firstLabel: "disk.read", secondLabel: "disk.write",
|
secondColor: Color("MetricNetwork"), fixedScale: nil, firstLabel: "disk.read", secondLabel: "disk.write",
|
||||||
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals
|
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals, visibleSeriesCount: 2
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
HStack(spacing: 12) {
|
||||||
|
inlineMetric("disk.read", MetricFormat.rate(snapshot.diskIO?.read))
|
||||||
|
inlineMetric("disk.write", MetricFormat.rate(snapshot.diskIO?.written))
|
||||||
|
}.frame(height: 14)
|
||||||
StorageDetailsView(disk: snapshot.disk, health: snapshot.diskHealth) {
|
StorageDetailsView(disk: snapshot.disk, health: snapshot.diskHealth) {
|
||||||
showVolumes.toggle()
|
showVolumes.toggle()
|
||||||
}
|
}
|
||||||
@@ -150,8 +170,8 @@ extension MenuPanelView {
|
|||||||
var batteryCard: some View {
|
var batteryCard: some View {
|
||||||
ResourceCard(
|
ResourceCard(
|
||||||
title: "metric.battery", symbol: "battery.100percent", color: Color("MetricBattery"),
|
title: "metric.battery", symbol: "battery.100percent", color: Color("MetricBattery"),
|
||||||
value: MetricFormat.percent(snapshot.battery?.charge)
|
value: MetricFormat.percent(snapshot.battery?.charge),
|
||||||
) {
|
chart: {
|
||||||
PanelTrendChart(
|
PanelTrendChart(
|
||||||
dates: samples.map(\.date),
|
dates: samples.map(\.date),
|
||||||
first: samples.map(\.battery),
|
first: samples.map(\.battery),
|
||||||
@@ -167,7 +187,10 @@ extension MenuPanelView {
|
|||||||
boundaryDates: chartBoundaries,
|
boundaryDates: chartBoundaries,
|
||||||
intervals: chartIntervals
|
intervals: chartIntervals
|
||||||
)
|
)
|
||||||
CardSeparator()
|
}
|
||||||
|
) {
|
||||||
|
inlineMetric(snapshot.battery.map(batteryPowerLabel) ?? "battery.power", MetricFormat.watts(snapshot.battery?.power))
|
||||||
|
.frame(height: 14)
|
||||||
if let battery = snapshot.battery {
|
if let battery = snapshot.battery {
|
||||||
batteryDetails(battery)
|
batteryDetails(battery)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ struct MenuPanelView: View {
|
|||||||
let missingIDs = (0..<reservedFanCount).filter { id in !fans.contains { $0.id == id } }
|
let missingIDs = (0..<reservedFanCount).filter { id in !fans.contains { $0.id == id } }
|
||||||
return (fans + missingIDs.prefix(reservedFanCount - fans.count).map { FanMetrics(id: $0, rpm: nil) }).sorted { $0.id < $1.id }
|
return (fans + missingIDs.prefix(reservedFanCount - fans.count).map { FanMetrics(id: $0, rpm: nil) }).sorted { $0.id < $1.id }
|
||||||
}
|
}
|
||||||
var cardContentWidth: CGFloat { max(0, (measuredCardWidth ?? PanelLayout.cardWidth(size: panelSize)) - 20) }
|
var cardContentWidth: CGFloat { max(0, (measuredCardWidth ?? PanelLayout.cardWidth(size: panelSize)) - ResourceCardMetrics.padding * 2) }
|
||||||
var columns: Int { PanelLayout.columns(width: panelSize.width) }
|
var columns: Int { PanelLayout.columns(width: panelSize.width) }
|
||||||
private var cardHeights: [PanelCard: CGFloat] {
|
private var cardHeights: [PanelCard: CGFloat] {
|
||||||
let coreCount = max(CPUCoreTopology.cores.count, ProcessInfo.processInfo.processorCount, snapshot.cpu?.cores.count ?? 0)
|
let coreCount = max(CPUCoreTopology.cores.count, ProcessInfo.processInfo.processorCount, snapshot.cpu?.cores.count ?? 0)
|
||||||
|
|||||||
@@ -25,12 +25,13 @@ nonisolated enum PanelLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fixed content rows with a 48pt plot. Nil fans reserve a discovery row.
|
/// Foreground details and the edge-to-edge background trend have separate budgets.
|
||||||
static func cardHeights(coreRows: Int, fanCount: Int?) -> [PanelCard: CGFloat] {
|
static func cardHeights(coreRows: Int, fanCount: Int?) -> [PanelCard: CGFloat] {
|
||||||
|
let base = ResourceCardMetrics.minimumHeight
|
||||||
let fanRows = fanCount.map { (max(0, $0) + 1) / 2 } ?? 1
|
let fanRows = fanCount.map { (max(0, $0) + 1) / 2 } ?? 1
|
||||||
return [.cpu: 152 + CGFloat(max(1, coreRows)) * 26,
|
return [.cpu: base + CGFloat(max(0, coreRows - 2)) * 26,
|
||||||
.gpu: fanRows == 0 ? 124 : 144 + CGFloat(fanRows) * 20,
|
.gpu: base + CGFloat(max(0, fanRows - 1)) * 20,
|
||||||
.memory: 180, .battery: 170, .storage: 170, .network: 208]
|
.memory: base, .battery: base, .storage: base, .network: base]
|
||||||
}
|
}
|
||||||
|
|
||||||
static func rowHeights(columns: Int, heights: [PanelCard: CGFloat]) -> [CGFloat] {
|
static func rowHeights(columns: Int, heights: [PanelCard: CGFloat]) -> [CGFloat] {
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ import AppKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mark("interactive")
|
mark("interactive")
|
||||||
|
if ProcessInfo.processInfo.environment["KYMO_AUDIT_CAPTURE"] == "1" {
|
||||||
|
await wait(10)
|
||||||
|
mark("open1.10")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let quick = ProcessInfo.processInfo.environment["KYMO_AUDIT_QUICK"] == "1"
|
let quick = ProcessInfo.processInfo.environment["KYMO_AUDIT_QUICK"] == "1"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ struct StorageDetailsView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
CardSeparator()
|
|
||||||
HStack(spacing: 8) {
|
HStack(spacing: 8) {
|
||||||
VStack(spacing: 4) {
|
VStack(spacing: 4) {
|
||||||
field("memory.available", value: MetricFormat.bytes(disk?.available))
|
field("memory.available", value: MetricFormat.bytes(disk?.available))
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ struct ChartTooltipPreference: PreferenceKey {
|
|||||||
/// Measures the actual localized tooltip, then keeps it inside the card.
|
/// Measures the actual localized tooltip, then keeps it inside the card.
|
||||||
struct ChartTooltipLayer: Layout {
|
struct ChartTooltipLayer: Layout {
|
||||||
let point: CGPoint
|
let point: CGPoint
|
||||||
|
var minimumY: CGFloat = 0
|
||||||
|
|
||||||
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
|
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
|
||||||
proposal.replacingUnspecifiedDimensions()
|
proposal.replacingUnspecifiedDimensions()
|
||||||
@@ -30,7 +31,7 @@ struct ChartTooltipLayer: Layout {
|
|||||||
let x = min(max(10, point.x + 12), max(10, bounds.width - size.width - 10))
|
let x = min(max(10, point.x + 12), max(10, bounds.width - size.width - 10))
|
||||||
let below = point.y + 10
|
let below = point.y + 10
|
||||||
let preferredY = below + size.height <= bounds.height - 10 ? below : point.y - size.height - 10
|
let preferredY = below + size.height <= bounds.height - 10 ? below : point.y - size.height - 10
|
||||||
let y = min(max(10, preferredY), max(10, bounds.height - size.height - 10))
|
let y = min(max(max(10, minimumY), preferredY), max(10, bounds.height - size.height - 10))
|
||||||
tooltip.place(at: CGPoint(x: bounds.minX + x, y: bounds.minY + y), anchor: .topLeading, proposal: tooltipProposal)
|
tooltip.place(at: CGPoint(x: bounds.minX + x, y: bounds.minY + y), anchor: .topLeading, proposal: tooltipProposal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import AppKit
|
import AppKit
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
/// Bounded static Core Graphics paths. No animation, gradient fill or per-frame work.
|
/// Bounded static lines and per-run area paths. Hover never rebuilds geometry.
|
||||||
struct NativePanelCurve: NSViewRepresentable {
|
struct NativePanelCurve: NSViewRepresentable {
|
||||||
let frame: PanelCurveFrame
|
let frame: PanelCurveFrame
|
||||||
let colors: [Color]
|
let colors: [Color]
|
||||||
let scales: [Double]
|
let scales: [Double]
|
||||||
let maximumGap: TimeInterval
|
let maximumGap: TimeInterval
|
||||||
var hoveredIndex: Int? = nil
|
var hoveredIndex: Int? = nil
|
||||||
|
var visibleSeriesCount: Int? = nil
|
||||||
|
var filledSeriesCount = 1
|
||||||
|
|
||||||
func sizeThatFits(_ proposal: ProposedViewSize, nsView: PlotView, context: Context) -> CGSize? {
|
func sizeThatFits(_ proposal: ProposedViewSize, nsView: PlotView, context: Context) -> CGSize? {
|
||||||
CGSize(width: proposal.width.flatMap { $0.isFinite ? $0 : nil } ?? 10,
|
CGSize(width: proposal.width.flatMap { $0.isFinite ? $0 : nil } ?? 10,
|
||||||
@@ -16,7 +18,7 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
func makeNSView(context: Context) -> PlotView { PlotView() }
|
func makeNSView(context: Context) -> PlotView { PlotView() }
|
||||||
func updateNSView(_ view: PlotView, context: Context) {
|
func updateNSView(_ view: PlotView, context: Context) {
|
||||||
view.configure(Input(frame: frame, colors: colors, scales: scales, maximumGap: maximumGap,
|
view.configure(Input(frame: frame, colors: colors, scales: scales, maximumGap: maximumGap,
|
||||||
hoveredIndex: hoveredIndex))
|
hoveredIndex: hoveredIndex, visibleSeriesCount: visibleSeriesCount, filledSeriesCount: filledSeriesCount))
|
||||||
}
|
}
|
||||||
struct Input: Equatable {
|
struct Input: Equatable {
|
||||||
let frame: PanelCurveFrame
|
let frame: PanelCurveFrame
|
||||||
@@ -24,6 +26,8 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
let scales: [Double]
|
let scales: [Double]
|
||||||
let maximumGap: TimeInterval
|
let maximumGap: TimeInterval
|
||||||
var hoveredIndex: Int? = nil
|
var hoveredIndex: Int? = nil
|
||||||
|
var visibleSeriesCount: Int? = nil
|
||||||
|
var filledSeriesCount = 1
|
||||||
}
|
}
|
||||||
final class PlotView: NSView {
|
final class PlotView: NSView {
|
||||||
private(set) var input: Input?
|
private(set) var input: Input?
|
||||||
@@ -43,6 +47,7 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
layer?.masksToBounds = true
|
layer?.masksToBounds = true
|
||||||
curves.anchorPoint = .zero
|
curves.anchorPoint = .zero
|
||||||
grid.fillColor = nil; grid.lineWidth = 0.5
|
grid.fillColor = nil; grid.lineWidth = 0.5
|
||||||
|
grid.isHidden = true
|
||||||
hoverLine.fillColor = nil; hoverLine.lineWidth = 1; hoverLine.lineDashPattern = [3, 2]
|
hoverLine.fillColor = nil; hoverLine.lineWidth = 1; hoverLine.lineDashPattern = [3, 2]
|
||||||
for child in [grid, curves, hoverLine] { layer?.addSublayer(child) }
|
for child in [grid, curves, hoverLine] { layer?.addSublayer(child) }
|
||||||
setAccessibilityElement(false)
|
setAccessibilityElement(false)
|
||||||
@@ -57,7 +62,11 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
CATransaction.begin(); CATransaction.setDisableActions(true)
|
CATransaction.begin(); CATransaction.setDisableActions(true)
|
||||||
curves.isHidden = value.colors.isEmpty || value.scales.isEmpty
|
curves.isHidden = value.colors.isEmpty || value.scales.isEmpty
|
||||||
ensureLayers(value.frame.series.count)
|
ensureLayers(value.frame.series.count)
|
||||||
if old?.colors != value.colors || old?.frame.series.count != value.frame.series.count { updatePalette() }
|
if old?.colors != value.colors || old?.frame.series.count != value.frame.series.count
|
||||||
|
|| old?.filledSeriesCount != value.filledSeriesCount { updatePalette() }
|
||||||
|
for index in seriesLayers.indices {
|
||||||
|
seriesLayers[index].root.isHidden = index >= (value.visibleSeriesCount ?? value.frame.series.count)
|
||||||
|
}
|
||||||
if frameChanged || old?.scales != value.scales || old?.maximumGap != value.maximumGap {
|
if frameChanged || old?.scales != value.scales || old?.maximumGap != value.maximumGap {
|
||||||
rebuildPaths()
|
rebuildPaths()
|
||||||
}
|
}
|
||||||
@@ -83,6 +92,9 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
for index in seriesLayers.indices {
|
for index in seriesLayers.indices {
|
||||||
let color = palette[min(index, palette.count - 1)], series = seriesLayers[index]
|
let color = palette[min(index, palette.count - 1)], series = seriesLayers[index]
|
||||||
series.line.strokeColor = color.cgColor; series.points.fillColor = color.cgColor
|
series.line.strokeColor = color.cgColor; series.points.fillColor = color.cgColor
|
||||||
|
let dark = effectiveAppearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua
|
||||||
|
series.area.fillColor = index < (input?.filledSeriesCount ?? 0)
|
||||||
|
? color.withAlphaComponent(dark ? 0.16 : 0.12).cgColor : nil
|
||||||
hoverDots[index].fillColor = color.cgColor
|
hoverDots[index].fillColor = color.cgColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +129,7 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
let scale = value.isFinite && value > 0 ? value : 1
|
let scale = value.isFinite && value > 0 ? value : 1
|
||||||
let runs = PanelCurveGeometry.runs(dates: frame.dates, values: frame.series[index], maximumGap: input.maximumGap,
|
let runs = PanelCurveGeometry.runs(dates: frame.dates, values: frame.series[index], maximumGap: input.maximumGap,
|
||||||
boundaryDates: frame.boundaryDates, intervals: frame.intervals)
|
boundaryDates: frame.boundaryDates, intervals: frame.intervals)
|
||||||
let line = CGMutablePath(), dots = CGMutablePath()
|
let line = CGMutablePath(), dots = CGMutablePath(), area = CGMutablePath()
|
||||||
for run in runs {
|
for run in runs {
|
||||||
let points = run.map { CGPoint(x: bounds.width * domain.position($0.date),
|
let points = run.map { CGPoint(x: bounds.width * domain.position($0.date),
|
||||||
y: bounds.height * (1 - min(1, max(0, $0.value / scale)))) }
|
y: bounds.height * (1 - min(1, max(0, $0.value / scale)))) }
|
||||||
@@ -131,9 +143,15 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
segment.addCurve(to: b, control1: CGPoint(x: mid, y: a.y), control2: CGPoint(x: mid, y: b.y))
|
segment.addCurve(to: b, control1: CGPoint(x: mid, y: a.y), control2: CGPoint(x: mid, y: b.y))
|
||||||
}
|
}
|
||||||
line.addPath(segment)
|
line.addPath(segment)
|
||||||
|
// Each continuous run closes against its own baseline, preserving real gaps.
|
||||||
|
let fill = CGMutablePath(); fill.addPath(segment)
|
||||||
|
fill.addLine(to: CGPoint(x: points.last!.x, y: bounds.height))
|
||||||
|
fill.addLine(to: CGPoint(x: start.x, y: bounds.height)); fill.closeSubpath()
|
||||||
|
area.addPath(fill)
|
||||||
}
|
}
|
||||||
series.line.path = line
|
series.line.path = line
|
||||||
series.points.path = dots
|
series.points.path = dots
|
||||||
|
series.area.path = area
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private func updateHover() {
|
private func updateHover() {
|
||||||
@@ -145,6 +163,7 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
let x = bounds.width * domain.position(input.frame.dates[index])
|
let x = bounds.width * domain.position(input.frame.dates[index])
|
||||||
let path = CGMutablePath(); path.move(to: CGPoint(x: x, y: 0)); path.addLine(to: CGPoint(x: x, y: bounds.height)); hoverLine.path = path
|
let path = CGMutablePath(); path.move(to: CGPoint(x: x, y: 0)); path.addLine(to: CGPoint(x: x, y: bounds.height)); hoverLine.path = path
|
||||||
for series in input.frame.series.indices {
|
for series in input.frame.series.indices {
|
||||||
|
guard series < (input.visibleSeriesCount ?? input.frame.series.count) else { continue }
|
||||||
let values = input.frame.series[series]
|
let values = input.frame.series[series]
|
||||||
guard values.indices.contains(index), let value = values[index], value.isFinite else { continue }
|
guard values.indices.contains(index), let value = values[index], value.isFinite else { continue }
|
||||||
let scale = input.scales[min(series, input.scales.count - 1)]
|
let scale = input.scales[min(series, input.scales.count - 1)]
|
||||||
@@ -171,17 +190,17 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
updatePalette(); CATransaction.commit()
|
updatePalette(); CATransaction.commit()
|
||||||
}
|
}
|
||||||
private final class SeriesLayer {
|
private final class SeriesLayer {
|
||||||
let root = CALayer(), line = CAShapeLayer(), points = CAShapeLayer()
|
let root = CALayer(), area = CAShapeLayer(), line = CAShapeLayer(), points = CAShapeLayer()
|
||||||
init() {
|
init() {
|
||||||
line.fillColor = nil; line.lineWidth = 1.5; line.lineCap = .round; line.lineJoin = .round
|
line.fillColor = nil; line.lineWidth = 1.8; line.lineCap = .round; line.lineJoin = .round
|
||||||
root.addSublayer(line); root.addSublayer(points)
|
root.addSublayer(area); root.addSublayer(line); root.addSublayer(points)
|
||||||
}
|
}
|
||||||
func resize(_ bounds: CGRect) {
|
func resize(_ bounds: CGRect) {
|
||||||
root.frame = bounds
|
root.frame = bounds
|
||||||
let local = CGRect(origin: .zero, size: bounds.size)
|
let local = CGRect(origin: .zero, size: bounds.size)
|
||||||
line.frame = local; points.frame = local
|
area.frame = local; line.frame = local; points.frame = local
|
||||||
}
|
}
|
||||||
func clear() { line.path = nil; points.path = nil }
|
func clear() { area.path = nil; line.path = nil; points.path = nil }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ struct PanelTrendChart: View {
|
|||||||
var thirdColor: Color = .purple
|
var thirdColor: Color = .purple
|
||||||
var fourthColor: Color = .yellow
|
var fourthColor: Color = .yellow
|
||||||
var fixedScale: Double? = 1
|
var fixedScale: Double? = 1
|
||||||
var scaleLabel: String?
|
|
||||||
var secondSeriesUsesAutonomousScale = false
|
var secondSeriesUsesAutonomousScale = false
|
||||||
var firstValueFormat: TrendValueFormat?
|
var firstValueFormat: TrendValueFormat?
|
||||||
var secondValueFormat: TrendValueFormat?
|
var secondValueFormat: TrendValueFormat?
|
||||||
@@ -31,8 +30,7 @@ struct PanelTrendChart: View {
|
|||||||
var expectedInterval: TimeInterval = 2
|
var expectedInterval: TimeInterval = 2
|
||||||
var boundaryDates: Set<Date> = []
|
var boundaryDates: Set<Date> = []
|
||||||
var intervals: [TimeInterval] = []
|
var intervals: [TimeInterval] = []
|
||||||
var plotHeight: CGFloat = PanelStyle.plotHeight
|
var visibleSeriesCount = 1
|
||||||
var showsLegendValues = true
|
|
||||||
@State private var retainedScale: Double = 1
|
@State private var retainedScale: Double = 1
|
||||||
@State private var smallSamples = 0
|
@State private var smallSamples = 0
|
||||||
@State private var retainedSecondScale: Double = 1
|
@State private var retainedSecondScale: Double = 1
|
||||||
@@ -73,16 +71,6 @@ struct PanelTrendChart: View {
|
|||||||
case .watts: return MetricFormat.watts(value)
|
case .watts: return MetricFormat.watts(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private func legend(_ label: LocalizedStringKey, values: [Double?], tint: Color, format: TrendValueFormat? = nil) -> some View {
|
|
||||||
HStack(spacing: 3) {
|
|
||||||
RoundedRectangle(cornerRadius: 1).fill(tint).frame(width: 7, height: 7)
|
|
||||||
Text(label)
|
|
||||||
if showsLegendValues {
|
|
||||||
Text(verbatim: formatted(values.last ?? nil, format: format)).monospacedDigit()
|
|
||||||
}
|
|
||||||
}.font(PanelStyle.legend).lineLimit(1).minimumScaleFactor(0.8)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func tooltipRow(_ label: LocalizedStringKey, values: [Double?], tint: Color, format: TrendValueFormat? = nil, index: Int) -> some View {
|
private func tooltipRow(_ label: LocalizedStringKey, values: [Double?], tint: Color, format: TrendValueFormat? = nil, index: Int) -> some View {
|
||||||
HStack(spacing: 6) {
|
HStack(spacing: 6) {
|
||||||
RoundedRectangle(cornerRadius: 2).fill(tint).frame(width: 8, height: 8)
|
RoundedRectangle(cornerRadius: 2).fill(tint).frame(width: 8, height: 8)
|
||||||
@@ -105,29 +93,11 @@ struct PanelTrendChart: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 3) {
|
|
||||||
HStack(spacing: 10) {
|
|
||||||
legend(firstLabel, values: first, tint: color)
|
|
||||||
if !second.isEmpty { legend(secondLabel, values: second, tint: secondColor, format: secondValueFormat) }
|
|
||||||
if !third.isEmpty { legend(thirdLabel, values: third, tint: thirdColor) }
|
|
||||||
if !fourth.isEmpty { legend(fourthLabel, values: fourth, tint: fourthColor) }
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
}.frame(height: 14)
|
|
||||||
HStack(spacing: 5) {
|
|
||||||
VStack(alignment: .trailing) {
|
|
||||||
Text(verbatim: scaleLabel ?? formatted(scale))
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
Text(verbatim: formatted(scale / 2))
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
Text(verbatim: "0")
|
|
||||||
}.font(.system(size: 8)).foregroundStyle(.secondary)
|
|
||||||
.lineLimit(1).minimumScaleFactor(0.6).frame(width: fixedScale == 1 ? 28 : 47, height: plotHeight)
|
|
||||||
GeometryReader { proxy in
|
GeometryReader { proxy in
|
||||||
ZStack(alignment: .topLeading) {
|
|
||||||
NativePanelCurve(frame: inputFrame, colors: [color, secondColor, thirdColor, fourthColor],
|
NativePanelCurve(frame: inputFrame, colors: [color, secondColor, thirdColor, fourthColor],
|
||||||
scales: [scale, hasSecondaryScale ? secondaryScale : scale, hasSecondaryScale ? secondaryScale : scale, scale],
|
scales: [scale, hasSecondaryScale ? secondaryScale : scale, scale, scale],
|
||||||
maximumGap: max(5, expectedInterval * 2), hoveredIndex: hoveredDate == nil ? nil : index)
|
maximumGap: max(5, expectedInterval * 2), hoveredIndex: hoveredDate == nil ? nil : index,
|
||||||
}
|
visibleSeriesCount: visibleSeriesCount, filledSeriesCount: visibleSeriesCount)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.onContinuousHover { phase in
|
.onContinuousHover { phase in
|
||||||
switch phase {
|
switch phase {
|
||||||
@@ -139,30 +109,12 @@ struct PanelTrendChart: View {
|
|||||||
case .ended: hoveredDate = nil; hoverPoint = nil
|
case .ended: hoveredDate = nil; hoverPoint = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.clipped()
|
|
||||||
}.frame(height: plotHeight)
|
|
||||||
.anchorPreference(key: ChartTooltipPreference.self, value: .bounds) { plot in
|
.anchorPreference(key: ChartTooltipPreference.self, value: .bounds) { plot in
|
||||||
guard let hoverPoint, let index else { return nil }
|
guard let hoverPoint, let index else { return nil }
|
||||||
return ChartTooltipPresentation(plot: plot, point: hoverPoint, content: AnyView(tooltip(index: index)))
|
return ChartTooltipPresentation(plot: plot, point: hoverPoint, content: AnyView(tooltip(index: index)))
|
||||||
}
|
}
|
||||||
if hasSecondaryScale {
|
|
||||||
VStack(alignment: .leading) {
|
|
||||||
Text(verbatim: formatted(secondaryScale, format: .watts))
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
Text(verbatim: formatted(secondaryScale / 2, format: .watts))
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
Text(verbatim: "0 W")
|
|
||||||
}.font(.system(size: 8)).foregroundStyle(.secondary)
|
|
||||||
.lineLimit(1).minimumScaleFactor(0.6).frame(width: 45, height: plotHeight)
|
|
||||||
}
|
}
|
||||||
}
|
.frame(height: ResourceCardMetrics.plotHeight)
|
||||||
HStack {
|
|
||||||
if let date = dates.first { Text(date, style: .time) }
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
if let date = dates.last { Text(date, style: .time) }
|
|
||||||
}.font(PanelStyle.legend).foregroundStyle(.secondary).frame(height: 12)
|
|
||||||
}
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.onAppear {
|
.onAppear {
|
||||||
retainedScale = maximum
|
retainedScale = maximum
|
||||||
retainedSecondScale = secondMaximum
|
retainedSecondScale = secondMaximum
|
||||||
@@ -181,6 +133,8 @@ struct PanelTrendChart: View {
|
|||||||
if smallSecondSamples >= 10 { retainedSecondScale = secondTarget; smallSecondSamples = 0 }
|
if smallSecondSamples >= 10 { retainedSecondScale = secondTarget; smallSecondSamples = 0 }
|
||||||
} else { smallSecondSamples = 0 }
|
} else { smallSecondSamples = 0 }
|
||||||
}
|
}
|
||||||
.accessibilityElement(children: .combine)
|
.accessibilityElement(children: .ignore)
|
||||||
|
.accessibilityLabel(Text(firstLabel))
|
||||||
|
.accessibilityValue(Text(verbatim: formatted(first.last ?? nil)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
/// Shared roles for the compact monitoring panel. Micro charts keep their own 8pt role.
|
/// Shared roles for auxiliary labels and native panel controls.
|
||||||
enum PanelStyle {
|
enum PanelStyle {
|
||||||
static let title = Font.system(size: 13, weight: .semibold)
|
static let title = Font.system(size: 13, weight: .semibold)
|
||||||
static let label = Font.system(size: 10)
|
static let label = Font.system(size: 10)
|
||||||
@@ -9,15 +9,6 @@ enum PanelStyle {
|
|||||||
static let padding: CGFloat = 10
|
static let padding: CGFloat = 10
|
||||||
static let gap: CGFloat = 8
|
static let gap: CGFloat = 8
|
||||||
static let titleHeight: CGFloat = 20
|
static let titleHeight: CGFloat = 20
|
||||||
static let plotHeight: CGFloat = 48
|
|
||||||
}
|
|
||||||
|
|
||||||
struct CardSeparator: View {
|
|
||||||
var body: some View {
|
|
||||||
Rectangle().fill(.primary.opacity(0.08)).frame(height: 1)
|
|
||||||
.padding(.vertical, 2)
|
|
||||||
.accessibilityHidden(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CardField<Content: View>: View {
|
struct CardField<Content: View>: View {
|
||||||
@@ -42,13 +33,6 @@ struct CardSurface: ViewModifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CardInset: ViewModifier {
|
|
||||||
func body(content: Content) -> some View {
|
|
||||||
content.padding(.horizontal, 8).padding(.vertical, 5)
|
|
||||||
.background(.primary.opacity(0.04), in: RoundedRectangle(cornerRadius: 6))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Segment widths are proportional to the supplied total, without minimum fills.
|
/// Segment widths are proportional to the supplied total, without minimum fills.
|
||||||
struct CapacityBar: View {
|
struct CapacityBar: View {
|
||||||
let values: [Double]
|
let values: [Double]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ResourceCard<Content: View>: View {
|
/// One fixed-size native host owns foreground, background trend and hover presentation.
|
||||||
|
struct ResourceCard<Chart: View, Content: View>: View {
|
||||||
let title: LocalizedStringKey
|
let title: LocalizedStringKey
|
||||||
let symbol: String
|
let symbol: String
|
||||||
let color: Color
|
let color: Color
|
||||||
@@ -14,69 +15,51 @@ struct ResourceCard<Content: View>: View {
|
|||||||
var detail: String? = nil
|
var detail: String? = nil
|
||||||
var detailColor: Color? = nil
|
var detailColor: Color? = nil
|
||||||
var detailHelp: String? = nil
|
var detailHelp: String? = nil
|
||||||
|
var headerAccessory: AnyView? = nil
|
||||||
|
@ViewBuilder var chart: () -> Chart
|
||||||
@ViewBuilder var content: () -> Content
|
@ViewBuilder var content: () -> Content
|
||||||
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
|
|
||||||
var body: some View {
|
var body: some View { NativeContentHost(content: cardBody) }
|
||||||
NativeContentHost(content: cardBody)
|
|
||||||
}
|
|
||||||
|
|
||||||
private var cardBody: some View {
|
private var cardBody: some View {
|
||||||
GeometryReader { bounds in
|
GeometryReader { bounds in
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
ZStack(alignment: .bottomLeading) {
|
||||||
HStack(alignment: .center, spacing: 6) {
|
chart()
|
||||||
Label {
|
.frame(width: bounds.size.width, height: ResourceCardMetrics.plotHeight)
|
||||||
Text(title).foregroundStyle(statusWarning ? .red : .primary)
|
VStack(alignment: .leading, spacing: ResourceCardMetrics.gap) {
|
||||||
} icon: {
|
header
|
||||||
Image(systemName: symbol).frame(width: 16, height: 16).foregroundStyle(statusWarning ? .red : color)
|
HStack(alignment: .firstTextBaseline, spacing: 12) {
|
||||||
}.font(PanelStyle.title).fixedSize()
|
MetricHeadline(value: value, compact: secondaryValue != nil, color: valueColor ?? .primary)
|
||||||
if let status {
|
|
||||||
Text(verbatim: status)
|
|
||||||
.font(.system(size: 10, weight: .medium))
|
|
||||||
.foregroundStyle(statusWarning ? .red : color)
|
|
||||||
.padding(.horizontal, 6).frame(height: 16)
|
|
||||||
.background((statusWarning ? Color.red : color).opacity(0.14), in: Capsule())
|
|
||||||
if let warningText {
|
|
||||||
warningText
|
|
||||||
.font(.system(size: 10)).foregroundStyle(.red).lineLimit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let detail {
|
|
||||||
Text(verbatim: detail)
|
|
||||||
.font(.system(size: 10, weight: .medium)).foregroundStyle(detailColor ?? .secondary)
|
|
||||||
.padding(.horizontal, 6).frame(height: 16)
|
|
||||||
.background((detailColor ?? .primary).opacity(detailColor == nil ? 0.06 : 0.14), in: Capsule())
|
|
||||||
.lineLimit(1)
|
|
||||||
.fixedSize(horizontal: true, vertical: false)
|
|
||||||
.help(Text(verbatim: detailHelp ?? detail))
|
|
||||||
.accessibilityLabel(Text(verbatim: detailHelp ?? detail))
|
|
||||||
}
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
HStack(alignment: .center, spacing: 6) {
|
|
||||||
MetricText(value: value)
|
|
||||||
.font(PanelStyle.title)
|
|
||||||
.foregroundStyle(valueColor ?? color)
|
|
||||||
if let secondaryValue {
|
if let secondaryValue {
|
||||||
MetricText(value: secondaryValue).font(PanelStyle.title)
|
MetricHeadline(value: secondaryValue, compact: true, color: secondaryValueColor ?? .primary)
|
||||||
.foregroundStyle(secondaryValueColor ?? color)
|
|
||||||
}
|
}
|
||||||
}.foregroundStyle(color).lineLimit(1)
|
|
||||||
}
|
}
|
||||||
.frame(height: PanelStyle.titleHeight)
|
.frame(height: ResourceCardMetrics.headlineHeight, alignment: .leading)
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
content()
|
content()
|
||||||
}
|
Spacer(minLength: 0)
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
|
||||||
}
|
}
|
||||||
.font(PanelStyle.label)
|
.font(PanelStyle.label)
|
||||||
.padding(PanelStyle.padding)
|
.padding(ResourceCardMetrics.padding)
|
||||||
|
.padding(.bottom, ResourceCardMetrics.plotHeight - ResourceCardMetrics.padding)
|
||||||
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading)
|
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading)
|
||||||
}
|
}
|
||||||
.modifier(CardSurface())
|
.background(Color("PanelCard"))
|
||||||
|
.clipShape(.rect(cornerRadius: ResourceCardMetrics.radius))
|
||||||
|
.overlay(RoundedRectangle(cornerRadius: ResourceCardMetrics.radius).strokeBorder(.primary.opacity(0.07)))
|
||||||
|
.background {
|
||||||
|
RoundedRectangle(cornerRadius: ResourceCardMetrics.radius)
|
||||||
|
.fill(Color("PanelCard"))
|
||||||
|
.shadow(color: .black.opacity(colorScheme == .dark ? 0.16 : 0.06), radius: 6, x: 0, y: 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
.overlayPreferenceValue(ChartTooltipPreference.self) { tooltip in
|
.overlayPreferenceValue(ChartTooltipPreference.self) { tooltip in
|
||||||
GeometryReader { proxy in
|
GeometryReader { proxy in
|
||||||
if let tooltip {
|
if let tooltip {
|
||||||
let plot = proxy[tooltip.plot]
|
let plot = proxy[tooltip.plot]
|
||||||
ChartTooltipLayer(point: CGPoint(x: plot.minX + tooltip.point.x, y: plot.minY + tooltip.point.y)) {
|
ChartTooltipLayer(point: CGPoint(x: plot.minX + tooltip.point.x, y: plot.minY + tooltip.point.y),
|
||||||
|
minimumY: max(ResourceCardMetrics.tooltipMinimumY, plot.minY)) {
|
||||||
tooltip.content.fixedSize(horizontal: false, vertical: true)
|
tooltip.content.fixedSize(horizontal: false, vertical: true)
|
||||||
}
|
}
|
||||||
.frame(width: proxy.size.width, height: proxy.size.height)
|
.frame(width: proxy.size.width, height: proxy.size.height)
|
||||||
@@ -86,4 +69,70 @@ struct ResourceCard<Content: View>: View {
|
|||||||
.accessibilityHidden(true)
|
.accessibilityHidden(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var header: some View {
|
||||||
|
HStack(spacing: 6) {
|
||||||
|
Label {
|
||||||
|
Text(title).foregroundStyle(statusWarning ? .red : .primary)
|
||||||
|
} icon: {
|
||||||
|
Image(systemName: symbol).foregroundStyle(statusWarning ? .red : color)
|
||||||
|
}
|
||||||
|
.font(.system(size: 14, weight: .semibold)).fixedSize()
|
||||||
|
Spacer(minLength: 4)
|
||||||
|
if let status {
|
||||||
|
Text(verbatim: status)
|
||||||
|
.font(.system(size: 11, weight: .medium))
|
||||||
|
.foregroundStyle(statusWarning ? .red : .secondary)
|
||||||
|
.help(warningText ?? Text(verbatim: status))
|
||||||
|
.accessibilityLabel(warningText.map { Text("\(status) \($0)") } ?? Text(verbatim: status))
|
||||||
|
}
|
||||||
|
if let detail {
|
||||||
|
Text(verbatim: detail)
|
||||||
|
.font(.system(size: 10, weight: .medium)).foregroundStyle(detailColor ?? .secondary)
|
||||||
|
.padding(.horizontal, 6).frame(height: 18)
|
||||||
|
.background((detailColor ?? .primary).opacity(0.10), in: Capsule())
|
||||||
|
.lineLimit(1)
|
||||||
|
.help(Text(verbatim: detailHelp ?? detail))
|
||||||
|
.accessibilityLabel(Text(verbatim: detailHelp ?? detail))
|
||||||
|
}
|
||||||
|
headerAccessory
|
||||||
|
}
|
||||||
|
.lineLimit(1)
|
||||||
|
.frame(height: ResourceCardMetrics.titleHeight)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A preformatted value keeps its unit smaller without changing metric semantics.
|
||||||
|
private struct MetricHeadline: View {
|
||||||
|
let value: String
|
||||||
|
let compact: Bool
|
||||||
|
let color: Color
|
||||||
|
private var direction: Character? { value.first.flatMap { $0 == "↓" || $0 == "↑" ? $0 : nil } }
|
||||||
|
private var parts: [Substring] {
|
||||||
|
let number = direction == nil ? value : String(value.dropFirst()).trimmingCharacters(in: .whitespaces)
|
||||||
|
if number.hasSuffix("%") { return [number.dropLast(), "%"] }
|
||||||
|
return number.split(separator: " ", maxSplits: 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack(alignment: .firstTextBaseline, spacing: 3) {
|
||||||
|
if let direction {
|
||||||
|
Image(systemName: direction == "↓" ? "arrow.down" : "arrow.up")
|
||||||
|
.font(.system(size: 16, weight: .medium))
|
||||||
|
}
|
||||||
|
Text(verbatim: parts.first.map(String.init) ?? value)
|
||||||
|
.font(.system(size: compact ? 23 : 36, weight: .semibold))
|
||||||
|
if parts.count > 1 {
|
||||||
|
Text(verbatim: String(parts[1]))
|
||||||
|
.font(.system(size: compact ? 11 : 14, weight: .medium))
|
||||||
|
.foregroundStyle(Color.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.monospacedDigit().foregroundStyle(color)
|
||||||
|
.lineLimit(1).minimumScaleFactor(0.75)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
.help(Text(verbatim: value))
|
||||||
|
.accessibilityElement(children: .ignore)
|
||||||
|
.accessibilityLabel(Text(verbatim: value))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import CoreGraphics
|
||||||
|
|
||||||
|
/// Shared geometry for resource foregrounds, background plots and panel budgets.
|
||||||
|
nonisolated enum ResourceCardMetrics {
|
||||||
|
static let minimumHeight: CGFloat = 264
|
||||||
|
static let padding: CGFloat = 16
|
||||||
|
static let radius: CGFloat = 20
|
||||||
|
static let plotHeight: CGFloat = 72
|
||||||
|
static let titleHeight: CGFloat = 20
|
||||||
|
static let headlineHeight: CGFloat = 44
|
||||||
|
static let gap: CGFloat = 6
|
||||||
|
static let tooltipMinimumY: CGFloat = 96
|
||||||
|
}
|
||||||
@@ -23,6 +23,10 @@ import QuartzCore
|
|||||||
plot.configure(continuous)
|
plot.configure(continuous)
|
||||||
let image = bitmap(plot)
|
let image = bitmap(plot)
|
||||||
precondition(redPixels(image, from: 0.4, to: 0.6) > 10, "Continuous curve must cross the middle")
|
precondition(redPixels(image, from: 0.4, to: 0.6) > 10, "Continuous curve must cross the middle")
|
||||||
|
let fill = image.colorAt(x: image.pixelsWide / 2, y: image.pixelsHigh / 2)!
|
||||||
|
precondition(fill.alphaComponent > 0.10 && fill.alphaComponent < 0.18,
|
||||||
|
"A continuous run must have a translucent area below its real curve")
|
||||||
|
precondition(plot.grid.isHidden, "Background trends must not draw a chart grid")
|
||||||
plot.needsDisplay = false; plot.configure(continuous)
|
plot.needsDisplay = false; plot.configure(continuous)
|
||||||
precondition(!plot.needsDisplay, "Identical inputs must not invalidate the plot")
|
precondition(!plot.needsDisplay, "Identical inputs must not invalidate the plot")
|
||||||
plot.configure(input([0.8,0.8,nil,0.8]))
|
plot.configure(input([0.8,0.8,nil,0.8]))
|
||||||
@@ -39,6 +43,20 @@ import QuartzCore
|
|||||||
precondition(dots.path == nil, "Connecting a missing value must not invent a measured hover dot")
|
precondition(dots.path == nil, "Connecting a missing value must not invent a measured hover dot")
|
||||||
plot.configure(input([nil,nil,nil,nil]))
|
plot.configure(input([nil,nil,nil,nil]))
|
||||||
precondition(redPixels(bitmap(plot)) == 0)
|
precondition(redPixels(bitmap(plot)) == 0)
|
||||||
|
plot.configure(input([nil,0.8,nil,nil]))
|
||||||
|
let single = bitmap(plot)
|
||||||
|
precondition(single.colorAt(x: single.pixelsWide / 2, y: single.pixelsHigh / 2)!.alphaComponent == 0,
|
||||||
|
"A single sample must not create a fabricated area")
|
||||||
|
var hiddenSeries = NativePanelCurve.Input(frame: .init(dates: dates,
|
||||||
|
series: [[nil,nil,nil,nil], [0.8,0.8,0.8,0.8]], intervals: [2,2,2,2], boundaryDates: []),
|
||||||
|
colors: [.red, .red], scales: [1], maximumGap: 5)
|
||||||
|
hiddenSeries.visibleSeriesCount = 1; hiddenSeries.hoveredIndex = 1
|
||||||
|
plot.configure(hiddenSeries)
|
||||||
|
precondition(redPixels(bitmap(plot)) == 0, "A tooltip-only series must not leak lines, fill or hover dots")
|
||||||
|
var unfilled = continuous; unfilled.filledSeriesCount = 0
|
||||||
|
plot.configure(unfilled)
|
||||||
|
let noArea = bitmap(plot)
|
||||||
|
precondition(noArea.colorAt(x: noArea.pixelsWide / 2, y: noArea.pixelsHigh / 2)!.alphaComponent == 0)
|
||||||
let changedDates = [0.0, 2, 8, 10].map { Date(timeIntervalSinceReferenceDate: $0) }
|
let changedDates = [0.0, 2, 8, 10].map { Date(timeIntervalSinceReferenceDate: $0) }
|
||||||
plot.configure(.init(frame: .init(dates: changedDates, series: [[0.8,0.8,0.8,0.8]],
|
plot.configure(.init(frame: .init(dates: changedDates, series: [[0.8,0.8,0.8,0.8]],
|
||||||
intervals: [2,30,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5))
|
intervals: [2,30,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5))
|
||||||
@@ -84,7 +102,7 @@ import QuartzCore
|
|||||||
assertStatic(plot.layer!)
|
assertStatic(plot.layer!)
|
||||||
plot.removeFromSuperview()
|
plot.removeFromSuperview()
|
||||||
window.orderOut(nil); window.close()
|
window.orderOut(nil); window.close()
|
||||||
print("PASS: static curve pixels, immediate stable updates, no animation/material/gradient layers, real gaps, hover cache, palette growth, appearance, full history and unmount")
|
print("PASS: static background lines/area pixels, no single-point fill, hidden-series isolation, immediate stable updates, no animation/material/gradient layers, real gaps, hover cache, palette growth, appearance, full history and unmount")
|
||||||
fflush(stdout); NSApp.terminate(nil)
|
fflush(stdout); NSApp.terminate(nil)
|
||||||
}
|
}
|
||||||
NSApp.run()
|
NSApp.run()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import CoreGraphics
|
|||||||
|
|
||||||
@main struct PanelLayoutChecks {
|
@main struct PanelLayoutChecks {
|
||||||
static func main() {
|
static func main() {
|
||||||
precondition(PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900)) == CGSize(width: 960, height: 514))
|
precondition(PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900)) == CGSize(width: 960, height: 630))
|
||||||
for visible in [CGRect(x: 0, y: 67, width: 1512, height: 882), CGRect(x: -1440, y: -200, width: 1440, height: 800), CGRect(x: 0, y: 24, width: 800, height: 600)] {
|
for visible in [CGRect(x: 0, y: 67, width: 1512, height: 882), CGRect(x: -1440, y: -200, width: 1440, height: 800), CGRect(x: 0, y: 24, width: 800, height: 600)] {
|
||||||
let content = PanelLayout.contentSize(visible: visible, chrome: CGSize(width: 4, height: 12))
|
let content = PanelLayout.contentSize(visible: visible, chrome: CGSize(width: 4, height: 12))
|
||||||
precondition(content.width + 4 <= visible.width - 32 && content.height + 12 <= visible.height - 32)
|
precondition(content.width + 4 <= visible.width - 32 && content.height + 12 <= visible.height - 32)
|
||||||
@@ -32,28 +32,28 @@ import CoreGraphics
|
|||||||
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 500), heights: compact))
|
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 500), heights: compact))
|
||||||
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 2400), heights: compact))
|
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 2400), heights: compact))
|
||||||
}
|
}
|
||||||
precondition(PanelLayout.rowHeights(columns: 3, heights: compact) == [204, 208])
|
precondition(PanelLayout.rowHeights(columns: 3, heights: compact) == [264, 264])
|
||||||
precondition(PanelLayout.rowHeights(columns: 2, heights: compact) == [204, 180, 208])
|
precondition(PanelLayout.rowHeights(columns: 2, heights: compact) == [264, 264, 264])
|
||||||
precondition(PanelLayout.cardWidth(size: CGSize(width: 960, height: 514)) == 308,
|
precondition(PanelLayout.cardWidth(size: CGSize(width: 960, height: 630)) == 308,
|
||||||
"Three columns must retain readable card widths")
|
"Three columns must retain readable card widths")
|
||||||
precondition(PanelLayout.preferredHeight(width: 960, heights: compact) == 514)
|
precondition(PanelLayout.preferredHeight(width: 960, heights: compact) == 630)
|
||||||
precondition(PanelLayout.preferredHeight(width: 640, heights: compact) == 702)
|
precondition(PanelLayout.preferredHeight(width: 640, heights: compact) == 800)
|
||||||
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 960, height: 514), heights: compact))
|
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 960, height: 630), heights: compact))
|
||||||
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 960, height: 513), heights: compact))
|
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 960, height: 629), heights: compact))
|
||||||
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 640, height: 702), heights: compact))
|
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 640, height: 902), heights: compact))
|
||||||
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 640, height: 701), heights: compact))
|
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 640, height: 901), heights: compact))
|
||||||
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 480, height: 800), heights: compact))
|
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 480, height: 800), heights: compact))
|
||||||
precondition(PanelLayout.columns(width: 960) == 3 && PanelLayout.columns(width: 900) == 3)
|
precondition(PanelLayout.columns(width: 960) == 3 && PanelLayout.columns(width: 900) == 3)
|
||||||
precondition(PanelLayout.columns(width: 899) == 2 && PanelLayout.columns(width: 560) == 2 && PanelLayout.columns(width: 559) == 1)
|
precondition(PanelLayout.columns(width: 899) == 2 && PanelLayout.columns(width: 560) == 2 && PanelLayout.columns(width: 559) == 1)
|
||||||
let tallerCPU = PanelLayout.cardHeights(coreRows: 6, fanCount: 2)
|
let tallerCPU = PanelLayout.cardHeights(coreRows: 6, fanCount: 2)
|
||||||
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [308, 208],
|
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [368, 264],
|
||||||
"Extra CPU rows must grow the first grid row without changing the second")
|
"Extra CPU rows must grow the first grid row without changing the second")
|
||||||
let moreFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 10)
|
let moreFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 10)
|
||||||
precondition(moreFans[.gpu]! > compact[.gpu]! && moreFans[.storage] == compact[.storage])
|
precondition(moreFans[.gpu]! > compact[.gpu]! && moreFans[.storage] == compact[.storage])
|
||||||
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [244, 208])
|
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [344, 264])
|
||||||
let noFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 0)
|
let noFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 0)
|
||||||
precondition(noFans[.gpu] == 124 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [204, 208])
|
precondition(noFans[.gpu] == 264 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [264, 264])
|
||||||
precondition(PanelLayout.preferredHeight(width: 960, heights: noFans) == 514,
|
precondition(PanelLayout.preferredHeight(width: 960, heights: noFans) == 630,
|
||||||
"A fanless GPU must keep row alignment with CPU and memory")
|
"A fanless GPU must keep row alignment with CPU and memory")
|
||||||
precondition(PanelLayout.cardHeights(coreRows: 2, fanCount: nil) == compact,
|
precondition(PanelLayout.cardHeights(coreRows: 2, fanCount: nil) == compact,
|
||||||
"Discovery placeholders must reserve the ordinary fan row")
|
"Discovery placeholders must reserve the ordinary fan row")
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import AppKit
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
/// Mount the production card and chart together; verify their real native geometry.
|
||||||
|
@main struct ResourceCardChecks {
|
||||||
|
@MainActor static func main() {
|
||||||
|
_ = NSApplication.shared
|
||||||
|
NSApp.setActivationPolicy(.accessory)
|
||||||
|
Task { @MainActor in
|
||||||
|
let window = NSWindow(contentRect: NSRect(x: 40, y: 40, width: 308, height: 264),
|
||||||
|
styleMask: [.borderless], backing: .buffered, defer: false)
|
||||||
|
window.isReleasedWhenClosed = false; window.level = .floating
|
||||||
|
let probe = DetailProbe()
|
||||||
|
let host = NSHostingView(rootView: AnyView(EmptyView())); host.sizingOptions = []
|
||||||
|
window.contentView = host; window.orderFrontRegardless()
|
||||||
|
for dark in [false, true] {
|
||||||
|
window.appearance = NSAppearance(named: dark ? .darkAqua : .aqua)
|
||||||
|
for language in ["zh-Hans", "zh-Hant", "en"] {
|
||||||
|
for width: CGFloat in [266, 308, 460] {
|
||||||
|
window.setContentSize(NSSize(width: width, height: 264))
|
||||||
|
host.rootView = AnyView(fixture(probe: probe, dualMetric: width == 308)
|
||||||
|
.environment(\.locale, Locale(identifier: language))
|
||||||
|
.environment(\.colorScheme, dark ? .dark : .light))
|
||||||
|
try? await Task.sleep(for: .milliseconds(80))
|
||||||
|
host.layoutSubtreeIfNeeded()
|
||||||
|
let plots = descendants(host).compactMap { $0 as? NativePanelCurve.PlotView }
|
||||||
|
precondition(plots.count == 1)
|
||||||
|
let plot = plots[0]
|
||||||
|
precondition(abs(plot.bounds.width - width) < 0.5 && plot.bounds.height == 72,
|
||||||
|
"The background chart must occupy the full card width, without axes or plot insets")
|
||||||
|
let graph = topRect(plot, in: host)
|
||||||
|
precondition(abs(graph.maxY - host.bounds.height) < 0.5,
|
||||||
|
"The background chart must end at the card bottom")
|
||||||
|
let detail = topRect(probe.view!, in: host)
|
||||||
|
precondition(detail.maxY <= graph.minY + 0.5 && detail.width <= width - 32 + 0.5,
|
||||||
|
"Foreground details must stay above the graph, including narrow/localized cards")
|
||||||
|
precondition(plot.grid.isHidden && plot.input?.visibleSeriesCount == 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
host.rootView = AnyView(EmptyView())
|
||||||
|
try? await Task.sleep(for: .milliseconds(100))
|
||||||
|
precondition(descendants(host).allSatisfy { !($0 is NativePanelCurve.PlotView) })
|
||||||
|
window.orderOut(nil); window.contentView = nil; window.close()
|
||||||
|
print("PASS: production resource card/plot geometry at 266/308/460pt, light/dark, three languages, foreground separation and unmount")
|
||||||
|
NSApp.terminate(nil)
|
||||||
|
}
|
||||||
|
NSApp.run()
|
||||||
|
}
|
||||||
|
|
||||||
|
@MainActor private static func fixture(probe: DetailProbe, dualMetric: Bool) -> some View {
|
||||||
|
let dates = (0..<60).map { Date(timeIntervalSinceReferenceDate: Double($0 * 2)) }
|
||||||
|
return ResourceCard(title: "metric.network", symbol: "network", color: .blue,
|
||||||
|
value: dualMetric ? "↓ 999.9 TB/s" : "99%", secondaryValue: dualMetric ? "↑ 999.9 TB/s" : nil,
|
||||||
|
chart: {
|
||||||
|
PanelTrendChart(dates: dates, first: Array(repeating: 0.3, count: 60),
|
||||||
|
second: Array(repeating: 0.6, count: 60), color: .blue)
|
||||||
|
}) {
|
||||||
|
DetailMarker(probe: probe).frame(height: 84)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@MainActor private static func descendants(_ view: NSView) -> [NSView] {
|
||||||
|
[view] + view.subviews.flatMap(descendants)
|
||||||
|
}
|
||||||
|
@MainActor private static func topRect(_ view: NSView, in host: NSView) -> CGRect {
|
||||||
|
let rect = view.convert(view.bounds, to: host)
|
||||||
|
return host.isFlipped ? rect : CGRect(x: rect.minX, y: host.bounds.height - rect.maxY, width: rect.width, height: rect.height)
|
||||||
|
}
|
||||||
|
@MainActor private final class DetailProbe { weak var view: NSView? }
|
||||||
|
private struct DetailMarker: NSViewRepresentable {
|
||||||
|
let probe: DetailProbe
|
||||||
|
func makeNSView(context: Context) -> NSView { let view = NSView(); probe.view = view; return view }
|
||||||
|
func updateNSView(_ view: NSView, context: Context) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-3
@@ -61,7 +61,19 @@ CHECKS.update({
|
|||||||
"kymo/Features/MenuBar/PanelWindowObserver.swift", "kymo/UI/Components/IntervalControl.swift"],
|
"kymo/Features/MenuBar/PanelWindowObserver.swift", "kymo/UI/Components/IntervalControl.swift"],
|
||||||
"SandboxNetworkChecks": ["kymo/Core/Services/PublicIPAddressService.swift"],
|
"SandboxNetworkChecks": ["kymo/Core/Services/PublicIPAddressService.swift"],
|
||||||
})
|
})
|
||||||
GUI = {"NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "LanguageScopeChecks", "SettingsWindowChecks", "PanelWindowChecks", "TabPickerChecks"}
|
CHECKS["ResourceCardChecks"] = [
|
||||||
|
"kymo/UI/Components/ResourceCard.swift", "kymo/UI/Components/ResourceCardMetrics.swift",
|
||||||
|
"kymo/UI/Components/PanelStyle.swift", "kymo/UI/Components/NativeContentHost.swift",
|
||||||
|
"kymo/UI/Components/MetricText.swift", "kymo/UI/Components/TooltipBackground.swift",
|
||||||
|
"kymo/UI/Charts/PanelTrendChart.swift", "kymo/UI/Charts/NativePanelCurve.swift",
|
||||||
|
"kymo/UI/Charts/PanelCurveFrame.swift", "kymo/UI/Charts/PanelCurveGeometry.swift",
|
||||||
|
"kymo/UI/Charts/ChartTooltipLayer.swift", "kymo/Core/Extensions/MetricFormat.swift",
|
||||||
|
]
|
||||||
|
|
||||||
|
for name in ("PanelLayoutChecks", "PanelWindowChecks"):
|
||||||
|
CHECKS[name].append("kymo/UI/Components/ResourceCardMetrics.swift")
|
||||||
|
|
||||||
|
GUI = {"ResourceCardChecks", "NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "LanguageScopeChecks", "SettingsWindowChecks", "PanelWindowChecks", "TabPickerChecks"}
|
||||||
NETWORK = {"SandboxNetworkChecks"}
|
NETWORK = {"SandboxNetworkChecks"}
|
||||||
SERVICES = {"ReleaseServiceChecks"}
|
SERVICES = {"ReleaseServiceChecks"}
|
||||||
|
|
||||||
@@ -95,7 +107,7 @@ def test_bundle(work, name, executable, host_entitlements=None, resources=None,
|
|||||||
(contents / "Info.plist").write_bytes(plistlib.dumps({
|
(contents / "Info.plist").write_bytes(plistlib.dumps({
|
||||||
"CFBundleIdentifier": "cn.airnan.kymo.checks." + uuid.uuid4().hex,
|
"CFBundleIdentifier": "cn.airnan.kymo.checks." + uuid.uuid4().hex,
|
||||||
"CFBundleExecutable": name, "CFBundlePackageType": "APPL",
|
"CFBundleExecutable": name, "CFBundlePackageType": "APPL",
|
||||||
"LSUIElement": name in {"PanelWindowChecks", "NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "NetworkAddressChecks", "SandboxNetworkChecks", "TabPickerChecks"},
|
"LSUIElement": name in {"ResourceCardChecks", "PanelWindowChecks", "NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "NetworkAddressChecks", "SandboxNetworkChecks", "TabPickerChecks"},
|
||||||
}))
|
}))
|
||||||
if resources:
|
if resources:
|
||||||
shutil.copytree(resources, contents / "Resources")
|
shutil.copytree(resources, contents / "Resources")
|
||||||
@@ -176,7 +188,7 @@ def main():
|
|||||||
run(["swiftc", "-parse-as-library", "-module-cache-path", work / "cache", *CHECKS[name],
|
run(["swiftc", "-parse-as-library", "-module-cache-path", work / "cache", *CHECKS[name],
|
||||||
f"kymoTests/{name}.swift", "-o", executable])
|
f"kymoTests/{name}.swift", "-o", executable])
|
||||||
if name in GUI:
|
if name in GUI:
|
||||||
bundle = test_bundle(work, name, executable, resources=app / "Contents/Resources" if name in {"NativeProcessTableChecks", "TabPickerChecks"} else None)
|
bundle = test_bundle(work, name, executable, resources=app / "Contents/Resources" if name in {"ResourceCardChecks", "NativeProcessTableChecks", "TabPickerChecks"} else None)
|
||||||
# Open the complete app for native activation semantics, while collecting its output.
|
# Open the complete app for native activation semantics, while collecting its output.
|
||||||
output = work / (name + ".out")
|
output = work / (name + ".out")
|
||||||
error = work / (name + ".err")
|
error = work / (name + ".err")
|
||||||
|
|||||||
Reference in New Issue
Block a user