feat(panel): 调整资源卡片读数布局并保留趋势平移
逐核显示 CPU 占用,在 GPU 标题展示核数并补充分项读数。无电池设备显示整机功率。 存储与网络将曲线排在详情下方,CPU、GPU、内存和电池保留整卡趋势。数值直接刷新,曲线随采样平滑平移。顶栏展示版本号,底栏调整开机时间和刷新间隔。
This commit is contained in:
@@ -4,15 +4,15 @@ Kymo 是 macOS 菜单栏资源监控工具。菜单栏常驻品牌图标,点
|
|||||||
|
|
||||||
## 当前功能
|
## 当前功能
|
||||||
|
|
||||||
- CPU:总占用、用户态与系统态趋势、按核型分行的逐核细条与悬浮数值、温度;设备信息与开机时间位于公共底栏。
|
- CPU:总占用、用户态与系统态趋势、按核型分组的逐核单元与悬浮数值、温度;设备信息与开机时间位于公共底栏。
|
||||||
- GPU:占用 / 空闲堆叠趋势,Renderer / Tiler 历史提示、核心数、温度和风扇转速。
|
- GPU:总占用、渲染器与分块器实时百分比和独立趋势,标题后的核心数胶囊、温度和风扇转速。
|
||||||
- 内存:已用与总量、应用 / 联动 / 压缩分类、缓存、可用量、压力与 Swap。
|
- 内存:已用与总量、应用 / 联动 / 压缩分类、缓存、可用量、压力与 Swap。
|
||||||
- 存储:主目录所在卷容量、块设备读写速率、各本地卷容量、可读取的 SMART 寿命与通电时间。
|
- 存储:主目录所在卷容量、块设备读写速率、各本地卷容量、可读取的 SMART 寿命与通电时间。
|
||||||
- 电池:电量、功率、电源状态、健康度、循环次数、放电时间估计。
|
- 电池:电量、功率、电源状态、健康度、循环次数、放电时间估计;确认无电池时显示传感器整机即时功率及 W 趋势。
|
||||||
- 网络:接口切换、收发速率与累计字节、路径状态、本地和公网 IP 及复制。
|
- 网络:接口切换、收发速率与累计字节、路径状态、本地和公网 IP 及复制。
|
||||||
- 进程:PID、名称、CPU、内存 footprint、CPU 平均功率、线程数六列;路径仍支持搜索和右键复制,无横向滚动条;支持列排序及复制,功率缺失始终排末。
|
- 进程:PID、名称、CPU、内存 footprint、CPU 平均功率、线程数六列;路径仍支持搜索和右键复制,无横向滚动条;支持列排序及复制,功率缺失始终排末。
|
||||||
|
|
||||||
面板支持固定显示、保持唤醒、暂停 / 恢复采样。首行 CPU / GPU / 内存,次行电池 / 存储 / 网络,第三行进程表跨满内容区;默认三行均高 176pt,面板 648×630pt,小屏退为两列或单列并滚动。趋势覆盖卡片全宽全高,文字叠放其上;CPU 系统 / 用户、内存应用 / 联动 / 压缩、GPU 占用 / 空闲按分量堆叠,悬浮查询原始历史;存储 / 网络以 60% 高度零轴上下显示读 / 写、上传 / 下载,内存不再重复显示容量条。逐核为方块竖柱;风扇图标沿用转速档位旋转,暂停、隐藏或系统减弱动态效果时停转。数字与曲线直接更新,无背景模糊。资源和进程同时按可见性采样,后台趋势独立控制。面板刷新默认 2 秒;默认隐藏停止采样,可显式开启后台趋势并配置间隔(新配置 30 秒)。设置窗口提供系统 / 浅色 / 深色外观、简体中文 / 繁體中文 / English 和关于信息。
|
面板支持固定显示、保持唤醒、暂停 / 恢复采样。首行 CPU / GPU / 内存,次行电池 / 存储 / 网络,第三行进程表跨满内容区;默认三行均高 176pt,面板 648×630pt,小屏退为两列或单列并滚动。CPU、GPU、内存和电池趋势覆盖整卡,存储和网络趋势位于详情下方;CPU 系统 / 用户、内存应用 / 联动 / 压缩按分量堆叠,悬浮查询原始历史;存储 / 网络以绘图区 60% 高度零轴上下显示读 / 写、上传 / 下载,内存不再重复显示容量条。每个逻辑核对应一格,以填充高度表示占用;风扇图标沿用转速档位旋转,暂停、隐藏或系统减弱动态效果时停转。数值随采样直接更新。曲线随新采样平滑平移,遵循系统减弱动态效果。资源和进程同时按可见性采样,后台趋势独立控制。面板刷新默认 2 秒;默认隐藏停止采样,可显式开启后台趋势并配置间隔(新配置 30 秒)。设置窗口提供系统 / 浅色 / 深色外观、简体中文 / 繁體中文 / English 和关于信息。
|
||||||
|
|
||||||
部分硬件指标依赖机型、驱动与权限,缺失值显示为 `--` 或对应状态。GPU 不提供逐核占用;耗电进程显示系统归属的 CPU 能量区间平均功率,注明可读覆盖范围,不代表完整应用总耗电。指标口径和限制见[监控指标](docs/monitoring.md)。
|
部分硬件指标依赖机型、驱动与权限,缺失值显示为 `--` 或对应状态。GPU 不提供逐核占用;耗电进程显示系统归属的 CPU 能量区间平均功率,注明可读覆盖范围,不代表完整应用总耗电。指标口径和限制见[监控指标](docs/monitoring.md)。
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
| `kymo/Core/Models` / `Extensions` | 指标、进程身份、有界历史 / 格式化 |
|
| `kymo/Core/Models` / `Extensions` | 指标、进程身份、有界历史 / 格式化 |
|
||||||
| `kymo/UI` | 无业务副作用的卡片、图表、控件、外观与本地化宿主 |
|
| `kymo/UI` | 无业务副作用的卡片、图表、控件、外观与本地化宿主 |
|
||||||
| `kymo/Resources` / `Assets.xcassets` | 三语字符串 / 颜色和图片 |
|
| `kymo/Resources` / `Assets.xcassets` | 三语字符串 / 颜色和图片 |
|
||||||
| `SMARTService` | 按需只读 XPC:温度、风扇、SMART、同 UID 进程 footprint 与 CPU 能量 |
|
| `SMARTService` | 按需只读 XPC:温度、风扇、整机功率、SMART、同 UID 进程 footprint 与 CPU 能量 |
|
||||||
|
|
||||||
App 装配依赖,方向为 Features → UI → Core → 系统 API。Features 可使用窗口所需 AppKit / SwiftUI;模块之间通过 App 注入动作与 Core 状态协作,无横向依赖。Core 不引用 Features 或 UI。SettingsPresentation 仅表示展示请求,不持有窗口。
|
App 装配依赖,方向为 Features → UI → Core → 系统 API。Features 可使用窗口所需 AppKit / SwiftUI;模块之间通过 App 注入动作与 Core 状态协作,无横向依赖。Core 不引用 Features 或 UI。SettingsPresentation 仅表示展示请求,不持有窗口。
|
||||||
|
|
||||||
@@ -22,9 +22,9 @@ App 装配依赖,方向为 Features → UI → Core → 系统 API。Features
|
|||||||
|
|
||||||
MenuPanelController 拥有模板品牌 NSStatusItem 和无边框、可成为 key 的非激活 MonitoringPanel。左键切换面板,右键提供打开 / 隐藏、设置和退出。窗口以状态项所在屏幕可见区域为边界,水平居中,边缘至少留 16pt;最大宽 648pt,常规高 630pt,按卡片内容预算调整,最大高 800pt,并受实际屏幕限制。
|
MenuPanelController 拥有模板品牌 NSStatusItem 和无边框、可成为 key 的非激活 MonitoringPanel。左键切换面板,右键提供打开 / 隐藏、设置和退出。窗口以状态项所在屏幕可见区域为边界,水平居中,边缘至少留 16pt;最大宽 648pt,常规高 630pt,按卡片内容预算调整,最大高 800pt,并受实际屏幕限制。
|
||||||
|
|
||||||
单页面板首行 CPU / GPU / 内存,次行电池 / 存储 / 网络,第三行进程表跨满内容区。所有行按最高资源卡片的结构预算等高,默认均为 176pt;资源卡片宽 205⅓pt。32pt 顶栏只放品牌和操作,26pt 底栏显示设备、开机时间和刷新间隔。宽度小于 620pt 退为两列资源网格,小于 430pt 退为单列;进程始终放在资源之后,高度不足时中间区域整体滚动,表格保留自身滚动。
|
单页面板首行 CPU / GPU / 内存,次行电池 / 存储 / 网络,第三行进程表跨满内容区。所有行按最高资源卡片的结构预算等高,默认均为 176pt;资源卡片宽 205⅓pt。32pt 顶栏在品牌标题右上方显示包内短版本号。26pt 底栏从左向右排列开机时间、设备与刷新间隔,面板间隔输入框宽 50pt。宽度小于 620pt 退为两列资源网格,小于 430pt 退为单列;进程始终放在资源之后,高度不足时中间区域整体滚动,表格保留自身滚动。
|
||||||
|
|
||||||
核心数由静态拓扑、硬件核数及快照共同确定;核型分组横向排列,各核心为四个 6×6pt 方块组成的 30pt 竖柱,从底部按真实比例填充,保留悬浮 / 辅助功能数值。核心较多时换行,每增加一行结构预算增加 34pt;风扇超过一行后每行增加 14pt,本次打开保留已发现槽位。实际卡片宽度和窗口 contentLayoutRect 驱动布局,仅结构预算变化才请求调整窗口高度。
|
核心数由静态拓扑、硬件核数及快照共同确定;核型分组横向排列,每个逻辑核对应一个 7×11pt 单元,从底部按真实比例填充,保留悬浮 / 辅助功能数值。核心较多时换行,每增加一行结构预算增加 15pt;风扇超过一行后每行增加 18pt,本次打开保留已发现槽位。实际卡片宽度和窗口 contentLayoutRect 驱动布局,仅结构预算变化才请求调整窗口高度。
|
||||||
|
|
||||||
固定按钮切换 normal / floating 层级。未固定时外部交互或应用失活收起;固定仍可显式关闭。进程表 Esc 依次清空搜索、清除选择、退出搜索焦点,然后关闭面板。隐藏卸载内容、关闭底层窗口资源并移除外部鼠标监听,控制器保留窗口对象供重开。presentation.isOpen 控制内容装配,采样可见性同时要求窗口 isVisible 与 occlusionState 可见;完全遮挡降级采样而保留内容及交互状态。
|
固定按钮切换 normal / floating 层级。未固定时外部交互或应用失活收起;固定仍可显式关闭。进程表 Esc 依次清空搜索、清除选择、退出搜索焦点,然后关闭面板。隐藏卸载内容、关闭底层窗口资源并移除外部鼠标监听,控制器保留窗口对象供重开。presentation.isOpen 控制内容装配,采样可见性同时要求窗口 isVisible 与 occlusionState 可见;完全遮挡降级采样而保留内容及交互状态。
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ MenuPanelController 拥有模板品牌 NSStatusItem 和无边框、可成为 key
|
|||||||
│ ├─ snapshot → 资源卡片
|
│ ├─ snapshot → 资源卡片
|
||||||
├─ 慢任务缓存 ├─ processSnapshot / energy → 进程表
|
├─ 慢任务缓存 ├─ processSnapshot / energy → 进程表
|
||||||
└─ 单在途进程任务 └─ MetricHistory → 趋势图
|
└─ 单在途进程任务 └─ MetricHistory → 趋势图
|
||||||
SMARTService(XPC)→ 只读客户端 → 慢缓存 / 进程任务
|
SMARTService(XPC)→ 只读客户端 → 整机功率 / 慢缓存 / 进程任务
|
||||||
实际可见性、详情需求、睡眠与偏好 → MetricsStore 调度
|
实际可见性、详情需求、睡眠与偏好 → MetricsStore 调度
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -55,11 +55,11 @@ SystemSampler actor 持有差分基线。CPU / 内存 Mach 查询取得的 host
|
|||||||
|
|
||||||
## 展示与本地状态
|
## 展示与本地状态
|
||||||
|
|
||||||
ResourceCard 通过 NativeContentHost 使用固定尺寸的独立 NSHostingView,传递字体、颜色、语言及外观环境;更新沿用挂载身份,卸载清空子宿主内容。背景绘图区覆盖卡片全宽全高:CPU / GPU / 电池底边为 0、顶边为 100%,内存顶边为物理总量;速率采用独立双向投影,文字和控件叠放其上。标题 / 主值 / 详情直接叠放于图表之上,不增加文字底板或局部压淡。辅助信息主要为 10pt / 16pt 行高,内存和存储详情通过 ViewThatFits 按信息组换行,默认卡片仍为 176pt 高。统一 16pt 圆角、10pt 前景内边距和静态轻阴影,图表锚点和提示在同一宿主内处理;不显示常驻图例、数值坐标轴、网格或起止时间。
|
ResourceCard 通过 NativeContentHost 使用固定尺寸的独立 NSHostingView,传递字体、颜色、语言及外观环境;更新沿用挂载身份,卸载清空子宿主内容。CPU、GPU、内存、电池采用整卡背景图,卡片顶边对应 100% 或物理内存总量,底边对应零。存储、网络与无电池时的整机功率图使用详情下方的剩余高度。辅助信息主要为 10pt / 16pt 行高,内存和存储详情通过 ViewThatFits 按信息组换行,默认卡片仍为 176pt 高。统一 16pt 圆角、10pt 前景内边距和静态轻阴影,图表锚点和提示在同一宿主内处理;不显示常驻图例、数值坐标轴、网格或起止时间。
|
||||||
|
|
||||||
StackedSeries 仅在渲染时构建累计上下边界:CPU 自下而上为系统 / 用户,内存为应用 / 联动 / 压缩,GPU 为总占用 / 空闲(相加为 100%,Renderer / Tiler 保留原始提示读数)。任一必要分量缺失或无效时不构造部分总量,原始历史不变。NativePanelCurve 按连续段在匹配的上下边界间闭合面积,保留真实断点;悬浮使用缓存累计边界定位,而提示读取原始分量。电池绘制电量。存储 / 网络通过 PanelCurveProjection.split 在自卡片顶向下 60% 位置绘制零轴,读取 / 上传向上、写入 / 下载向下,两侧各使用卡片高度 30% 的振幅并共享自动速率尺度,峰值不映射到卡片顶边。原始速率仍为正值,提示、标记与面积采用同一投影,保留缺失与真实断点。内存的已用三层包含匿名应用 / 系统进程、联动和压缩器物理内存;缓存 / Swap 口径见监控文档,不再显示重复容量进度条。
|
StackedSeries 仅在渲染时构建累计上下边界:CPU 自下而上为系统 / 用户,内存为应用 / 联动 / 压缩。GPU 同轴绘制总占用、渲染器、分块器三条独立曲线,仅总占用填色。标题后的胶囊显示驱动报告的核心数,正文显示两个阶段读数。任一必要分量缺失或无效时不构造部分总量,原始历史不变。NativePanelCurve 按连续段在匹配的上下边界间闭合面积,保留真实断点;悬浮使用缓存累计边界定位,而提示读取原始分量。有内置电池绘制电量;仅在 IOPowerSources 确认无内置电池时,前台详情轮次通过固定只读 XPC 请求 AppleSMC PSTR,快照和历史独立保存整机瓦数。请求最多一个在途、2 秒超时,不可用退避 60–600 秒,不用旧值填充历史。存储 / 网络通过 PanelCurveProjection.split 在自绘图区顶向下 60% 位置绘制零轴,读取 / 上传向上、写入 / 下载向下,两侧各使用绘图区高度 30% 的振幅并共享自动速率尺度,峰值不映射到卡片顶边。原始速率仍为正值,提示、标记与面积采用同一投影,保留缺失与真实断点。内存的已用三层包含匿名应用 / 系统进程、联动和压缩器物理内存;缓存 / Swap 口径见监控文档,不再显示重复容量进度条。
|
||||||
|
|
||||||
数字、曲线和进度条直接更新,曲线不创建动画、渐变或遮罩图层,不使用背景模糊。风扇是唯一持续动效:FanRotor 将 SF Symbol 绘制到独立图像子图层,固定中心锚点和位置,使用原生 Core Animation 旋转子图层,AppKit 宿主图层保持不变,按历史 RPM 档位映射 90 / 180 / 300 / 450°/s,切档保留相位;零 / 无效 / 缺失值、系统减弱动态效果、暂停、隐藏、遮挡、睡眠或卸载时停止。没有新增帧计时器。样式与异常状态见 [UI 设计规范](ui-design-standard.md)。
|
MetricText 用等宽数字直接显示当前读数。连续追加时 NativePanelCurve 在已有 curves 图层进行 0.35 秒水平变换,历史满窗时绘制一个出界旧点;不逐帧重建路径。悬浮时对齐最终位置,暂停、减弱动态效果与断点不启动滚动。风扇是唯一持续动效:FanRotor 将 SF Symbol 绘制到独立图像子图层,固定中心锚点和位置,使用原生 Core Animation 旋转子图层,AppKit 宿主图层保持不变,按历史 RPM 档位映射 90 / 180 / 300 / 450°/s,切档保留相位;零 / 无效 / 缺失值、系统减弱动态效果、暂停、隐藏、遮挡、睡眠或卸载时停止。没有新增帧计时器。样式与异常状态见 [UI 设计规范](ui-design-standard.md)。
|
||||||
|
|
||||||
设置使用 NeutralTabPicker 静态 AppKit 按钮组,保留 tabGroup / tabButton 语义、选中值与键盘导航。
|
设置使用 NeutralTabPicker 静态 AppKit 按钮组,保留 tabGroup / tabButton 语义、选中值与键盘导航。
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ StackedSeries 仅在渲染时构建累计上下边界:CPU 自下而上为系
|
|||||||
|
|
||||||
主应用启用 App Sandbox 和出站网络权限;SMARTService 不启用沙盒,启用 Hardened Runtime,是同用户按需启动的只读服务,不是 root 守护进程,不写 SMC。客户端以包内服务实际 designated requirement 限制连接;服务按同 UID 和所属主应用的实际签名要求认证调用方。
|
主应用启用 App Sandbox 和出站网络权限;SMARTService 不启用沙盒,启用 Hardened Runtime,是同用户按需启动的只读服务,不是 root 守护进程,不写 SMC。客户端以包内服务实际 designated requirement 限制连接;服务按同 UID 和所属主应用的实际签名要求认证调用方。
|
||||||
|
|
||||||
ServiceRequest 统一一次性完成响应、错误、中断、超时和取消,并释放计时器与连接。温度 / 风扇超时 2 秒,SMART 超时 15 秒。传感器发现由服务 actor 缓存,各能力独立退避。进程 footprint 和能量经原有签名认证服务批量读取,最多 256 项 / 请求 64 KiB / 响应 256 KiB;客户端总截止 3 秒、单请求 1.5 秒,服务每批 1 秒。服务限制同 UID、PID 与启动时间,能量额外校验请求 UUID、启动标记和计数。进程单在途任务先合并 footprint 再发布、调度能量;缺失内存不回退 RSS。具体口径见[监控指标](monitoring.md)。
|
ServiceRequest 统一一次性完成响应、错误、中断、超时和取消,并释放计时器与连接。温度 / 风扇 / 整机功率超时 2 秒,SMART 超时 15 秒。传感器发现由服务 actor 缓存,各能力独立退避。进程 footprint 和能量经原有签名认证服务批量读取,最多 256 项 / 请求 64 KiB / 响应 256 KiB;客户端总截止 3 秒、单请求 1.5 秒,服务每批 1 秒。服务限制同 UID、PID 与启动时间,能量额外校验请求 UUID、启动标记和计数。进程单在途任务先合并 footprint 再发布、调度能量;缺失内存不回退 RSS。具体口径见[监控指标](monitoring.md)。
|
||||||
|
|
||||||
system_profiler / diskutil 共用 BoundedProcess,流式保留最多 256 KiB,额外至多读 1 字节检测溢出;10 秒截止、超限或调用 Task 取消时终止并回收本轮直接子进程。取消管道唤醒 poll,无周期检查计时器,不杀其他进程。XPC 断开尚不保证取消已进入服务的报告任务。
|
system_profiler / diskutil 共用 BoundedProcess,流式保留最多 256 KiB,额外至多读 1 字节检测溢出;10 秒截止、超限或调用 Task 取消时终止并回收本轮直接子进程。取消管道唤醒 poll,无周期检查计时器,不杀其他进程。XPC 断开尚不保证取消已进入服务的报告任务。
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
趋势图跳过无值节点,按真实时间连接前后有效点;有效 0 仍绘制,暂停 / 休眠等显式断点及真实采样空档仍断线。连接只影响曲线外观:缺失时刻悬浮读数为 `--`,原历史不补值。
|
趋势图跳过无值节点,按真实时间连接前后有效点;有效 0 仍绘制,暂停 / 休眠等显式断点及真实采样空档仍断线。连接只影响曲线外观:缺失时刻悬浮读数为 `--`,原历史不补值。
|
||||||
|
|
||||||
趋势覆盖整张卡片,CPU / GPU / 电池底边为 0、顶边为 100%,内存顶边为物理总量,文字和控件叠放其上。CPU 自下而上堆叠系统态 / 用户态,内存堆叠应用 / 联动 / 压缩,GPU 堆叠占用 / 空闲(相加为 100%);Renderer / Tiler 可能重叠,仅保留原始历史提示。电池显示电量,功率提示独立标 W;存储 / 网络以自顶向下 60% 高度为零轴,读取 / 上传向上、写入 / 下载向下;两侧同样使用 30% 卡片高度振幅及共享自动速率尺度,原始值和提示均保持正速率。不显示常驻数值坐标轴、网格或图例。静态淡色面积在匹配的累计上下边界间按真实连续段闭合,不跨暂停或长空档;单点只显示真实点,必要分量缺失不构造部分总量。悬浮不会替换上方实时主数值。
|
CPU / GPU / 电池的零值与 100% 分别映射到卡片底边和顶边,内存卡片顶边为物理总量。存储、网络以及无电池设备的功率曲线绘在文字下方。CPU 自下而上堆叠系统态 / 用户态,内存堆叠应用 / 联动 / 压缩,GPU 总利用率、Renderer、Tiler 分别绘制,阶段可能重叠,不相加。电池显示电量,功率提示独立标 W;存储 / 网络以自顶向下 60% 高度为零轴,读取 / 上传向上、写入 / 下载向下;两侧同样使用 30% 绘图区高度振幅及共享自动速率尺度,原始值和提示均保持正速率。不显示常驻数值坐标轴、网格或图例。静态淡色面积在匹配的累计上下边界间按真实连续段闭合,不跨暂停或长空档;单点只显示真实点,必要分量缺失不构造部分总量。悬浮不会替换上方实时主数值。
|
||||||
|
|
||||||
## 数据来源
|
## 数据来源
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
| 存储 IO | `DiskIOMonitor`,IOBlockStorageDriver 累计字节 | 物理块设备读写速率,非主卷文件 IO;设备集合变化、计数回退、首次读取均重建基线 |
|
| 存储 IO | `DiskIOMonitor`,IOBlockStorageDriver 累计字节 | 物理块设备读写速率,非主卷文件 IO;设备集合变化、计数回退、首次读取均重建基线 |
|
||||||
| SMART | `DiskHealthMonitor` → XPC → `diskutil info -plist` | 主目录所在卷关联报告中的寿命和通电时间;剩余寿命 = 100 − PERCENTAGE_USED(下限 0),通电小时要求高位为 0,多物理存储拒绝合并;不代表所有卷或磁盘 |
|
| SMART | `DiskHealthMonitor` → XPC → `diskutil info -plist` | 主目录所在卷关联报告中的寿命和通电时间;剩余寿命 = 100 − PERCENTAGE_USED(下限 0),通电小时要求高位为 0,多物理存储拒绝合并;不代表所有卷或磁盘 |
|
||||||
| 电池 | `BatteryMonitor`,IOPowerSources 与 AppleSmartBattery | 电量、充电 / 外接电源、循环和功率;功率取电压 × 电流的绝对值,非整机功耗;区分无内置电池和读取失败 |
|
| 电池 | `BatteryMonitor`,IOPowerSources 与 AppleSmartBattery | 电量、充电 / 外接电源、循环和功率;功率取电压 × 电流的绝对值,非整机功耗;区分无内置电池和读取失败 |
|
||||||
|
| 无电池整机功率 | 签名 XPC 只读 AppleSMC 固定键 PSTR | 传感器即时整机功率 W,不是插座侧计量;字段口径可对照 [Stats 传感器表](https://github.com/exelban/stats/blob/master/Modules/Sensors/values.swift)。不支持或读取失败显示不可用,不用电池或进程功率替代 |
|
||||||
| 电池健康 | `SystemBatteryHealthMonitor`,`system_profiler SPPowerDataType -json` | 使用系统报告的最大容量百分比,不用当前充电容量推算 |
|
| 电池健康 | `SystemBatteryHealthMonitor`,`system_profiler SPPowerDataType -json` | 使用系统报告的最大容量百分比,不用当前充电容量推算 |
|
||||||
| 网络 | `NetworkMonitor`,`NET_RT_IFLIST2` 64 位计数与 `getifaddrs` | 累计收发计数不属于应用会话流量;速率按实际经过时间差分,回退或接口身份 / 地址变化时重建基线;计数缓冲在采样器内复用,容量不足时扩容,仅解析本轮实际返回字节;本地地址保持系统 numeric formatter(含 scope),每轮共用地址缓冲、每接口最终排序一次 |
|
| 网络 | `NetworkMonitor`,`NET_RT_IFLIST2` 64 位计数与 `getifaddrs` | 累计收发计数不属于应用会话流量;速率按实际经过时间差分,回退或接口身份 / 地址变化时重建基线;计数缓冲在采样器内复用,容量不足时扩容,仅解析本轮实际返回字节;本地地址保持系统 numeric formatter(含 scope),每轮共用地址缓冲、每接口最终排序一次 |
|
||||||
| 网络路径 | `NetworkPathObserver`,NWPathMonitor | 可用 / 不可用 / 需连接;代码取 `availableInterfaces.first` 作为主接口候选,并非独立解析系统默认路由;路径可用不保证公网可达 |
|
| 网络路径 | `NetworkPathObserver`,NWPathMonitor | 可用 / 不可用 / 需连接;代码取 `availableInterfaces.first` 作为主接口候选,并非独立解析系统默认路由;路径可用不保证公网可达 |
|
||||||
@@ -50,6 +51,7 @@
|
|||||||
| 进程 | 请求进程详情且面板实际可见、未暂停 / 睡眠时随采样请求更新;异步独立发布,最多一个在途 |
|
| 进程 | 请求进程详情且面板实际可见、未暂停 / 睡眠时随采样请求更新;异步独立发布,最多一个在途 |
|
||||||
| 进程 CPU 能量 | 复用同轮进程候选,成功后至少 5 秒再读(默认 2 秒轮次下通常约 6 秒);失败 30–600 秒退避,明确不支持后 600 秒;最多一批在途 |
|
| 进程 CPU 能量 | 复用同轮进程候选,成功后至少 5 秒再读(默认 2 秒轮次下通常约 6 秒);失败 30–600 秒退避,明确不支持后 600 秒;最多一批在途 |
|
||||||
| CPU / GPU 温度、风扇 | 一次批量请求中只读取到期类别;各类别成功后至少 10 秒再读,失败独立退避 60–600 秒 |
|
| CPU / GPU 温度、风扇 | 一次批量请求中只读取到期类别;各类别成功后至少 10 秒再读,失败独立退避 60–600 秒 |
|
||||||
|
| 无电池整机功率 | 仅可见且请求详情时按面板采样间隔读取;2 秒超时、失败独立退避 60–600 秒,历史保留缺失 |
|
||||||
| 卷列表 | 读取结束后至少 30 秒 |
|
| 卷列表 | 读取结束后至少 30 秒 |
|
||||||
| SMART / 电池健康 | 成功后至少 3600 秒;失败后至少 600 秒 |
|
| SMART / 电池健康 | 成功后至少 3600 秒;失败后至少 600 秒 |
|
||||||
| 公网 IP | 同一路由键成功缓存 600 秒,失败缓存 30 秒,请求超时 5 秒;面板可见时按缓存到期持续刷新,路由键变化、暂停或面板隐藏取消请求及等待,取消不缓存;有效期使用单调时间 |
|
| 公网 IP | 同一路由键成功缓存 600 秒,失败缓存 30 秒,请求超时 5 秒;面板可见时按缓存到期持续刷新,路由键变化、暂停或面板隐藏取消请求及等待,取消不缓存;有效期使用单调时间 |
|
||||||
|
|||||||
@@ -6,3 +6,7 @@
|
|||||||
2. MenuBar / UI / Resources:前景按实际内容高度排版,余下区域给曲线;保留双向速率、现有控件、历史断点与提示。一核一格以连续填充显示负载,GPU 渲染器 / 分块器常显,不相加。无电池切换功率卡与 W 趋势,三语一致。
|
2. MenuBar / UI / Resources:前景按实际内容高度排版,余下区域给曲线;保留双向速率、现有控件、历史断点与提示。一核一格以连续填充显示负载,GPU 渲染器 / 分块器常显,不相加。无电池切换功率卡与 W 趋势,三语一致。
|
||||||
3. UI:复用初版系统 numericText 动效;连续追加时对已有曲线图层短暂做水平变换,不设逐帧计时器。悬浮、断点和减弱动态效果时保持静态。
|
3. UI:复用初版系统 numericText 动效;连续追加时对已有曲线图层短暂做水平变换,不设逐帧计时器。悬浮、断点和减弱动态效果时保持静态。
|
||||||
4. 验证构建、逐核/高核数换行、曲线滚动与悬浮、缺失值、XPC 实际读取、不同宽度三语布局以及真实面板。保留已运行的应用。当前机器为 MacBook Pro,不能代替 Mac mini 整机验收;跨机型传感器支持、长期功耗与动效手感须分别评估。
|
4. 验证构建、逐核/高核数换行、曲线滚动与悬浮、缺失值、XPC 实际读取、不同宽度三语布局以及真实面板。保留已运行的应用。当前机器为 MacBook Pro,不能代替 Mac mini 整机验收;跨机型传感器支持、长期功耗与动效手感须分别评估。
|
||||||
|
|
||||||
|
实施完成。Debug 构建及 10 项相关 Swift 检查通过。签名沙盒经本轮 XPC 在 M4 Pro 读到 PSTR 30.04 W;桌面功率、无传感器、未知/读取失败和有电池状态使用生产卡片输入分别验证,尚无 Mac mini 实机结果。三语、浅深色及 190 / 205⅓ / 400pt 布局下文字与图区不重叠。真实面板三次打开均挂载六图区、关闭卸载;默认布局中存储 / 网络图高分别为 56 / 48pt。数字滚动以原生宿主中间帧核对;曲线验证满窗滚动、悬浮取消与断点。主观手感和长期能耗未验收。
|
||||||
|
|
||||||
|
交互边界:定向 Esc 关闭测试面板已观察到。AX 命中卷入口位置时仅返回组;定向合成点击未观察到弹出窗口,屏幕点击因命中位置不能确认由测试窗口独占而跳过。卷详情弹出仍需在新版面板点击「本地卷」确认。
|
||||||
|
|||||||
+4
-4
@@ -34,16 +34,16 @@ python3 tools/check.py --list
|
|||||||
| GPUStatisticsChecks、CPUTemperatureChecks、FanChecks、DiskHealthChecks | 当前 GPU 利用率与历史、温度范围与解码、风扇零值 / 无效值、历史速度边界与切档相位、SMART 边界与多物理存储拒绝合并 |
|
| GPUStatisticsChecks、CPUTemperatureChecks、FanChecks、DiskHealthChecks | 当前 GPU 利用率与历史、温度范围与解码、风扇零值 / 无效值、历史速度边界与切档相位、SMART 边界与多物理存储拒绝合并 |
|
||||||
| SensorScheduleChecks、BoundedProcessChecks | 各能力独立退避;真实受控子进程输出上限、超时、取消、异常退出与回收 |
|
| SensorScheduleChecks、BoundedProcessChecks | 各能力独立退避;真实受控子进程输出上限、超时、取消、异常退出与回收 |
|
||||||
| ProcessEnergyChecks、ProcessEnergyReaderChecks、ProcessCPULiveChecks | UInt64 能量差分、身份 / UID / 缺失 / 回退 / 时间边界、受控本机能量增长和 Mach 时基 CPU 差分 |
|
| ProcessEnergyChecks、ProcessEnergyReaderChecks、ProcessCPULiveChecks | UInt64 能量差分、身份 / UID / 缺失 / 回退 / 时间边界、受控本机能量增长和 Mach 时基 CPU 差分 |
|
||||||
| ProcessSelectionChecks、PanelLayoutChecks、CPUCoreGridChecks | 退出与 PID 复用、搜索 / 排序、648pt 三列资源及第三行进程 / 两列及单列窄屏预算、全行等高与滚动边界、逐核竖柱行数与部分方块填充边界 |
|
| ProcessSelectionChecks、PanelLayoutChecks、CPUCoreGridChecks | 退出与 PID 复用、搜索 / 排序、648pt 三列资源及第三行进程 / 两列及单列窄屏预算、全行等高与滚动边界、逐核单元数量、分组和换行边界 |
|
||||||
| PublicIPAddressChecks | 隔离 URLProtocol、600 秒成功 / 30 秒失败缓存、单调时间、持续刷新及取消,不发送真实请求 |
|
| PublicIPAddressChecks | 隔离 URLProtocol、600 秒成功 / 30 秒失败缓存、单调时间、持续刷新及取消,不发送真实请求 |
|
||||||
| NetworkAddressChecks、ProcessIconCacheChecks | 沙盒下地址格式 / 速率;图标位图、尺寸、共享、过期、LRU 与严格预算 |
|
| NetworkAddressChecks、ProcessIconCacheChecks | 沙盒下地址格式 / 速率;图标位图、尺寸、共享、过期、LRU 与严格预算 |
|
||||||
| AppearancePreferencesChecks、LocalizationChecks、PresentationChecks | 外观与偏好隔离、语言持久化、编译资源、窗口显式 / 系统外观切换 |
|
| AppearancePreferencesChecks、LocalizationChecks、PresentationChecks | 外观与偏好隔离、语言持久化、编译资源、窗口显式 / 系统外观切换 |
|
||||||
| CodeIdentityChecks、PanelAssetChecks、KeepAwakeChecks | 签名身份拒绝边界、编译颜色及对比度、真实 IOPM 断言开关与释放 |
|
| CodeIdentityChecks、PanelAssetChecks、KeepAwakeChecks | 签名身份拒绝边界、编译颜色及对比度、真实 IOPM 断言开关与释放 |
|
||||||
| NativeMetricDrawingChecks(--gui) | 实际曲线 / 堆叠色带、双向速率面积和零轴、方向 / 悬浮 / 断点及累计边界定位、单点无虚构填充、隐藏序列隔离、缺失点接续与真实断点、悬浮缓存、无动画 / 渐变 / 遮罩、卸载 |
|
| NativeMetricDrawingChecks(--gui) | 实际曲线 / 堆叠色带、双向速率面积和零轴、方向 / 悬浮 / 断点及累计边界定位、单点无虚构填充、隐藏序列隔离、缺失点接续与真实断点、悬浮缓存、滚动时间域变换、悬浮停止动画、断点、无渐变 / 遮罩、卸载 |
|
||||||
| FanRotorChecks(--gui) | 独立图层多角度 / 多尺寸旋转中心不漂移,原生旋转动画时长、无效 / 零 / 缺失、非活动 / 减弱动态效果及卸载停转 |
|
| FanRotorChecks(--gui) | 独立图层多角度 / 多尺寸旋转中心不漂移,原生旋转动画时长、无效 / 零 / 缺失、非活动 / 减弱动态效果及卸载停转 |
|
||||||
| ResourceCardChecks(--gui) | 生产卡片与曲线真实挂载,190 / 205⅓ / 400pt、浅深色及三语下的全宽全高图区、文字区与底部留白的图表颜色一致、无局部压淡、10pt 三语内存 / 存储详情在固定卡片内的边界、卸载;比较 AppKit 实际尺寸,允许分数点窗口尺寸取整 |
|
| ResourceCardChecks(--gui) | 生产卡片与曲线真实挂载,190 / 205⅓ / 400pt、浅深色及三语下的整卡背景图区、存储与网络的独立图区及文字换行边界、10pt 三语内存 / 存储详情在固定卡片内的边界、模拟有电池 / 无电池 / 未知和失败的历史序列及单位尺度、卸载;比较 AppKit 实际尺寸,允许分数点窗口尺寸取整 |
|
||||||
| ProcessSectionChecks(--gui) | 生产进程区域固定 176pt,三语 / 浅深色及 340 / 628pt 下移除说明行后表格占满剩余高度且无横向滚动条 |
|
| ProcessSectionChecks(--gui) | 生产进程区域固定 176pt,三语 / 浅深色及 340 / 628pt 下移除说明行后表格占满剩余高度且无横向滚动条 |
|
||||||
| NativeContentHostChecks(--gui) | 数字更新、父环境继承、挂载身份、有限尺寸和卸载 |
|
| NativeContentHostChecks(--gui) | 小数末位增减后直接显示最终读数、更新帧与稳定帧像素一致、父环境继承、挂载身份、有限尺寸和卸载 |
|
||||||
| NativeProcessTableChecks(--gui) | 原生虚拟表格、原地更新、身份选择、六列窄宽度适配、隐藏路径列但真实菜单复制路径、排序 / 列序 / 复制 / 三语列头、合成 Esc 投递 |
|
| NativeProcessTableChecks(--gui) | 原生虚拟表格、原地更新、身份选择、六列窄宽度适配、隐藏路径列但真实菜单复制路径、排序 / 列序 / 复制 / 三语列头、合成 Esc 投递 |
|
||||||
| TabPickerChecks、LanguageScopeChecks、SettingsWindowChecks(--gui) | 原生页签选择与键盘、已挂载语言即时切换、设置焦点 / 最小化恢复 / Dock 生命周期 |
|
| TabPickerChecks、LanguageScopeChecks、SettingsWindowChecks(--gui) | 原生页签选择与键盘、已挂载语言即时切换、设置焦点 / 最小化恢复 / Dock 生命周期 |
|
||||||
| PanelWindowChecks(--gui) | 真实 NSPanel 居中、尺寸反馈、固定、遮挡可见性、显式关闭重开和退出复位 |
|
| PanelWindowChecks(--gui) | 真实 NSPanel 居中、尺寸反馈、固定、遮挡可见性、显式关闭重开和退出复位 |
|
||||||
|
|||||||
+15
-15
@@ -1,12 +1,12 @@
|
|||||||
# Kymo 界面设计规范 v1.5
|
# Kymo 界面设计规范 v1.6
|
||||||
|
|
||||||
2026-11-15 根据用户确认的[背景趋势设计稿](designs/card-background-trends-v1/README.md)制定,并按后续反馈将首版卡片宽、高缩至 2/3,恢复图稿中的紧凑左对齐排布;本轮将图表扩展到整卡、采用分量堆叠,并合并进程为第三行。本文为实现与验收标准,效果图中的示例数据、品牌重绘与核心格子不作为数据或素材依据。
|
2026-11-15 根据用户确认的[背景趋势设计稿](designs/card-background-trends-v1/README.md)制定,并按后续反馈将首版卡片宽、高缩至 2/3,恢复图稿中的紧凑左对齐排布;容量与占用趋势铺满卡片,速率趋势位于文字下方,保留分量曲线和第三行进程区。本文为实现与验收标准,效果图中的示例数据、品牌重绘与核心格子不作为数据或素材依据。
|
||||||
|
|
||||||
## 适用范围与原则
|
## 适用范围与原则
|
||||||
|
|
||||||
单页面板包括三列两行资源卡片及第三行通栏进程表,顶部移除概览 / 进程页签,保留工具栏与公共底栏。Settings 与进程表保留原有交互;共用外观、语言与控件语义。依赖方向继续为 Features → UI → Core。
|
单页面板包括三列两行资源卡片及第三行通栏进程表,顶部移除概览 / 进程页签,保留工具栏与公共底栏。Settings 与进程表保留原有交互;共用外观、语言与控件语义。依赖方向继续为 Features → UI → Core。
|
||||||
|
|
||||||
按确认图稿保持数值层级、左对齐信息行与曲线背景,并在用户指定尺寸内实现。所有缺失值显示 -- 或既有明确状态,不推导不存在的指标、不以装饰波形代替历史。无采样间的数值过渡、动态波纹、发光和背景模糊。
|
按确认图稿保持数值层级、左对齐信息行与曲线背景,并在用户指定尺寸内实现。所有缺失值显示 -- 或既有明确状态,不推导不存在的指标、不以装饰波形代替历史。数值随采样直接刷新。曲线随采样水平移动;遵循系统减弱动态效果,不使用背景模糊。
|
||||||
|
|
||||||
## 布局与尺寸(pt)
|
## 布局与尺寸(pt)
|
||||||
|
|
||||||
@@ -17,11 +17,11 @@
|
|||||||
| 顺序 | CPU / GPU / 内存 / 电池 / 存储 / 网络,按行阅读;进程位于资源之后,所有资源行与进程行等高 |
|
| 顺序 | CPU / GPU / 内存 / 电池 / 存储 / 网络,按行阅读;进程位于资源之后,所有资源行与进程行等高 |
|
||||||
| 面板内边距 / 卡片间距 | 10 / 6;常规卡片宽 205⅓ |
|
| 面板内边距 / 卡片间距 | 10 / 6;常规卡片宽 205⅓ |
|
||||||
| 卡片 | 基础高 176,圆角 16,前景内边距 10 |
|
| 卡片 | 基础高 176,圆角 16,前景内边距 10 |
|
||||||
| 动态高度 | CPU 核型横向分组,逐核竖柱一行基础预算,超出每行增加 34;GPU 超过一行风扇后每行增加 14;所有行采用最大结构预算,不裁掉硬件数据 |
|
| 动态高度 | CPU 核型横向分组,逐核单元一行基础预算,超出每行增加 15;GPU 超过一行风扇后每行增加 18;所有行采用最大结构预算,不裁掉硬件数据 |
|
||||||
| 标题 / 主值区域 | 标题行 16,主值行 34,区域间距 4 |
|
| 标题 / 主值区域 | 标题行 16,主值行 34,区域间距 4 |
|
||||||
| 背景趋势 | 覆盖全卡宽高,CPU / GPU / 电池底边 0、顶边 100%;内存顶边为物理总量;速率采用 60% 高度零轴的上下双向投影;文字与控件覆盖其上,按卡片圆角裁切 |
|
| 背景趋势 | CPU / GPU / 电池从卡底 0 到卡顶 100%,内存从卡底 0 到卡顶物理总量。存储和网络使用详情下方独立图区,零轴位于该区高度的 60% |
|
||||||
| 逐核格子 | 每核四个 6×6 方块,间距 2,柱高 30;底部先填充,最后一格部分填充保留真实比例;核型短标签在柱上方 |
|
| 逐核格子 | 每核一个 7×11 单元,从底部按真实比例填充;核型短标签与数量在上方 |
|
||||||
| 顶栏 / 底栏 | 32 / 26;操作可键盘访问 |
|
| 顶栏 / 底栏 | 32 / 26。标题右上显示版本胶囊,开机时间在底栏最左,间隔输入框宽 50 |
|
||||||
|
|
||||||
## 字体、颜色与层级
|
## 字体、颜色与层级
|
||||||
|
|
||||||
@@ -30,27 +30,27 @@
|
|||||||
- 主要辅助信息 10pt、行高 16pt,标签 secondary、数值 primary / medium;逐核紧凑短标签 9pt、行高 12pt。悬浮提示沿用 9pt。内存分类 / 存储读写和健康说明在宽度不足时按组换行;少数紧凑单行最低缩至 90%,避免回落到原 8pt。
|
- 主要辅助信息 10pt、行高 16pt,标签 secondary、数值 primary / medium;逐核紧凑短标签 9pt、行高 12pt。悬浮提示沿用 9pt。内存分类 / 存储读写和健康说明在宽度不足时按组换行;少数紧凑单行最低缩至 90%,避免回落到原 8pt。
|
||||||
- 主数值使用 primary,提高浅深色对比度;网络仅方向箭头着色。CPU 青绿(MetricCPU)、GPU 玫红(MetricGPU)、内存蓝(MemoryApplication)、电池绿(MetricBattery)、存储琥珀(MetricDisk)、下载蓝(MetricMemory)、上传琥珀(SeriesUpload)。所有颜色来自 Assets。
|
- 主数值使用 primary,提高浅深色对比度;网络仅方向箭头着色。CPU 青绿(MetricCPU)、GPU 玫红(MetricGPU)、内存蓝(MemoryApplication)、电池绿(MetricBattery)、存储琥珀(MetricDisk)、下载蓝(MetricMemory)、上传琥珀(SeriesUpload)。所有颜色来自 Assets。
|
||||||
- 温度在标题右侧;CPU ≥90°C 使用红色和既有高温说明。内存压力沿用正常 / 警告 / 严重颜色和文字,不能仅靠颜色传达状态。
|
- 温度在标题右侧;CPU ≥90°C 使用红色和既有高温说明。内存压力沿用正常 / 警告 / 严重颜色和文字,不能仅靠颜色传达状态。
|
||||||
- 标题、主值和详情直接叠放于整卡趋势上;按用户反馈取消文字底板和局部压淡,曲线 / 面积在文字区保持原有色彩和透明度。保留放大后的辅助字号、行距和按组换行,不使用模糊或渐变。
|
- CPU、GPU、内存和电池的文字叠在整卡趋势上。存储、网络和无电池整机功率卡优先安排详情高度,曲线接在下方。保留放大后的辅助字号、行距和按组换行,不使用模糊或渐变。
|
||||||
- 卡片采用 PanelCard、面板采用 PanelBackground 的浅深色资源。边框为 primary 浅色 2.5% / 深色 6%;静态轻阴影半径 4、纵偏移 1,不给文字或曲线单独加阴影。
|
- 卡片采用 PanelCard、面板采用 PanelBackground 的浅深色资源。边框为 primary 浅色 2.5% / 深色 6%;静态轻阴影半径 4、纵偏移 1,不给文字或曲线单独加阴影。
|
||||||
|
|
||||||
## 曲线与悬浮
|
## 曲线与悬浮
|
||||||
|
|
||||||
- 不显示常驻图例、数值坐标轴、网格、起止时间与独立图框。背景曲线线宽 1.4,填充为同色静态实色透明度:浅色 12%、深色 16%;不使用渐变层、遮罩层或动画层。
|
- 不显示常驻图例、数值坐标轴、网格、起止时间与独立图框。背景曲线线宽 1.4,填充为同色静态实色透明度:浅色 12%、深色 16%;不使用渐变层或遮罩层,连续追加时仅移动已有曲线图层。
|
||||||
- CPU 自下而上堆叠系统态 / 用户态;内存堆叠应用 / 联动 / 压缩,顶边为物理总量、空余为可用空间;GPU 堆叠占用 / 空闲至 100%,Renderer / Tiler 仅保留原始提示读数,不叠加为总占用。电池背景显示电量,功率在悬浮中单独注明 W,不能与电量共用未解释的尺度。存储和网络采用上下双向曲线:自顶向下 60% 为零轴(细线),向上读取 / 上传、向下写入 / 下载,两侧各有卡片高度 30% 的振幅,共用自动速率尺度,峰值不触及卡片顶边。
|
- CPU 自下而上堆叠系统态 / 用户态;内存堆叠应用 / 联动 / 压缩,顶边为物理总量、空余为可用空间;GPU 总利用率、Renderer、Tiler 共用百分比轴但各自绘制,只有总利用率填充面积。电池背景显示电量,功率在悬浮中单独注明 W,不能与电量共用未解释的尺度。存储和网络采用上下双向曲线:自顶向下 60% 为零轴(细线),向上读取 / 上传、向下写入 / 下载,两侧各有绘图区高度 30% 的振幅,共用自动速率尺度,峰值不触及卡片顶边。
|
||||||
- 百分比固定 0–100%;内存固定当前物理总量;速率保留既有自动范围及延迟缩小策略,不为视觉任意改变振幅。
|
- 百分比固定 0–100%;内存固定当前物理总量;速率保留既有自动范围及延迟缩小策略,不为视觉任意改变振幅。
|
||||||
- 时间使用真实采样日期;有效 0 保留,nil / 非有限数值不补值。沿用既有缺失节点接续与显式断点 / 长空档策略。堆叠缺少任一必要分量时不构造部分总量;面积在匹配上下边界之间按每个连续段分别闭合,不能填过暂停空档。
|
- 时间使用真实采样日期;有效 0 保留,nil / 非有限数值不补值。沿用既有缺失节点接续与显式断点 / 长空档策略。堆叠缺少任一必要分量时不构造部分总量;面积在匹配上下边界之间按每个连续段分别闭合,不能填过暂停空档。
|
||||||
- 单点历史仅显示真实点,不绘制虚构面积。全缺失无曲线和填充。
|
- 单点历史仅显示真实点,不绘制虚构面积。全缺失无曲线和填充。
|
||||||
- 悬浮响应全卡背景中未被交互控件占用的区域:按最近采样时间显示时间、各序列名称与数值;仅为有效可见序列绘制定位点,堆叠标记位于累计边界,缺失显示 --。主数值保持最新值。
|
- 悬浮响应对应卡片的绘图区:按最近采样时间显示时间、各序列名称与数值;仅为有效可见序列绘制定位点,堆叠标记位于累计边界,缺失显示 --。主数值保持最新值。
|
||||||
- 定位线和提示仅随指针更新,不重建曲线 / 面积几何。提示保持在卡片内,不遮挡标题、主值及主要按钮,不拦截鼠标事件;离开绘图区清除。
|
- 定位线和提示仅随指针更新,不重建曲线 / 面积几何。提示保持在卡片内,不遮挡标题、主值及主要按钮,不拦截鼠标事件;离开绘图区清除。
|
||||||
|
|
||||||
## 各卡片信息契约
|
## 各卡片信息契约
|
||||||
|
|
||||||
| 卡片 | 必须保留的前景与入口 |
|
| 卡片 | 必须保留的前景与入口 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| CPU | 总占用、温度 / 高温状态、左对齐用户 / 系统;核型横向分组、每核独立方块竖柱,数值通过悬浮和辅助功能提供;禁止把核数画成亮灯计数 |
|
| CPU | 总占用、温度 / 高温状态、左对齐用户 / 系统;核型横向分组、每核独立单元,数值通过悬浮和辅助功能提供;禁止把核数画成亮灯计数 |
|
||||||
| GPU | 总占用、温度;主值下一行核心数,再显示旋转风扇图标与转速或等待状态;Renderer / Tiler 保留在历史提示 |
|
| GPU | 总占用、温度,GPU 标题后紧跟实际核心数胶囊,带曲线色标的渲染器 / 分块器读数、旋转风扇图标与转速或等待状态 |
|
||||||
| 内存 | 已用 / 总量 GiB、压力标签;应用 / 联动 / 压缩单行及可用量,移除重复容量条;占用率、缓存和 Swap 保留在压力提示中 |
|
| 内存 | 已用 / 总量 GiB、压力标签;应用 / 联动 / 压缩单行及可用量,移除重复容量条;占用率、缓存和 Swap 保留在压力提示中 |
|
||||||
| 电池 | 电量;电源在标题右侧;功率、健康 / 循环、估时依次左对齐;保留无电池、失败和不适用状态 |
|
| 电池 | 电量;电源在标题右侧;功率、健康 / 循环、估时依次左对齐;确认无内置电池时切换为整机即时 W 与独立趋势;传感器缺失显示不可用,电池读取失败不触发切换 |
|
||||||
| 存储 | 已用 / 总量 GB;本地卷入口在标题右侧;可用、读写、寿命 / 通电依次左对齐;保留卷弹出层与口径说明 |
|
| 存储 | 已用 / 总量 GB;本地卷入口在标题右侧;可用、读写、寿命 / 通电依次左对齐;保留卷弹出层与口径说明 |
|
||||||
| 网络 | 黑白主数值与着色方向箭头;单行累计收发;标题右侧接口与路径状态;两行公网 / 本地 IP 及全文提示 / 选择 / 复制 |
|
| 网络 | 黑白主数值与着色方向箭头;单行累计收发;标题右侧接口与路径状态;两行公网 / 本地 IP 及全文提示 / 选择 / 复制 |
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
## 风扇动效
|
## 风扇动效
|
||||||
|
|
||||||
风扇宿主图层不旋转,SF Symbol 独立子图层以图标区域中心为固定转轴;仅图标使用原生循环旋转:正值 <2000 RPM 为 90°/s,<4000 为 180°/s,<6000 为 300°/s,更高为 450°/s;这是沿用的视觉映射,不是物理 RPM。切档保持角度连续。零 / 缺失 / 无效值、暂停、隐藏 / 遮挡、睡眠、卸载及系统减弱动态效果时停转;数值、图表和进度条不增加动画。
|
风扇宿主图层不旋转,SF Symbol 独立子图层以图标区域中心为固定转轴;仅图标使用原生循环旋转:正值 <2000 RPM 为 90°/s,<4000 为 180°/s,<6000 为 300°/s,更高为 450°/s;这是沿用的视觉映射,不是物理 RPM。切档保持角度连续。零 / 缺失 / 无效值、暂停、隐藏 / 遮挡、睡眠、卸载及系统减弱动态效果时停转;曲线随新采样短暂平移,数字和进度条直接更新。
|
||||||
|
|
||||||
## 性能与验收
|
## 性能与验收
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ nonisolated enum SamplingDiagnostics {
|
|||||||
payload["cores"] = snapshot.cpu?.cores.count
|
payload["cores"] = snapshot.cpu?.cores.count
|
||||||
payload["cpuTemperature"] = snapshot.cpuTemperature
|
payload["cpuTemperature"] = snapshot.cpuTemperature
|
||||||
payload["gpuUsage"] = snapshot.gpuUsage
|
payload["gpuUsage"] = snapshot.gpuUsage
|
||||||
|
payload["gpuRenderer"] = snapshot.gpu?.renderer
|
||||||
|
payload["gpuTiler"] = snapshot.gpu?.tiler
|
||||||
payload["gpuCoreCount"] = snapshot.gpu?.coreCount
|
payload["gpuCoreCount"] = snapshot.gpu?.coreCount
|
||||||
payload["processEnumerated"] = snapshot.processes?.enumerated
|
payload["processEnumerated"] = snapshot.processes?.enumerated
|
||||||
payload["processReadable"] = snapshot.processes?.readable
|
payload["processReadable"] = snapshot.processes?.readable
|
||||||
@@ -50,6 +52,7 @@ nonisolated enum SamplingDiagnostics {
|
|||||||
payload["volumeCount"] = snapshot.volumes?.count
|
payload["volumeCount"] = snapshot.volumes?.count
|
||||||
payload["batteryCycles"] = snapshot.battery?.cycles
|
payload["batteryCycles"] = snapshot.battery?.cycles
|
||||||
payload["batteryHealth"] = snapshot.battery?.health
|
payload["batteryHealth"] = snapshot.battery?.health
|
||||||
|
payload["systemPower"] = snapshot.systemPower
|
||||||
payload["batteryPower"] = snapshot.battery?.power
|
payload["batteryPower"] = snapshot.battery?.power
|
||||||
var info = task_vm_info_data_t()
|
var info = task_vm_info_data_t()
|
||||||
var count = mach_msg_type_number_t(MemoryLayout<task_vm_info_data_t>.size / MemoryLayout<integer_t>.size)
|
var count = mach_msg_type_number_t(MemoryLayout<task_vm_info_data_t>.size / MemoryLayout<integer_t>.size)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
/// Core-kind columns contain one vertical segmented meter per real core.
|
/// Core-kind columns contain one continuously filled cell per real core.
|
||||||
struct CPUCoreGrid: View {
|
struct CPUCoreGrid: View {
|
||||||
let values: [Double]
|
let values: [Double]
|
||||||
let kinds: [Int: CPUCoreTopology.Kind]
|
let kinds: [Int: CPUCoreTopology.Kind]
|
||||||
@@ -85,8 +85,13 @@ struct CPUCoreGrid: View {
|
|||||||
private func core(index: Int) -> some View {
|
private func core(index: Int) -> some View {
|
||||||
let kind = kinds[index]
|
let kind = kinds[index]
|
||||||
let measured = values[index].isFinite ? values[index] : nil
|
let measured = values[index].isFinite ? values[index] : nil
|
||||||
return SegmentedCoreBar(value: measured, color: color(kind))
|
return RoundedRectangle(cornerRadius: 2)
|
||||||
.frame(height: 30)
|
.fill(color(kind).opacity(0.22))
|
||||||
|
.overlay(alignment: .bottom) {
|
||||||
|
Rectangle().fill(color(kind)).frame(height: CPUCoreGridLayout.rowHeight * (measured.map { min(1, max(0, $0)) } ?? 0))
|
||||||
|
}
|
||||||
|
.clipShape(.rect(cornerRadius: 2))
|
||||||
|
.frame(height: CPUCoreGridLayout.rowHeight)
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
.help(Text("\(kind.map { label($0) } ?? Text("cpu.core")) · \(index + 1): \(MetricFormat.percent(measured))"))
|
.help(Text("\(kind.map { label($0) } ?? Text("cpu.core")) · \(index + 1): \(MetricFormat.percent(measured))"))
|
||||||
.accessibilityElement(children: .ignore)
|
.accessibilityElement(children: .ignore)
|
||||||
@@ -98,8 +103,8 @@ struct CPUCoreGrid: View {
|
|||||||
struct CPUCoreGridLayout: Layout {
|
struct CPUCoreGridLayout: Layout {
|
||||||
static let columnSpacing: CGFloat = 3
|
static let columnSpacing: CGFloat = 3
|
||||||
static let rowSpacing: CGFloat = 4
|
static let rowSpacing: CGFloat = 4
|
||||||
static let rowHeight: CGFloat = 30
|
static let rowHeight: CGFloat = 11
|
||||||
static let minimumCellWidth: CGFloat = 6
|
static let minimumCellWidth: CGFloat = 7
|
||||||
|
|
||||||
static func rowCounts(count: Int, width: CGFloat) -> [Int] {
|
static func rowCounts(count: Int, width: CGFloat) -> [Int] {
|
||||||
guard count > 0 else { return [] }
|
guard count > 0 else { return [] }
|
||||||
|
|||||||
@@ -10,20 +10,6 @@ extension MenuPanelView {
|
|||||||
}.frame(height: 16)
|
}.frame(height: 16)
|
||||||
}
|
}
|
||||||
|
|
||||||
func inlineMetric(_ title: LocalizedStringKey, _ value: String) -> some View {
|
|
||||||
HStack(spacing: 4) {
|
|
||||||
Text(title).foregroundStyle(.secondary)
|
|
||||||
MetricText(value: value).fontWeight(.medium)
|
|
||||||
}
|
|
||||||
.font(.system(size: 10)).lineLimit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func batteryPowerLabel(_ battery: BatteryMetrics) -> LocalizedStringKey {
|
|
||||||
if battery.charging { return "battery.chargePower" }
|
|
||||||
if !battery.externalPower { return "battery.dischargePower" }
|
|
||||||
return "battery.power"
|
|
||||||
}
|
|
||||||
|
|
||||||
var cpuCard: some View {
|
var cpuCard: some View {
|
||||||
let temperature = snapshot.cpuTemperature
|
let temperature = snapshot.cpuTemperature
|
||||||
let highTemperature = CPUTemperatureMonitor.isHighTemperature(temperature)
|
let highTemperature = CPUTemperatureMonitor.isHighTemperature(temperature)
|
||||||
@@ -33,6 +19,7 @@ extension MenuPanelView {
|
|||||||
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,
|
||||||
|
chartPlacement: .background,
|
||||||
chart: {
|
chart: {
|
||||||
PanelTrendChart(
|
PanelTrendChart(
|
||||||
dates: samples.map(\.date), first: samples.map(\.cpu),
|
dates: samples.map(\.date), first: samples.map(\.cpu),
|
||||||
@@ -43,8 +30,8 @@ extension MenuPanelView {
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
HStack(spacing: 5) {
|
HStack(spacing: 5) {
|
||||||
inlineMetric("cpu.user", MetricFormat.percent(snapshot.cpu?.user))
|
InlineMetric("cpu.user", MetricFormat.percent(snapshot.cpu?.user))
|
||||||
inlineMetric("cpu.system", MetricFormat.percent(snapshot.cpu?.system))
|
InlineMetric("cpu.system", MetricFormat.percent(snapshot.cpu?.system))
|
||||||
}.frame(height: 16)
|
}.frame(height: 16)
|
||||||
if let cpu = snapshot.cpu {
|
if let cpu = snapshot.cpu {
|
||||||
CPUCoreGrid(
|
CPUCoreGrid(
|
||||||
@@ -60,24 +47,26 @@ extension MenuPanelView {
|
|||||||
var gpuCard: some View {
|
var gpuCard: some View {
|
||||||
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),
|
||||||
|
titleBadge: snapshot.gpu?.coreCount.map {
|
||||||
|
String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), $0)
|
||||||
|
},
|
||||||
status: snapshot.gpuTemperature.map { "\(Int($0.rounded()))°C" },
|
status: snapshot.gpuTemperature.map { "\(Int($0.rounded()))°C" },
|
||||||
|
chartPlacement: .background,
|
||||||
chart: {
|
chart: {
|
||||||
PanelTrendChart(
|
PanelTrendChart(
|
||||||
dates: samples.map(\.date), first: samples.map(\.gpu),
|
dates: samples.map(\.date), first: samples.map(\.gpu),
|
||||||
second: samples.map { $0.gpu.map { max(0, 1 - $0) } },
|
second: samples.map(\.gpuRenderer), third: samples.map(\.gpuTiler),
|
||||||
third: samples.map(\.gpuRenderer), fourth: samples.map(\.gpuTiler),
|
color: Color("MetricGPU"), secondColor: Color("MetricCPU"), thirdColor: Color("SeriesSystem"),
|
||||||
color: Color("MetricGPU"), secondColor: Color("MemoryAvailable"),
|
firstLabel: "gpu.totalUtilization",
|
||||||
thirdColor: Color("MetricCPU"), fourthColor: Color("SeriesSystem"),
|
secondLabel: "gpu.renderer", thirdLabel: "gpu.tiler",
|
||||||
firstLabel: "gpu.totalUtilization", secondLabel: "gpu.idle", thirdLabel: "gpu.renderer", fourthLabel: "gpu.tiler",
|
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals,
|
||||||
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals, stackOrder: [0, 1])
|
visibleSeriesCount: 3, filledSeriesCount: 1)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
HStack(spacing: 5) {
|
HStack(spacing: 8) {
|
||||||
if let count = snapshot.gpu?.coreCount {
|
gpuStage("gpu.renderer", snapshot.gpu?.renderer, Color("MetricCPU"))
|
||||||
Text(verbatim: String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), count))
|
gpuStage("gpu.tiler", snapshot.gpu?.tiler, Color("SeriesSystem"))
|
||||||
.foregroundStyle(.primary)
|
}.frame(height: 16)
|
||||||
}
|
|
||||||
}.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9).frame(height: 16)
|
|
||||||
let fans = displayedFans
|
let fans = displayedFans
|
||||||
if !fans.isEmpty {
|
if !fans.isEmpty {
|
||||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 5, alignment: .leading), count: min(2, fans.count)), spacing: 2) {
|
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 5, alignment: .leading), count: min(2, fans.count)), spacing: 2) {
|
||||||
@@ -97,6 +86,13 @@ extension MenuPanelView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func gpuStage(_ title: LocalizedStringKey, _ usage: Double?, _ tint: Color) -> some View {
|
||||||
|
HStack(spacing: 3) {
|
||||||
|
Circle().fill(tint).frame(width: 4, height: 4)
|
||||||
|
InlineMetric(title, MetricFormat.percent(usage))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var memoryCard: some View {
|
var memoryCard: some View {
|
||||||
let header = MemoryHeaderInfo(memory: snapshot.memory, locale: locale)
|
let header = MemoryHeaderInfo(memory: snapshot.memory, locale: locale)
|
||||||
return ResourceCard(
|
return ResourceCard(
|
||||||
@@ -106,6 +102,7 @@ extension MenuPanelView {
|
|||||||
} ?? "--",
|
} ?? "--",
|
||||||
detail: header.badgeTitle, detailColor: snapshot.memory?.pressure == 1 ? Color("MetricBattery") : header.color,
|
detail: header.badgeTitle, detailColor: snapshot.memory?.pressure == 1 ? Color("MetricBattery") : header.color,
|
||||||
detailHelp: header.help + "\n" + MetricFormat.percent(snapshot.memory?.usage),
|
detailHelp: header.help + "\n" + MetricFormat.percent(snapshot.memory?.usage),
|
||||||
|
chartPlacement: .background,
|
||||||
chart: {
|
chart: {
|
||||||
PanelTrendChart(
|
PanelTrendChart(
|
||||||
dates: samples.map(\.date),
|
dates: samples.map(\.date),
|
||||||
@@ -168,55 +165,7 @@ extension MenuPanelView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var batteryCard: some View {
|
var batteryCard: some View {
|
||||||
ResourceCard(
|
PowerResourceCard(snapshot: snapshot, samples: samples, chartInterval: chartInterval,
|
||||||
title: "metric.battery", symbol: "battery.100percent", color: Color("MetricBattery"),
|
chartBoundaries: chartBoundaries, chartIntervals: chartIntervals)
|
||||||
value: MetricFormat.percent(snapshot.battery?.charge),
|
|
||||||
status: snapshot.battery.map { AppLocalization.string($0.externalPower ? "battery.acPower" : "battery.batterySource", locale: locale) },
|
|
||||||
chart: {
|
|
||||||
PanelTrendChart(
|
|
||||||
dates: samples.map(\.date),
|
|
||||||
first: samples.map(\.battery),
|
|
||||||
second: samples.map(\.batteryPower),
|
|
||||||
color: Color("MetricBattery"),
|
|
||||||
secondColor: Color("SeriesUser"),
|
|
||||||
fixedScale: 1,
|
|
||||||
secondSeriesUsesAutonomousScale: true,
|
|
||||||
secondValueFormat: .watts,
|
|
||||||
firstLabel: "metric.battery",
|
|
||||||
secondLabel: snapshot.battery.map(batteryPowerLabel) ?? "battery.power",
|
|
||||||
expectedInterval: chartInterval,
|
|
||||||
boundaryDates: chartBoundaries,
|
|
||||||
intervals: chartIntervals
|
|
||||||
)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
inlineMetric("battery.powerShort", MetricFormat.watts(snapshot.battery?.power))
|
|
||||||
.frame(height: 16)
|
|
||||||
if let battery = snapshot.battery {
|
|
||||||
batteryDetails(battery)
|
|
||||||
} else {
|
|
||||||
Text(snapshot.batteryState == .absent ? "panel.noBattery" : "panel.batteryFailed").foregroundStyle(.secondary)
|
|
||||||
.font(.system(size: 10)).frame(maxWidth: .infinity).frame(height: 32)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private func batteryDetails(_ battery: BatteryMetrics) -> some View {
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
HStack(spacing: 8) {
|
|
||||||
inlineMetric("battery.healthShort", MetricFormat.percent(battery.health))
|
|
||||||
inlineMetric("battery.cyclesShort", battery.cycles.map(String.init) ?? "--")
|
|
||||||
}
|
|
||||||
HStack(spacing: 4) {
|
|
||||||
Text("battery.timeShort").foregroundStyle(.secondary)
|
|
||||||
if battery.externalPower {
|
|
||||||
Text("battery.notApplicableShort").help(Text("battery.timeNotApplicable"))
|
|
||||||
} else if let minutes = battery.minutesRemaining {
|
|
||||||
MetricText(value: "\(minutes) min")
|
|
||||||
} else {
|
|
||||||
Text("battery.timeUnknown")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ struct MenuPanelView: View {
|
|||||||
}
|
}
|
||||||
.background(Color("PanelBackground"), in: .rect(cornerRadius: 18))
|
.background(Color("PanelBackground"), in: .rect(cornerRadius: 18))
|
||||||
.clipShape(.rect(cornerRadius: 18))
|
.clipShape(.rect(cornerRadius: 18))
|
||||||
.transaction { $0.animation = nil; $0.disablesAnimations = true }
|
.transaction { $0.animation = nil }
|
||||||
|
.environment(\.panelMotionActive, metrics.isPanelVisible && !metrics.isPaused && !metrics.isSystemSleeping && !metrics.isDisplaySleeping)
|
||||||
.modifier(AppearanceStyle(preferences: preferences))
|
.modifier(AppearanceStyle(preferences: preferences))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,11 +128,23 @@ struct MenuPanelView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
|
||||||
|
|
||||||
private var brand: some View {
|
private var brand: some View {
|
||||||
HStack(spacing: 6) {
|
HStack(spacing: 6) {
|
||||||
Image("BrandMark").renderingMode(.template).resizable().scaledToFit()
|
Image("BrandMark").renderingMode(.template).resizable().scaledToFit()
|
||||||
.frame(width: 22, height: 22)
|
.frame(width: 22, height: 22)
|
||||||
|
HStack(alignment: .top, spacing: 3) {
|
||||||
Text("Kymo").font(.system(size: 17, weight: .semibold))
|
Text("Kymo").font(.system(size: 17, weight: .semibold))
|
||||||
|
if let version = Self.version {
|
||||||
|
Text(verbatim: "v" + version)
|
||||||
|
.font(.system(size: 9, weight: .semibold)).monospacedDigit()
|
||||||
|
.padding(.horizontal, 5).padding(.vertical, 1)
|
||||||
|
.background(.primary.opacity(0.09), in: Capsule())
|
||||||
|
.offset(y: -2)
|
||||||
|
.accessibilityLabel(Text("about.version \(version)"))
|
||||||
|
}
|
||||||
|
}.fixedSize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,18 +160,18 @@ struct MenuPanelView: View {
|
|||||||
|
|
||||||
private var footer: some View {
|
private var footer: some View {
|
||||||
HStack {
|
HStack {
|
||||||
Text(verbatim: HardwareIdentity.displayName)
|
|
||||||
.lineLimit(1).truncationMode(.middle)
|
|
||||||
.help(Text(verbatim: HardwareIdentity.displayName))
|
|
||||||
Spacer(minLength: 8)
|
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
Text("panel.uptime")
|
Text("panel.uptime")
|
||||||
MetricText(value: String(format: "%.1f h", snapshot.uptime / 3600))
|
MetricText(value: String(format: "%.1f h", snapshot.uptime / 3600))
|
||||||
}.fixedSize()
|
}.fixedSize()
|
||||||
Divider().frame(height: 14)
|
Divider().frame(height: 14)
|
||||||
|
Text(verbatim: HardwareIdentity.displayName)
|
||||||
|
.lineLimit(1).truncationMode(.middle)
|
||||||
|
.help(Text(verbatim: HardwareIdentity.displayName))
|
||||||
|
Spacer(minLength: 8)
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
Image(systemName: "timer").help(Text("sampling.panel"))
|
Image(systemName: "timer").help(Text("sampling.panel"))
|
||||||
IntervalControl(milliseconds: Binding(get: { metrics.sampling.panelMilliseconds }, set: { metrics.sampling.panelMilliseconds = $0 }))
|
IntervalControl(milliseconds: Binding(get: { metrics.sampling.panelMilliseconds }, set: { metrics.sampling.panelMilliseconds = $0 }), fieldWidth: 50)
|
||||||
}
|
}
|
||||||
.foregroundStyle(.primary)
|
.foregroundStyle(.primary)
|
||||||
.accessibilityLabel(Text("sampling.panel"))
|
.accessibilityLabel(Text("sampling.panel"))
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ nonisolated enum PanelLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structural foreground height determines the full-height background chart.
|
/// Structural foreground height determines the room available for the trend below the text.
|
||||||
static func cardHeights(coreRows: Int, fanCount: Int?) -> [PanelCard: CGFloat] {
|
static func cardHeights(coreRows: Int, fanCount: Int?) -> [PanelCard: CGFloat] {
|
||||||
let base = ResourceCardMetrics.minimumHeight
|
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: base + CGFloat(max(0, coreRows - 1)) * 34,
|
return [.cpu: base + CGFloat(max(0, coreRows - 1)) * 15,
|
||||||
.gpu: base + CGFloat(max(0, fanRows - 1)) * 14,
|
.gpu: base + CGFloat(max(0, fanRows - 1)) * 18,
|
||||||
.memory: base, .battery: base, .storage: base, .network: base]
|
.memory: base, .battery: base, .storage: base, .network: base]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct PowerResourceCard: View {
|
||||||
|
let snapshot: MetricsSnapshot
|
||||||
|
let samples: [TrendSample]
|
||||||
|
let chartInterval: TimeInterval
|
||||||
|
let chartBoundaries: Set<Date>
|
||||||
|
let chartIntervals: [TimeInterval]
|
||||||
|
@Environment(\.locale) private var locale
|
||||||
|
|
||||||
|
private func batteryPowerLabel(_ battery: BatteryMetrics) -> LocalizedStringKey {
|
||||||
|
if battery.charging { return "battery.chargePower" }
|
||||||
|
if !battery.externalPower { return "battery.dischargePower" }
|
||||||
|
return "battery.power"
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewBuilder var body: some View {
|
||||||
|
if snapshot.batteryState == .absent {
|
||||||
|
ResourceCard(title: "power.system", symbol: "bolt.fill", color: Color("MetricBattery"),
|
||||||
|
value: MetricFormat.watts(snapshot.systemPower), chart: {
|
||||||
|
PanelTrendChart(dates: samples.map(\.date), first: samples.map(\.systemPower),
|
||||||
|
color: Color("MetricBattery"), fixedScale: nil, firstValueFormat: .watts,
|
||||||
|
firstLabel: "power.system", expectedInterval: chartInterval,
|
||||||
|
boundaryDates: chartBoundaries, intervals: chartIntervals)
|
||||||
|
}) {
|
||||||
|
Text(snapshot.systemPower == nil ? "power.sensorUnavailable" : "panel.noBattery")
|
||||||
|
.font(.system(size: 10)).foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
batteryChargeCard
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var batteryChargeCard: some View {
|
||||||
|
ResourceCard(
|
||||||
|
title: "metric.battery", symbol: "battery.100percent", color: Color("MetricBattery"),
|
||||||
|
value: MetricFormat.percent(snapshot.battery?.charge),
|
||||||
|
status: snapshot.battery.map { AppLocalization.string($0.externalPower ? "battery.acPower" : "battery.batterySource", locale: locale) },
|
||||||
|
chartPlacement: .background,
|
||||||
|
chart: {
|
||||||
|
PanelTrendChart(
|
||||||
|
dates: samples.map(\.date),
|
||||||
|
first: samples.map(\.battery),
|
||||||
|
second: samples.map(\.batteryPower),
|
||||||
|
color: Color("MetricBattery"),
|
||||||
|
secondColor: Color("SeriesUser"),
|
||||||
|
fixedScale: 1,
|
||||||
|
secondSeriesUsesAutonomousScale: true,
|
||||||
|
secondValueFormat: .watts,
|
||||||
|
firstLabel: "metric.battery",
|
||||||
|
secondLabel: snapshot.battery.map(batteryPowerLabel) ?? "battery.power",
|
||||||
|
expectedInterval: chartInterval,
|
||||||
|
boundaryDates: chartBoundaries,
|
||||||
|
intervals: chartIntervals
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
InlineMetric("battery.powerShort", MetricFormat.watts(snapshot.battery?.power))
|
||||||
|
.frame(height: 16)
|
||||||
|
if let battery = snapshot.battery {
|
||||||
|
batteryDetails(battery)
|
||||||
|
} else {
|
||||||
|
Text(snapshot.batteryState == .unknown ? "metric.waiting" : "panel.batteryFailed").foregroundStyle(.secondary)
|
||||||
|
.font(.system(size: 10)).frame(maxWidth: .infinity).frame(height: 32)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private func batteryDetails(_ battery: BatteryMetrics) -> some View {
|
||||||
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
|
HStack(spacing: 8) {
|
||||||
|
InlineMetric("battery.healthShort", MetricFormat.percent(battery.health))
|
||||||
|
InlineMetric("battery.cyclesShort", battery.cycles.map(String.init) ?? "--")
|
||||||
|
}
|
||||||
|
HStack(spacing: 4) {
|
||||||
|
Text("battery.timeShort").foregroundStyle(.secondary)
|
||||||
|
if battery.externalPower {
|
||||||
|
Text("battery.notApplicableShort").help(Text("battery.timeNotApplicable"))
|
||||||
|
} else if let minutes = battery.minutesRemaining {
|
||||||
|
MetricText(value: "\(minutes) min")
|
||||||
|
} else {
|
||||||
|
Text("battery.timeUnknown")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,11 +6,11 @@ struct StorageDetailsView: View {
|
|||||||
let io: DiskIOMetrics?
|
let io: DiskIOMetrics?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 3) {
|
||||||
field("memory.available", value: MetricFormat.bytes(disk?.available))
|
field("memory.available", value: MetricFormat.bytes(disk?.available))
|
||||||
ViewThatFits(in: .horizontal) {
|
ViewThatFits(in: .horizontal) {
|
||||||
HStack(spacing: 6) { read; write }.fixedSize(horizontal: true, vertical: true)
|
HStack(spacing: 6) { read; write }.fixedSize(horizontal: true, vertical: true)
|
||||||
VStack(alignment: .leading, spacing: 4) { read; write }
|
VStack(alignment: .leading, spacing: 3) { read; write }
|
||||||
}
|
}
|
||||||
ViewThatFits(in: .horizontal) {
|
ViewThatFits(in: .horizontal) {
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
@@ -18,7 +18,7 @@ struct StorageDetailsView: View {
|
|||||||
Text("·").foregroundStyle(.secondary)
|
Text("·").foregroundStyle(.secondary)
|
||||||
powerOn
|
powerOn
|
||||||
}.fixedSize(horizontal: true, vertical: true)
|
}.fixedSize(horizontal: true, vertical: true)
|
||||||
VStack(alignment: .leading, spacing: 4) { life; powerOn }
|
VStack(alignment: .leading, spacing: 3) { life; powerOn }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.font(.system(size: 10)).lineLimit(1)
|
.font(.system(size: 10)).lineLimit(1)
|
||||||
@@ -33,6 +33,6 @@ struct StorageDetailsView: View {
|
|||||||
HStack(spacing: 3) {
|
HStack(spacing: 3) {
|
||||||
Text(title).foregroundStyle(.secondary).help(Text(title))
|
Text(title).foregroundStyle(.secondary).help(Text(title))
|
||||||
MetricText(value: value).fontWeight(.medium).foregroundStyle(.primary)
|
MetricText(value: value).fontWeight(.medium).foregroundStyle(.primary)
|
||||||
}.frame(height: 16)
|
}.frame(height: 14)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,50 @@
|
|||||||
{
|
{
|
||||||
"sourceLanguage" : "en",
|
"sourceLanguage" : "en",
|
||||||
"strings" : {
|
"strings" : {
|
||||||
|
"power.system": {
|
||||||
|
"localizations": {
|
||||||
|
"en": {
|
||||||
|
"stringUnit": {
|
||||||
|
"state": "translated",
|
||||||
|
"value": "System power"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hans": {
|
||||||
|
"stringUnit": {
|
||||||
|
"state": "translated",
|
||||||
|
"value": "整机功率"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hant": {
|
||||||
|
"stringUnit": {
|
||||||
|
"state": "translated",
|
||||||
|
"value": "整機功率"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"power.sensorUnavailable": {
|
||||||
|
"localizations": {
|
||||||
|
"en": {
|
||||||
|
"stringUnit": {
|
||||||
|
"state": "translated",
|
||||||
|
"value": "Power sensor unavailable"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hans": {
|
||||||
|
"stringUnit": {
|
||||||
|
"state": "translated",
|
||||||
|
"value": "功率传感器不可用"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hant": {
|
||||||
|
"stringUnit": {
|
||||||
|
"state": "translated",
|
||||||
|
"value": "功率感測器無法使用"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"memory.distributionHelp" : {
|
"memory.distributionHelp" : {
|
||||||
"localizations": {
|
"localizations": {
|
||||||
"en": {
|
"en": {
|
||||||
@@ -23,28 +67,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"gpu.idle" : {
|
|
||||||
"localizations": {
|
|
||||||
"en": {
|
|
||||||
"stringUnit": {
|
|
||||||
"state": "translated",
|
|
||||||
"value": "Idle"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zh-Hans": {
|
|
||||||
"stringUnit": {
|
|
||||||
"state": "translated",
|
|
||||||
"value": "空闲"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zh-Hant": {
|
|
||||||
"stringUnit": {
|
|
||||||
"state": "translated",
|
|
||||||
"value": "閒置"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"disk.lifeShort" : {
|
"disk.lifeShort" : {
|
||||||
"localizations": {
|
"localizations": {
|
||||||
"en": {
|
"en": {
|
||||||
@@ -2953,19 +2975,19 @@
|
|||||||
"en" : {
|
"en" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
"state" : "translated",
|
"state" : "translated",
|
||||||
"value" : "Uptime"
|
"value" : "System uptime"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"zh-Hans" : {
|
"zh-Hans" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
"state" : "translated",
|
"state" : "translated",
|
||||||
"value" : "运行时间"
|
"value" : "开机时间"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"zh-Hant" : {
|
"zh-Hant" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
"state" : "translated",
|
"state" : "translated",
|
||||||
"value" : "執行時間"
|
"value" : "開機時間"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ nonisolated enum PanelCurveProjection: Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bounded static lines and per-run area paths. Hover never rebuilds geometry.
|
/// Bounded 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]
|
||||||
@@ -26,6 +26,7 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
var filledSeriesCount = 1
|
var filledSeriesCount = 1
|
||||||
var stacked = false
|
var stacked = false
|
||||||
var projection: PanelCurveProjection = .fullHeight
|
var projection: PanelCurveProjection = .fullHeight
|
||||||
|
var animates = false
|
||||||
|
|
||||||
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,
|
||||||
@@ -34,7 +35,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, visibleSeriesCount: visibleSeriesCount, filledSeriesCount: filledSeriesCount, stacked: stacked, projection: projection))
|
hoveredIndex: hoveredIndex, visibleSeriesCount: visibleSeriesCount, filledSeriesCount: filledSeriesCount, stacked: stacked, projection: projection, animates: animates))
|
||||||
}
|
}
|
||||||
struct Input: Equatable {
|
struct Input: Equatable {
|
||||||
let frame: PanelCurveFrame
|
let frame: PanelCurveFrame
|
||||||
@@ -46,6 +47,7 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
var filledSeriesCount = 1
|
var filledSeriesCount = 1
|
||||||
var stacked = false
|
var stacked = false
|
||||||
var projection: PanelCurveProjection = .fullHeight
|
var projection: PanelCurveProjection = .fullHeight
|
||||||
|
var animates = false
|
||||||
}
|
}
|
||||||
final class PlotView: NSView {
|
final class PlotView: NSView {
|
||||||
private(set) var input: Input?
|
private(set) var input: Input?
|
||||||
@@ -57,6 +59,8 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
private var hoverDots: [CAShapeLayer] = []
|
private var hoverDots: [CAShapeLayer] = []
|
||||||
private var seriesLayers: [SeriesLayer] = []
|
private var seriesLayers: [SeriesLayer] = []
|
||||||
private var palette: [NSColor] = []
|
private var palette: [NSColor] = []
|
||||||
|
private var drawingFrame: PanelCurveFrame?
|
||||||
|
private static let slideKey = "trend.slide"
|
||||||
private var plottedBands: [StackedSeries.Band] = []
|
private var plottedBands: [StackedSeries.Band] = []
|
||||||
override var isFlipped: Bool { true }
|
override var isFlipped: Bool { true }
|
||||||
override func hitTest(_ point: NSPoint) -> NSView? { nil }
|
override func hitTest(_ point: NSPoint) -> NSView? { nil }
|
||||||
@@ -79,7 +83,15 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
guard input != value else { return }
|
guard input != value else { return }
|
||||||
let old = input
|
let old = input
|
||||||
let frameChanged = old?.frame != value.frame
|
let frameChanged = old?.frame != value.frame
|
||||||
|
let slides = value.animates && value.hoveredIndex == nil && window?.isVisible == true
|
||||||
|
&& frameChanged && old.map { value.frame.follows($0.frame, maximumGap: value.maximumGap) } == true
|
||||||
input = value
|
input = value
|
||||||
|
if frameChanged || !value.animates || value.hoveredIndex != nil {
|
||||||
|
curves.removeAnimation(forKey: Self.slideKey)
|
||||||
|
}
|
||||||
|
if frameChanged {
|
||||||
|
drawingFrame = slides ? old.map { value.frame.includingOutgoing(from: $0.frame) } : nil
|
||||||
|
}
|
||||||
CATransaction.begin(); CATransaction.setDisableActions(true)
|
CATransaction.begin(); CATransaction.setDisableActions(true)
|
||||||
if old?.projection != value.projection { updateBaseline() }
|
if old?.projection != value.projection { updateBaseline() }
|
||||||
curves.isHidden = value.colors.isEmpty || value.scales.isEmpty
|
curves.isHidden = value.colors.isEmpty || value.scales.isEmpty
|
||||||
@@ -93,8 +105,24 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
rebuildPaths()
|
rebuildPaths()
|
||||||
}
|
}
|
||||||
updateHover()
|
updateHover()
|
||||||
|
if slides, let old { slide(from: old.frame, to: value.frame) }
|
||||||
CATransaction.commit()
|
CATransaction.commit()
|
||||||
}
|
}
|
||||||
|
private func slide(from previous: PanelCurveFrame, to next: PanelCurveFrame) {
|
||||||
|
guard bounds.width > 0, let a = previous.dates.first, let b = previous.dates.last,
|
||||||
|
let c = next.dates.first, let d = next.dates.last else { return }
|
||||||
|
// Map the new geometry onto the old time domain, then reveal the new point.
|
||||||
|
let span = b.timeIntervalSince(a)
|
||||||
|
let transform = CGAffineTransform(a: d.timeIntervalSince(c) / span, b: 0, c: 0, d: 1,
|
||||||
|
tx: c.timeIntervalSince(a) / span * bounds.width, ty: 0)
|
||||||
|
let animation = CABasicAnimation(keyPath: "transform")
|
||||||
|
animation.fromValue = NSValue(caTransform3D: CATransform3DMakeAffineTransform(transform))
|
||||||
|
animation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
|
||||||
|
animation.duration = 0.35
|
||||||
|
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
|
||||||
|
curves.add(animation, forKey: Self.slideKey)
|
||||||
|
}
|
||||||
|
|
||||||
private func ensureLayers(_ count: Int) {
|
private func ensureLayers(_ count: Int) {
|
||||||
while seriesLayers.count < count {
|
while seriesLayers.count < count {
|
||||||
let series = SeriesLayer(); seriesLayers.append(series); curves.addSublayer(series.root)
|
let series = SeriesLayer(); seriesLayers.append(series); curves.addSublayer(series.root)
|
||||||
@@ -153,7 +181,7 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let domain = PanelCurveFrame.domain(begin: first, end: last)
|
let domain = PanelCurveFrame.domain(begin: first, end: last)
|
||||||
let frame = input.frame
|
let frame = drawingFrame ?? input.frame
|
||||||
plottedBands = input.stacked ? StackedSeries.bands(frame.series, count: frame.dates.count, limit: input.scales.first) : []
|
plottedBands = input.stacked ? StackedSeries.bands(frame.series, count: frame.dates.count, limit: input.scales.first) : []
|
||||||
for index in frame.series.indices {
|
for index in frame.series.indices {
|
||||||
let series = seriesLayers[index]
|
let series = seriesLayers[index]
|
||||||
@@ -205,7 +233,8 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
for series in input.frame.series.indices {
|
for series in input.frame.series.indices {
|
||||||
guard series < (input.visibleSeriesCount ?? input.frame.series.count) else { continue }
|
guard series < (input.visibleSeriesCount ?? input.frame.series.count) else { continue }
|
||||||
let values = input.stacked && plottedBands.indices.contains(series) ? plottedBands[series].upper : input.frame.series[series]
|
let values = input.stacked && plottedBands.indices.contains(series) ? plottedBands[series].upper : input.frame.series[series]
|
||||||
guard values.indices.contains(index), let value = values[index], value.isFinite else { continue }
|
let plottedIndex = index + (input.stacked ? (drawingFrame?.dates.count ?? input.frame.dates.count) - input.frame.dates.count : 0)
|
||||||
|
guard values.indices.contains(plottedIndex), let value = values[plottedIndex], value.isFinite else { continue }
|
||||||
let scale = input.scales[input.stacked ? 0 : min(series, input.scales.count - 1)]
|
let scale = input.scales[input.stacked ? 0 : min(series, input.scales.count - 1)]
|
||||||
let y = input.projection.y(value: value, scale: scale, series: series, height: bounds.height)
|
let y = input.projection.y(value: value, scale: scale, series: series, height: bounds.height)
|
||||||
hoverDots[series].path = CGPath(ellipseIn: CGRect(x: x - 2.5, y: y - 2.5, width: 5, height: 5), transform: nil)
|
hoverDots[series].path = CGPath(ellipseIn: CGRect(x: x - 2.5, y: y - 2.5, width: 5, height: 5), transform: nil)
|
||||||
@@ -215,12 +244,14 @@ struct NativePanelCurve: NSViewRepresentable {
|
|||||||
let changed = frame.size != size
|
let changed = frame.size != size
|
||||||
super.setFrameSize(size)
|
super.setFrameSize(size)
|
||||||
if changed {
|
if changed {
|
||||||
|
curves.removeAnimation(forKey: Self.slideKey)
|
||||||
CATransaction.begin(); CATransaction.setDisableActions(true)
|
CATransaction.begin(); CATransaction.setDisableActions(true)
|
||||||
updateGrid(); rebuildPaths(); updateHover(); CATransaction.commit()
|
updateGrid(); rebuildPaths(); updateHover(); CATransaction.commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override func viewDidMoveToWindow() {
|
override func viewDidMoveToWindow() {
|
||||||
super.viewDidMoveToWindow()
|
super.viewDidMoveToWindow()
|
||||||
|
if window == nil { curves.removeAnimation(forKey: Self.slideKey) }
|
||||||
CATransaction.begin(); CATransaction.setDisableActions(true)
|
CATransaction.begin(); CATransaction.setDisableActions(true)
|
||||||
updatePalette(); CATransaction.commit()
|
updatePalette(); CATransaction.commit()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,29 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// A static render frame follows the bounded sampling history without outgoing points.
|
/// History remains bounded; a rolling plot can draw one outgoing vertex beyond its left edge.
|
||||||
nonisolated struct PanelCurveFrame: Equatable {
|
nonisolated struct PanelCurveFrame: Equatable {
|
||||||
let dates: [Date]
|
let dates: [Date]
|
||||||
let series: [[Double?]]
|
let series: [[Double?]]
|
||||||
let intervals: [TimeInterval]
|
let intervals: [TimeInterval]
|
||||||
let boundaryDates: Set<Date>
|
let boundaryDates: Set<Date>
|
||||||
|
|
||||||
|
/// Only adjacent samples from the same timeline can slide into view.
|
||||||
|
func follows(_ old: Self, maximumGap: TimeInterval) -> Bool {
|
||||||
|
guard old.dates.count >= 2, let before = old.dates.last, let end = dates.last,
|
||||||
|
let begin = old.dates.first, begin < before, end > before, !boundaryDates.contains(end),
|
||||||
|
end.timeIntervalSince(before) <= PanelCurveGeometry.allowedGap(at: dates.count - 1, intervals: intervals, fallback: maximumGap)
|
||||||
|
else { return false }
|
||||||
|
return dates.dropLast().elementsEqual(old.dates)
|
||||||
|
|| (dates.count == old.dates.count && dates.dropLast().elementsEqual(old.dates.dropFirst()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func includingOutgoing(from old: Self) -> Self {
|
||||||
|
guard dates.first != old.dates.first, let outgoing = old.dates.first else { return self }
|
||||||
|
return Self(dates: [outgoing] + dates, series: series.enumerated().map { index, values in
|
||||||
|
[old.series.indices.contains(index) ? old.series[index].first ?? nil : nil] + values
|
||||||
|
}, intervals: [old.intervals.first ?? 2] + intervals, boundaryDates: boundaryDates)
|
||||||
|
}
|
||||||
|
|
||||||
struct Domain {
|
struct Domain {
|
||||||
let begin: TimeInterval
|
let begin: TimeInterval
|
||||||
let end: TimeInterval
|
let end: TimeInterval
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ enum TrendValueFormat {
|
|||||||
case watts
|
case watts
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Static curves skip missing vertices, retaining timestamps and explicit sampling breaks.
|
/// Curves skip missing vertices, retaining timestamps and explicit sampling breaks.
|
||||||
struct PanelTrendChart: View {
|
struct PanelTrendChart: View {
|
||||||
let dates: [Date]
|
let dates: [Date]
|
||||||
let first: [Double?]
|
let first: [Double?]
|
||||||
@@ -31,8 +31,11 @@ struct PanelTrendChart: View {
|
|||||||
var boundaryDates: Set<Date> = []
|
var boundaryDates: Set<Date> = []
|
||||||
var intervals: [TimeInterval] = []
|
var intervals: [TimeInterval] = []
|
||||||
var visibleSeriesCount = 1
|
var visibleSeriesCount = 1
|
||||||
|
var filledSeriesCount: Int? = nil
|
||||||
var stackOrder: [Int] = []
|
var stackOrder: [Int] = []
|
||||||
var projection: PanelCurveProjection = .fullHeight
|
var projection: PanelCurveProjection = .fullHeight
|
||||||
|
@Environment(\.panelMotionActive) private var active
|
||||||
|
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
||||||
@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
|
||||||
@@ -115,7 +118,8 @@ struct PanelTrendChart: View {
|
|||||||
scales: [scale, hasSecondaryScale ? secondaryScale : scale, 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: stackOrder.isEmpty ? visibleSeriesCount : stackOrder.count,
|
visibleSeriesCount: stackOrder.isEmpty ? visibleSeriesCount : stackOrder.count,
|
||||||
filledSeriesCount: stackOrder.isEmpty ? visibleSeriesCount : stackOrder.count, stacked: !stackOrder.isEmpty, projection: projection)
|
filledSeriesCount: stackOrder.isEmpty ? (filledSeriesCount ?? visibleSeriesCount) : stackOrder.count, stacked: !stackOrder.isEmpty, projection: projection,
|
||||||
|
animates: active && !reduceMotion)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.onContinuousHover { phase in
|
.onContinuousHover { phase in
|
||||||
switch phase {
|
switch phase {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ struct IntervalControl: View {
|
|||||||
@Binding var milliseconds: Int
|
@Binding var milliseconds: Int
|
||||||
var range: ClosedRange<Int> = 500...1_800_000
|
var range: ClosedRange<Int> = 500...1_800_000
|
||||||
var step = 100
|
var step = 100
|
||||||
|
var fieldWidth: CGFloat = 64
|
||||||
@State private var text = ""
|
@State private var text = ""
|
||||||
@FocusState private var focused: Bool
|
@FocusState private var focused: Bool
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ struct IntervalControl: View {
|
|||||||
TextField("sampling.seconds", text: $text)
|
TextField("sampling.seconds", text: $text)
|
||||||
.labelsHidden()
|
.labelsHidden()
|
||||||
.textFieldStyle(.roundedBorder).multilineTextAlignment(.trailing)
|
.textFieldStyle(.roundedBorder).multilineTextAlignment(.trailing)
|
||||||
.frame(width: 64).focused($focused)
|
.frame(width: fieldWidth).focused($focused)
|
||||||
.onChange(of: text) { _, value in
|
.onChange(of: text) { _, value in
|
||||||
if let seconds = Double(value.replacingOccurrences(of: ",", with: ".")), seconds.isFinite,
|
if let seconds = Double(value.replacingOccurrences(of: ",", with: ".")), seconds.isFinite,
|
||||||
seconds >= Double(range.lowerBound) / 1000, seconds <= Double(range.upperBound) / 1000 {
|
seconds >= Double(range.lowerBound) / 1000, seconds <= Double(range.upperBound) / 1000 {
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
/// Metrics change only when a new sample is published; no numeric transition or spring.
|
extension EnvironmentValues {
|
||||||
|
@Entry var panelMotionActive: Bool = true
|
||||||
|
}
|
||||||
|
|
||||||
struct MetricText: View {
|
struct MetricText: View {
|
||||||
let value: String
|
let value: String
|
||||||
var body: some View { Text(verbatim: value).monospacedDigit() }
|
|
||||||
|
var body: some View {
|
||||||
|
Text(verbatim: value).monospacedDigit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PanelCardBackground: ViewModifier {
|
struct PanelCardBackground: ViewModifier {
|
||||||
@@ -13,3 +19,17 @@ struct PanelCardBackground: ViewModifier {
|
|||||||
content.background(RoundedRectangle(cornerRadius: radius).fill(Color("PanelCard")))
|
content.background(RoundedRectangle(cornerRadius: radius).fill(Color("PanelCard")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct InlineMetric: View {
|
||||||
|
let title: LocalizedStringKey
|
||||||
|
let value: String
|
||||||
|
init(_ title: LocalizedStringKey, _ value: String) { self.title = title; self.value = value }
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack(spacing: 4) {
|
||||||
|
Text(title).foregroundStyle(.secondary)
|
||||||
|
MetricText(value: value).fontWeight(.medium)
|
||||||
|
}
|
||||||
|
.font(.system(size: 10)).lineLimit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
/// One fixed-size native host owns foreground, background trend and hover presentation.
|
enum CardChartPlacement {
|
||||||
|
case background
|
||||||
|
case belowDetails
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One native host owns the text, chart and hover presentation.
|
||||||
struct ResourceCard<Chart: View, Content: View>: View {
|
struct ResourceCard<Chart: View, Content: View>: View {
|
||||||
let title: LocalizedStringKey
|
let title: LocalizedStringKey
|
||||||
let symbol: String
|
let symbol: String
|
||||||
@@ -9,6 +14,7 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
|||||||
var secondaryValue: String? = nil
|
var secondaryValue: String? = nil
|
||||||
var valueColor: Color? = nil
|
var valueColor: Color? = nil
|
||||||
var secondaryValueColor: Color? = nil
|
var secondaryValueColor: Color? = nil
|
||||||
|
var titleBadge: String? = nil
|
||||||
var status: String? = nil
|
var status: String? = nil
|
||||||
var statusWarning = false
|
var statusWarning = false
|
||||||
var warningText: Text? = nil
|
var warningText: Text? = nil
|
||||||
@@ -16,6 +22,7 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
|||||||
var detailColor: Color? = nil
|
var detailColor: Color? = nil
|
||||||
var detailHelp: String? = nil
|
var detailHelp: String? = nil
|
||||||
var headerAccessory: AnyView? = nil
|
var headerAccessory: AnyView? = nil
|
||||||
|
var chartPlacement: CardChartPlacement = .belowDetails
|
||||||
@ViewBuilder var chart: () -> Chart
|
@ViewBuilder var chart: () -> Chart
|
||||||
@ViewBuilder var content: () -> Content
|
@ViewBuilder var content: () -> Content
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
@@ -24,15 +31,17 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
|||||||
|
|
||||||
private var cardBody: some View {
|
private var cardBody: some View {
|
||||||
GeometryReader { bounds in
|
GeometryReader { bounds in
|
||||||
ZStack(alignment: .bottomLeading) {
|
VStack(alignment: .leading, spacing: ResourceCardMetrics.gap) {
|
||||||
chart()
|
|
||||||
.frame(width: bounds.size.width, height: bounds.size.height)
|
|
||||||
VStack(alignment: .leading, spacing: 0) {
|
|
||||||
foreground
|
foreground
|
||||||
Spacer(minLength: 0)
|
.padding(.horizontal, ResourceCardMetrics.padding)
|
||||||
|
.padding(.top, ResourceCardMetrics.padding)
|
||||||
|
if chartPlacement == .belowDetails {
|
||||||
|
chart().frame(maxWidth: .infinity, maxHeight: .infinity).clipped()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding(ResourceCardMetrics.padding)
|
|
||||||
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading)
|
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading)
|
||||||
|
.background {
|
||||||
|
if chartPlacement == .background { chart() }
|
||||||
}
|
}
|
||||||
.background(Color("PanelCard"))
|
.background(Color("PanelCard"))
|
||||||
.clipShape(.rect(cornerRadius: ResourceCardMetrics.radius))
|
.clipShape(.rect(cornerRadius: ResourceCardMetrics.radius))
|
||||||
@@ -48,7 +57,7 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
|||||||
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)) {
|
minimumY: ResourceCardMetrics.tooltipMinimumY) {
|
||||||
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)
|
||||||
@@ -84,9 +93,17 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
|||||||
Image(systemName: symbol).foregroundStyle(statusWarning ? .red : color)
|
Image(systemName: symbol).foregroundStyle(statusWarning ? .red : color)
|
||||||
}
|
}
|
||||||
.font(.system(size: 11, weight: .semibold)).fixedSize()
|
.font(.system(size: 11, weight: .semibold)).fixedSize()
|
||||||
|
if let titleBadge {
|
||||||
|
Text(verbatim: titleBadge)
|
||||||
|
.font(.system(size: 9, weight: .semibold)).monospacedDigit()
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
.padding(.horizontal, 5).frame(height: 14)
|
||||||
|
.background(.primary.opacity(0.08), in: Capsule())
|
||||||
|
.fixedSize()
|
||||||
|
}
|
||||||
Spacer(minLength: 4)
|
Spacer(minLength: 4)
|
||||||
if let status {
|
if let status {
|
||||||
Text(verbatim: status)
|
MetricText(value: status)
|
||||||
.font(.system(size: 10, weight: .medium))
|
.font(.system(size: 10, weight: .medium))
|
||||||
.foregroundStyle(statusWarning ? .red : .secondary)
|
.foregroundStyle(statusWarning ? .red : .secondary)
|
||||||
.help(warningText ?? Text(verbatim: status))
|
.help(warningText ?? Text(verbatim: status))
|
||||||
@@ -126,10 +143,10 @@ private struct MetricHeadline: View {
|
|||||||
Image(systemName: direction == "↓" ? "arrow.down" : "arrow.up")
|
Image(systemName: direction == "↓" ? "arrow.down" : "arrow.up")
|
||||||
.font(.system(size: 12, weight: .medium)).foregroundStyle(color)
|
.font(.system(size: 12, weight: .medium)).foregroundStyle(color)
|
||||||
}
|
}
|
||||||
Text(verbatim: parts.first.map(String.init) ?? value)
|
MetricText(value: parts.first.map(String.init) ?? value)
|
||||||
.font(.system(size: compact ? 16 : 28, weight: .semibold))
|
.font(.system(size: compact ? 16 : 28, weight: .semibold))
|
||||||
if parts.count > 1 {
|
if parts.count > 1 {
|
||||||
Text(verbatim: String(parts[1]))
|
MetricText(value: String(parts[1]))
|
||||||
.font(.system(size: compact ? 10 : 12, weight: .medium))
|
.font(.system(size: compact ? 10 : 12, weight: .medium))
|
||||||
.foregroundStyle(Color.primary.opacity(0.8))
|
.foregroundStyle(Color.primary.opacity(0.8))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import SwiftUI
|
|
||||||
|
|
||||||
/// Four square blocks fill from bottom to top; partial blocks retain the actual fraction.
|
|
||||||
struct SegmentedCoreBar: View {
|
|
||||||
let value: Double?
|
|
||||||
let color: Color
|
|
||||||
|
|
||||||
static func portions(_ value: Double?, count: Int = 4) -> [Double] {
|
|
||||||
guard count > 0 else { return [] }
|
|
||||||
let fraction = value.flatMap { $0.isFinite ? min(1, max(0, $0)) : nil } ?? 0
|
|
||||||
return (0..<count).map { min(1, max(0, fraction * Double(count) - Double($0))) }
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
let fills = Self.portions(value)
|
|
||||||
VStack(spacing: 2) {
|
|
||||||
ForEach(Array(fills.indices.reversed()), id: \.self) { index in
|
|
||||||
ZStack(alignment: .bottom) {
|
|
||||||
Rectangle().fill(color.opacity(0.15))
|
|
||||||
Rectangle().fill(color).frame(height: 6 * fills[index])
|
|
||||||
}.frame(width: 6, height: 6).clipped()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.accessibilityHidden(true)
|
|
||||||
.transaction { $0.animation = nil; $0.disablesAnimations = true }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,14 +10,14 @@ import SwiftUI
|
|||||||
precondition(last > 0 && first - last <= 1)
|
precondition(last > 0 && first - last <= 1)
|
||||||
let columns = rows.max()!
|
let columns = rows.max()!
|
||||||
let cellWidth = (width - Double(columns - 1) * 3) / Double(columns)
|
let cellWidth = (width - Double(columns - 1) * 3) / Double(columns)
|
||||||
precondition(cellWidth >= 6, "Each real core needs its own visible meter cell")
|
precondition(cellWidth >= 7, "Each real core needs its own visible meter cell")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 430) == [18])
|
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 430) == [18])
|
||||||
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 280) == [18])
|
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 280) == [18])
|
||||||
precondition(CPUCoreGridLayout.rowCounts(count: 32, width: 430) == [32])
|
precondition(CPUCoreGridLayout.rowCounts(count: 32, width: 430) == [32])
|
||||||
precondition(CPUCoreGridLayout.rowCounts(count: 48, width: 430) == [48])
|
precondition(CPUCoreGridLayout.rowCounts(count: 48, width: 430) == [24, 24])
|
||||||
for count in [0, 1, 4, 8, 14, 18, 24, 32, 48, 128] {
|
for count in [0, 1, 4, 8, 14, 18, 24, 32, 48, 128] {
|
||||||
let kinds = Dictionary(uniqueKeysWithValues: (0..<count).map { ($0, $0 < count / 3 ? CPUCoreTopology.Kind.efficiency : .performance) })
|
let kinds = Dictionary(uniqueKeysWithValues: (0..<count).map { ($0, $0 < count / 3 ? CPUCoreTopology.Kind.efficiency : .performance) })
|
||||||
let groups = CPUCoreGrid.groups(count: count, kinds: kinds)
|
let groups = CPUCoreGrid.groups(count: count, kinds: kinds)
|
||||||
@@ -37,11 +37,10 @@ import SwiftUI
|
|||||||
precondition(CPUCoreGridLayout.rowCounts(count: 128, width: width).reduce(0, +) == 128)
|
precondition(CPUCoreGridLayout.rowCounts(count: 128, width: width).reduce(0, +) == 128)
|
||||||
}
|
}
|
||||||
precondition(CPUCoreGrid.groups(count: 3, kinds: [0: .efficiency]).count == 2)
|
precondition(CPUCoreGrid.groups(count: 3, kinds: [0: .efficiency]).count == 2)
|
||||||
precondition(SegmentedCoreBar.portions(0) == [0,0,0,0])
|
let m4 = CPUCoreGrid.groups(count: 14, kinds: Dictionary(uniqueKeysWithValues:
|
||||||
precondition(SegmentedCoreBar.portions(0.125) == [0.5,0,0,0])
|
(0..<14).map { ($0, $0 < 4 ? CPUCoreTopology.Kind.efficiency : .performance) }))
|
||||||
precondition(SegmentedCoreBar.portions(0.5) == [1,1,0,0])
|
let widths = CPUCoreGrid.groupWidths(groups: m4, width: 185)
|
||||||
precondition(SegmentedCoreBar.portions(1) == [1,1,1,1])
|
precondition(zip(m4, widths).map { CPUCoreGridLayout.rowCounts(count: $0.count, width: $1) } == [[4], [10]])
|
||||||
for invalid: Double? in [nil,.nan,-1] { precondition(SegmentedCoreBar.portions(invalid) == [0,0,0,0]) }
|
|
||||||
print("PASS: compact per-core meters with intact identities and bounded wrapping at multiple widths/counts")
|
print("PASS: compact per-core meters with intact identities and bounded wrapping at multiple widths/counts")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import SwiftUI
|
|||||||
styleMask: [.borderless], backing: .buffered, defer: false)
|
styleMask: [.borderless], backing: .buffered, defer: false)
|
||||||
window.isReleasedWhenClosed = false
|
window.isReleasedWhenClosed = false
|
||||||
window.level = .floating
|
window.level = .floating
|
||||||
let host = NSHostingView(rootView: Example(value: "128", probe: probe))
|
let host = NSHostingView(rootView: Example(value: "12.8 W", probe: probe))
|
||||||
host.sizingOptions = []
|
host.sizingOptions = []
|
||||||
window.contentView = host
|
window.contentView = host
|
||||||
window.orderFrontRegardless()
|
window.orderFrontRegardless()
|
||||||
@@ -22,18 +22,18 @@ import SwiftUI
|
|||||||
precondition(probe.appearances == 1 && probe.locale == "en_US" && probe.font == .system(size: 22, weight: .medium))
|
precondition(probe.appearances == 1 && probe.locale == "en_US" && probe.font == .system(size: 22, weight: .medium))
|
||||||
precondition(redPixels(before) > 30, "Foreground style must cross the native boundary")
|
precondition(redPixels(before) > 30, "Foreground style must cross the native boundary")
|
||||||
let originalLifetime = ObjectIdentifier(probe.lifetime!)
|
let originalLifetime = ObjectIdentifier(probe.lifetime!)
|
||||||
host.rootView = Example(value: "345", probe: probe)
|
host.rootView = Example(value: "12.9 W", probe: probe)
|
||||||
try? await Task.sleep(for: .milliseconds(140))
|
try? await Task.sleep(for: .milliseconds(40))
|
||||||
let settled = bitmap(host)
|
let updated = pixels(bitmap(host))
|
||||||
try? await Task.sleep(for: .milliseconds(600))
|
precondition(updated != pixels(before), "The next render must display the new reading")
|
||||||
let after = bitmap(host)
|
try? await Task.sleep(for: .milliseconds(500))
|
||||||
precondition(before.bitmapData != nil && after.bitmapData != nil)
|
precondition(updated == pixels(bitmap(host)), "Updated digits must be stationary")
|
||||||
precondition(pixels(before) != pixels(after), "Changed values must reach the retained child host")
|
host.rootView = Example(value: "12.8 W", probe: probe)
|
||||||
precondition(pixels(settled) == pixels(after),
|
try? await Task.sleep(for: .milliseconds(40))
|
||||||
"A sample must settle immediately without numeric rolling or a later animation frame")
|
precondition(pixels(bitmap(host)) == pixels(before), "A decrease must restore the original digits immediately")
|
||||||
precondition(probe.appearances == 1 && probe.lifetime.map(ObjectIdentifier.init) == originalLifetime,
|
precondition(probe.appearances == 1 && probe.lifetime.map(ObjectIdentifier.init) == originalLifetime,
|
||||||
"Sampling must update mounted content, not remount it")
|
"Sampling must update mounted content, not remount it")
|
||||||
host.rootView = Example(value: "345", probe: probe, locale: "zh_CN")
|
host.rootView = Example(value: "12.9 W", probe: probe, locale: "zh_CN")
|
||||||
try? await Task.sleep(for: .milliseconds(100))
|
try? await Task.sleep(for: .milliseconds(100))
|
||||||
precondition(probe.locale == "zh_CN")
|
precondition(probe.locale == "zh_CN")
|
||||||
window.setContentSize(NSSize(width: 360, height: 100))
|
window.setContentSize(NSSize(width: 360, height: 100))
|
||||||
@@ -44,7 +44,7 @@ import SwiftUI
|
|||||||
}
|
}
|
||||||
let child = childHost(host)
|
let child = childHost(host)
|
||||||
precondition(child?.bounds.size == host.bounds.size, "The parent must remain the sole frame owner")
|
precondition(child?.bounds.size == host.bounds.size, "The parent must remain the sole frame owner")
|
||||||
host.rootView = Example(value: "345", probe: probe, visible: false)
|
host.rootView = Example(value: "12.9 W", probe: probe, visible: false)
|
||||||
try? await Task.sleep(for: .milliseconds(150))
|
try? await Task.sleep(for: .milliseconds(150))
|
||||||
precondition(probe.disappearances == 1)
|
precondition(probe.disappearances == 1)
|
||||||
let releaseDeadline = ContinuousClock.now.advanced(by: .seconds(1))
|
let releaseDeadline = ContinuousClock.now.advanced(by: .seconds(1))
|
||||||
@@ -55,7 +55,7 @@ import SwiftUI
|
|||||||
window.orderOut(nil)
|
window.orderOut(nil)
|
||||||
window.contentView = nil
|
window.contentView = nil
|
||||||
window.close()
|
window.close()
|
||||||
print("PASS: static card host preserves immediate stable text, inherited font/style/locale, child state, resize and unmount")
|
print("PASS: card host displays stationary updated digits and preserves inherited font/style/locale, child state, resize and unmount")
|
||||||
fflush(stdout)
|
fflush(stdout)
|
||||||
NSApp.terminate(nil)
|
NSApp.terminate(nil)
|
||||||
}
|
}
|
||||||
@@ -118,12 +118,12 @@ import SwiftUI
|
|||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
private static func redPixels(_ bitmap: NSBitmapImageRep) -> Int {
|
private static func redPixels(_ bitmap: NSBitmapImageRep, contrast: CGFloat = 0.2) -> Int {
|
||||||
var count = 0
|
var count = 0
|
||||||
for x in 0..<bitmap.pixelsWide {
|
for x in 0..<bitmap.pixelsWide {
|
||||||
for y in 0..<bitmap.pixelsHigh {
|
for y in 0..<bitmap.pixelsHigh {
|
||||||
if let color = bitmap.colorAt(x: x, y: y)?.usingColorSpace(.deviceRGB),
|
if let color = bitmap.colorAt(x: x, y: y)?.usingColorSpace(.deviceRGB),
|
||||||
color.redComponent > color.greenComponent + 0.2 && color.redComponent > color.blueComponent + 0.2 {
|
(color.redComponent - max(color.greenComponent, color.blueComponent)) * color.alphaComponent > contrast {
|
||||||
count += 1
|
count += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,20 @@ import QuartzCore
|
|||||||
series: [Array(repeating: 0.8, count: 59) + [0.5]], intervals: fullFrame.intervals, boundaryDates: [])
|
series: [Array(repeating: 0.8, count: 59) + [0.5]], intervals: fullFrame.intervals, boundaryDates: [])
|
||||||
plot.configure(.init(frame: appended, colors: [.red], scales: [1], maximumGap: 5))
|
plot.configure(.init(frame: appended, colors: [.red], scales: [1], maximumGap: 5))
|
||||||
precondition(plot.input?.frame.dates.count == 60, "Static history must not retain an outgoing animation point")
|
precondition(plot.input?.frame.dates.count == 60, "Static history must not retain an outgoing animation point")
|
||||||
|
var moving = NativePanelCurve.Input(frame: appended, colors: [.red], scales: [1], maximumGap: 5, animates: true)
|
||||||
|
plot.configure(.init(frame: fullFrame, colors: [.red], scales: [1], maximumGap: 5))
|
||||||
|
plot.configure(moving)
|
||||||
|
let slide = plot.curves.animation(forKey: "trend.slide") as? CABasicAnimation
|
||||||
|
let start = (slide?.fromValue as? NSValue)?.caTransform3DValue
|
||||||
|
precondition(abs((start?.m41 ?? 0) - 280.0/59) < 0.001 && slide?.duration == 0.35)
|
||||||
|
let movingBuilds = plot.pathBuildCount
|
||||||
|
moving.hoveredIndex = 3
|
||||||
|
plot.configure(moving)
|
||||||
|
precondition(plot.curves.animationKeys()?.isEmpty != false && plot.pathBuildCount == movingBuilds)
|
||||||
|
plot.configure(.init(frame: .init(dates: Array(appended.dates.dropFirst()) + [Date(timeIntervalSinceReferenceDate: 122)],
|
||||||
|
series: appended.series, intervals: appended.intervals, boundaryDates: [Date(timeIntervalSinceReferenceDate: 122)]),
|
||||||
|
colors: [.red], scales: [1], maximumGap: 5, animates: true))
|
||||||
|
precondition(plot.curves.animationKeys()?.isEmpty != false, "Do not slide through a pause")
|
||||||
// Adding a series with an unchanged palette must color the new layer too.
|
// Adding a series with an unchanged palette must color the new layer too.
|
||||||
plot.configure(.init(frame: PanelCurveFrame(dates: dates, series: [[nil,nil,nil,nil], [0.5,0.5,0.5,0.5]],
|
plot.configure(.init(frame: PanelCurveFrame(dates: dates, series: [[nil,nil,nil,nil], [0.5,0.5,0.5,0.5]],
|
||||||
intervals: [2,2,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5))
|
intervals: [2,2,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5))
|
||||||
@@ -163,7 +177,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: bidirectional rate areas/zero axis/direction/hover/gaps, stacked component pixels and cumulative hover, 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")
|
print("PASS: bidirectional rate areas/zero axis/direction/hover/gaps, stacked component pixels and cumulative hover, static background lines/area pixels, no single-point fill, hidden-series isolation, reduced-motion stable updates, rolling transform and hover cancellation, 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()
|
||||||
|
|||||||
@@ -46,11 +46,11 @@ import CoreGraphics
|
|||||||
precondition(PanelLayout.columns(width: 648) == 3 && PanelLayout.columns(width: 620) == 3)
|
precondition(PanelLayout.columns(width: 648) == 3 && PanelLayout.columns(width: 620) == 3)
|
||||||
precondition(PanelLayout.columns(width: 619) == 2 && PanelLayout.columns(width: 430) == 2 && PanelLayout.columns(width: 429) == 1)
|
precondition(PanelLayout.columns(width: 619) == 2 && PanelLayout.columns(width: 430) == 2 && PanelLayout.columns(width: 429) == 1)
|
||||||
let tallerCPU = PanelLayout.cardHeights(coreRows: 6, fanCount: 2)
|
let tallerCPU = PanelLayout.cardHeights(coreRows: 6, fanCount: 2)
|
||||||
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [346, 346],
|
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [251, 251],
|
||||||
"All resource rows must share the maximum structural card height")
|
"All resource rows must share the maximum structural card height")
|
||||||
let moreFans = PanelLayout.cardHeights(coreRows: 1, fanCount: 10)
|
let moreFans = PanelLayout.cardHeights(coreRows: 1, 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) == [232, 232])
|
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [248, 248])
|
||||||
let noFans = PanelLayout.cardHeights(coreRows: 1, fanCount: 0)
|
let noFans = PanelLayout.cardHeights(coreRows: 1, fanCount: 0)
|
||||||
precondition(noFans[.gpu] == 176 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [176, 176])
|
precondition(noFans[.gpu] == 176 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [176, 176])
|
||||||
precondition(PanelLayout.preferredHeight(width: 648, heights: noFans) == 630,
|
precondition(PanelLayout.preferredHeight(width: 648, heights: noFans) == 630,
|
||||||
@@ -64,7 +64,7 @@ import CoreGraphics
|
|||||||
precondition(requested.height == 732, "A hardware-driven height above the default must be preserved")
|
precondition(requested.height == 732, "A hardware-driven height above the default must be preserved")
|
||||||
precondition(PanelLayout.processHeight(heights: compact) == 176)
|
precondition(PanelLayout.processHeight(heights: compact) == 176)
|
||||||
precondition(PanelLayout.dashboardHeight(columns: 3, heights: compact) == 540)
|
precondition(PanelLayout.dashboardHeight(columns: 3, heights: compact) == 540)
|
||||||
precondition(PanelLayout.processHeight(heights: tallerCPU) == 346)
|
precondition(PanelLayout.processHeight(heights: tallerCPU) == 251)
|
||||||
let input: [ProcessMetrics] = (0..<2000).map { (index: Int) -> ProcessMetrics in
|
let input: [ProcessMetrics] = (0..<2000).map { (index: Int) -> ProcessMetrics in
|
||||||
let id = ProcessIdentity(pid: Int32(index + 1), seconds: 1, microseconds: 0)
|
let id = ProcessIdentity(pid: Int32(index + 1), seconds: 1, microseconds: 0)
|
||||||
let path: String? = index == 42 ? "/test/needle" : nil
|
let path: String? = index == 42 ? "/test/needle" : nil
|
||||||
|
|||||||
@@ -27,32 +27,26 @@ import SwiftUI
|
|||||||
precondition(plots.count == 1)
|
precondition(plots.count == 1)
|
||||||
let plot = plots[0]
|
let plot = plots[0]
|
||||||
precondition(abs(host.bounds.width - width) < 1, "AppKit may round fractional content sizes to a point")
|
precondition(abs(host.bounds.width - width) < 1, "AppKit may round fractional content sizes to a point")
|
||||||
precondition(abs(plot.bounds.width - host.bounds.width) < 0.5 && abs(plot.bounds.height - host.bounds.height) < 0.5,
|
|
||||||
"The background chart must occupy the full card width and height, without axes or plot insets")
|
|
||||||
let graph = topRect(plot, in: host)
|
let graph = topRect(plot, in: host)
|
||||||
precondition(abs(graph.minY) < 0.5 && abs(graph.maxY - host.bounds.height) < 0.5,
|
|
||||||
"The background chart must end at the card bottom")
|
|
||||||
let detail = topRect(probe.view!, in: host)
|
let detail = topRect(probe.view!, in: host)
|
||||||
precondition(detail.minY >= 0 && detail.maxY <= host.bounds.height && detail.width <= host.bounds.width - 20 + 0.5,
|
precondition(abs(graph.width - host.bounds.width) < 0.5 && abs(graph.maxY - host.bounds.height) < 0.5)
|
||||||
"Foreground details must overlay the full-height graph within card bounds, including narrow/localized cards")
|
precondition(detail.maxY + 3 <= graph.minY && graph.height >= 32,
|
||||||
|
"The plot must sit entirely below the text at every width and locale")
|
||||||
precondition(plot.grid.isHidden && plot.input?.visibleSeriesCount == 1)
|
precondition(plot.grid.isHidden && plot.input?.visibleSeriesCount == 1)
|
||||||
let bitmap = host.bitmapImageRepForCachingDisplay(in: host.bounds)!
|
|
||||||
host.cacheDisplay(in: host.bounds, to: bitmap)
|
|
||||||
func sample(_ y: Double) -> [Double] {
|
|
||||||
let c = bitmap.colorAt(x: bitmap.pixelsWide / 2, y: Int(y * Double(bitmap.pixelsHigh) / 176))!.usingColorSpace(.deviceRGB)!
|
|
||||||
return [Double(c.redComponent), Double(c.greenComponent), Double(c.blueComponent)]
|
|
||||||
}
|
|
||||||
let base = sample(3)
|
|
||||||
let covered = zip(sample(80), base).reduce(0.0) { $0 + abs($1.0 - $1.1) }
|
|
||||||
let open = zip(sample(150), base).reduce(0.0) { $0 + abs($1.0 - $1.1) }
|
|
||||||
precondition(open > 0.02 && abs(covered - open) < 0.01,
|
|
||||||
"Charts must retain the same color under foreground details and bottom whitespace: \(covered), \(open)")
|
|
||||||
for kind in 0...1 {
|
for kind in 0...1 {
|
||||||
host.rootView = AnyView(detailsFixture(kind: kind, probe: probe)
|
host.rootView = AnyView(detailsFixture(kind: kind, probe: probe)
|
||||||
.environment(\.locale, Locale(identifier: language))
|
.environment(\.locale, Locale(identifier: language))
|
||||||
.environment(\.colorScheme, dark ? .dark : .light))
|
.environment(\.colorScheme, dark ? .dark : .light))
|
||||||
try? await Task.sleep(for: .milliseconds(60)); host.layoutSubtreeIfNeeded()
|
try? await Task.sleep(for: .milliseconds(60)); host.layoutSubtreeIfNeeded()
|
||||||
let details = topRect(probe.view!, in: host)
|
let details = topRect(probe.view!, in: host)
|
||||||
|
let trend = descendants(host).compactMap { $0 as? NativePanelCurve.PlotView }.first!
|
||||||
|
let plotRect = topRect(trend, in: host)
|
||||||
|
if kind == 0 {
|
||||||
|
precondition(plotRect == host.bounds, "Physical memory capacity must map to the top of the card")
|
||||||
|
} else {
|
||||||
|
precondition(plotRect.height >= 24 && plotRect.minY >= details.maxY + 3,
|
||||||
|
"Storage details must leave a separate usable plot")
|
||||||
|
}
|
||||||
precondition(details.maxY <= host.bounds.height - 10 + 0.5 && details.width <= host.bounds.width - 20 + 0.5,
|
precondition(details.maxY <= host.bounds.height - 10 + 0.5 && details.width <= host.bounds.width - 20 + 0.5,
|
||||||
"Larger production details must fit the unchanged card: \(kind), \(language), \(width), \(details)")
|
"Larger production details must fit the unchanged card: \(kind), \(language), \(width), \(details)")
|
||||||
}
|
}
|
||||||
@@ -60,11 +54,32 @@ import SwiftUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Mount the production branch with a desktop, a missing sensor and a failed battery read.
|
||||||
|
for state: BatteryAvailability in [.absent, .failed, .present, .unknown] {
|
||||||
|
var sample = MetricsSnapshot()
|
||||||
|
sample.batteryState = state
|
||||||
|
sample.systemPower = state == .absent ? 32.5 : nil
|
||||||
|
if state == .present { sample.battery = BatteryMetrics(charge: 0.8, charging: false, externalPower: true, power: 0) }
|
||||||
|
var history = MetricHistory()
|
||||||
|
history.append(sample)
|
||||||
|
sample.date = sample.date.addingTimeInterval(2); sample.systemPower = nil
|
||||||
|
history.append(sample)
|
||||||
|
host.rootView = AnyView(PowerResourceCard(snapshot: sample, samples: history.samples,
|
||||||
|
chartInterval: 2, chartBoundaries: [], chartIntervals: [2,2]))
|
||||||
|
try? await Task.sleep(for: .milliseconds(80)); host.layoutSubtreeIfNeeded()
|
||||||
|
let plot = descendants(host).compactMap { $0 as? NativePanelCurve.PlotView }.first!
|
||||||
|
let first = plot.input?.frame.series.first
|
||||||
|
switch state {
|
||||||
|
case .absent: precondition(first == [32.5, nil] && plot.input?.scales.first == 32.5)
|
||||||
|
case .present: precondition(first == [0.8, 0.8] && plot.input?.scales.first == 1 && topRect(plot, in: host) == host.bounds)
|
||||||
|
default: precondition(first == [nil, nil] && plot.input?.scales.first == 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
host.rootView = AnyView(EmptyView())
|
host.rootView = AnyView(EmptyView())
|
||||||
try? await Task.sleep(for: .milliseconds(100))
|
try? await Task.sleep(for: .milliseconds(100))
|
||||||
precondition(descendants(host).allSatisfy { !($0 is NativePanelCurve.PlotView) })
|
precondition(descendants(host).allSatisfy { !($0 is NativePanelCurve.PlotView) })
|
||||||
window.orderOut(nil); window.contentView = nil; window.close()
|
window.orderOut(nil); window.contentView = nil; window.close()
|
||||||
print("PASS: production card geometry at 190/205⅓/400pt, light/dark, three languages, full-height chart without foreground dimming, larger localized memory/storage detail bounds, unmount")
|
print("PASS: production card geometry at 190/205⅓/400pt, light/dark, three languages, separate plot below text, localized memory/storage details, unmount")
|
||||||
NSApp.terminate(nil)
|
NSApp.terminate(nil)
|
||||||
}
|
}
|
||||||
NSApp.run()
|
NSApp.run()
|
||||||
@@ -90,7 +105,7 @@ import SwiftUI
|
|||||||
health: .init(remainingLife: 0.98, powerOnHours: 99999),
|
health: .init(remainingLife: 0.98, powerOnHours: 99999),
|
||||||
io: .init(read: 999_900_000_000, written: 999_900_000_000)))
|
io: .init(read: 999_900_000_000, written: 999_900_000_000)))
|
||||||
return ResourceCard(title: kind == 0 ? "metric.memory" : "metric.disk", symbol: "memorychip", color: .blue,
|
return ResourceCard(title: kind == 0 ? "metric.memory" : "metric.disk", symbol: "memorychip", color: .blue,
|
||||||
value: "26.0 / 48 GiB", chart: { Color.clear }) {
|
value: "26.0 / 48 GiB", chartPlacement: kind == 0 ? .background : .belowDetails, chart: { PanelTrendChart(dates: [Date()], first: [0.5], color: .blue) }) {
|
||||||
details.background(DetailMarker(probe: probe).allowsHitTesting(false))
|
details.background(DetailMarker(probe: probe).allowsHitTesting(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -25,7 +25,7 @@ CHECKS.update({
|
|||||||
"BoundedProcessChecks": ["kymo/Core/Services/BoundedProcess.swift"],
|
"BoundedProcessChecks": ["kymo/Core/Services/BoundedProcess.swift"],
|
||||||
"SensorScheduleChecks": ["kymo/Core/Services/SensorSchedule.swift"],
|
"SensorScheduleChecks": ["kymo/Core/Services/SensorSchedule.swift"],
|
||||||
"CPUCoreGridChecks": ["kymo/Features/MenuBar/CPUCoreGrid.swift", "kymo/Core/Services/CPUCoreTopology.swift",
|
"CPUCoreGridChecks": ["kymo/Features/MenuBar/CPUCoreGrid.swift", "kymo/Core/Services/CPUCoreTopology.swift",
|
||||||
"kymo/Core/Extensions/MetricFormat.swift", "kymo/UI/Components/MetricProgressBar.swift", "kymo/UI/Components/SegmentedCoreBar.swift"],
|
"kymo/Core/Extensions/MetricFormat.swift"],
|
||||||
"CPUTemperatureChecks": ["kymo/Core/Monitors/CPUTemperatureMonitor.swift"],
|
"CPUTemperatureChecks": ["kymo/Core/Monitors/CPUTemperatureMonitor.swift"],
|
||||||
"DiskHealthChecks": ["kymo/Core/Models/DiskHealthMetrics.swift", "kymo/Core/Monitors/DiskHealthReport.swift"],
|
"DiskHealthChecks": ["kymo/Core/Models/DiskHealthMetrics.swift", "kymo/Core/Monitors/DiskHealthReport.swift"],
|
||||||
"PublicIPAddressChecks": ["kymo/Core/Services/PublicIPAddressService.swift"],
|
"PublicIPAddressChecks": ["kymo/Core/Services/PublicIPAddressService.swift"],
|
||||||
@@ -70,6 +70,7 @@ CHECKS["ResourceCardChecks"] = [
|
|||||||
"kymo/UI/Charts/ChartTooltipLayer.swift", "kymo/Core/Extensions/MetricFormat.swift",
|
"kymo/UI/Charts/ChartTooltipLayer.swift", "kymo/Core/Extensions/MetricFormat.swift",
|
||||||
]
|
]
|
||||||
CHECKS["ResourceCardChecks"] = list(dict.fromkeys(CORE + CHECKS["ResourceCardChecks"] + [
|
CHECKS["ResourceCardChecks"] = list(dict.fromkeys(CORE + CHECKS["ResourceCardChecks"] + [
|
||||||
|
"kymo/Features/MenuBar/PowerResourceCard.swift", "kymo/UI/Components/AppLocalization.swift",
|
||||||
"kymo/Features/MenuBar/MemoryDetailsView.swift", "kymo/Features/MenuBar/StorageDetailsView.swift",
|
"kymo/Features/MenuBar/MemoryDetailsView.swift", "kymo/Features/MenuBar/StorageDetailsView.swift",
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user