Files
Kymo/kymo/UI/Charts/TrendScroll.swift
T
wangairnan 0c846a2127 feat(menubar): 实现趋势面板外侧详情与三语外观设置
接入有界趋势、平滑滚动、菜单式外侧详情、底部操作与三语文案,装配独立外观设置和 Dock 生命周期。
合并跟随系统外观刷新、自选颜色入口与色块绘制修复,保留用户确认的配色联动、重启保存及滚动验收。
多场景视觉与长期资源验证边界仍记录于 docs。
2026-10-30 00:45:34 +08:00

19 lines
820 B
Swift

import Foundation
/// Geometry for a single appended sample, including the outgoing point at full capacity.
nonisolated enum TrendScroll {
static func isAppend(from old: [Double?], to new: [Double?]) -> Bool {
guard !old.isEmpty, !new.isEmpty else { return false }
if old.count < MetricHistory.capacity {
return new.count == old.count + 1 && Array(new.dropLast()) == old
}
return new.count == old.count && Array(old.dropFirst()) == Array(new.dropLast())
}
static func position(index: Int, count: Int, progress: CGFloat, scrolling: Bool) -> CGFloat {
let offset = MetricHistory.capacity - count
let shift = scrolling ? 1 - min(1, max(0, progress)) : 0
return (CGFloat(index + offset) + shift) / CGFloat(MetricHistory.capacity - 1)
}
}