feat(settings): 默认启用短动效并提供独立减弱动画选项

This commit is contained in:
2026-11-04 11:53:17 +08:00
parent 40a7a55edf
commit f18f6652ff
23 changed files with 443 additions and 34 deletions
+35 -1
View File
@@ -7,6 +7,7 @@ import SwiftUI
Task { @MainActor in
let window = NSWindow(contentRect: NSRect(x: 40, y: 40, width: 300, height: 140), styleMask: [.borderless], backing: .buffered, defer: false)
window.isReleasedWhenClosed = false
window.level = .floating
let root = NSView(frame: NSRect(x: 0, y: 0, width: 300, height: 140))
window.contentView = root
let plot = NativePanelCurve.PlotView(); plot.frame = NSRect(x: 0, y: 0, width: 280, height: 60)
@@ -41,8 +42,41 @@ import SwiftUI
ring.configure(NativeMetricRing.Input(value: 1, color: .red, lineWidth: 3, trackOpacity: 0.17, inset: 2))
let full = redPixels(bitmap(ring), opaque: true)
precondition(quarter > 0 && full > quarter * 2, "Ring fraction must change the rendered arc")
// Actual native compositor transitions finish and remove their animation objects.
var moving = continuous
let extendedDates = dates + [Date(timeIntervalSinceReferenceDate: 8)]
moving = NativePanelCurve.Input(frame: PanelCurveFrame(dates: extendedDates, series: [[0.8,0.8,0.8,0.8,0.5]],
intervals: [2,2,2,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5, animates: true)
plot.configure(continuous); plot.configure(moving)
precondition(plot.isAnimating)
try? await Task.sleep(for: .milliseconds(400))
precondition(!plot.isAnimating && plot.drawingFrame == moving.frame)
var appended = moving
appended = NativePanelCurve.Input(frame: PanelCurveFrame(dates: extendedDates + [Date(timeIntervalSinceReferenceDate: 10)],
series: [[0.8,0.8,0.8,0.8,0.5,0.2]], intervals: [2,2,2,2,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5, animates: true)
plot.configure(appended); precondition(plot.isAnimating)
appended.animates = false; plot.configure(appended)
precondition(!plot.isAnimating && plot.drawingFrame == appended.frame)
let beforeGap = appended
appended = NativePanelCurve.Input(frame: PanelCurveFrame(dates: appended.frame.dates + [Date(timeIntervalSinceReferenceDate: 30)],
series: [[0.8,0.8,0.8,0.8,0.5,0.2,0.7]], intervals: [2,2,2,2,2,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5, animates: true)
plot.configure(appended); precondition(!plot.isAnimating, "Do not animate across real gaps")
plot.configure(moving)
var attached = beforeGap; attached.animates = true
plot.configure(attached); precondition(plot.isAnimating)
plot.removeFromSuperview(); precondition(!plot.isAnimating)
ring.configure(NativeMetricRing.Input(value: 0, color: .red, lineWidth: 3, trackOpacity: 0.17, inset: 2, animates: true))
precondition(ring.isAnimating)
try? await Task.sleep(for: .milliseconds(400))
precondition(!ring.isAnimating && ring.displayedValue == 0)
ring.configure(NativeMetricRing.Input(value: 0.8, color: .red, lineWidth: 3, trackOpacity: 0.17, inset: 2, animates: true))
precondition(ring.isAnimating)
ring.configure(NativeMetricRing.Input(value: 0.8, color: .red, lineWidth: 3, trackOpacity: 0.17, inset: 2))
precondition(!ring.isAnimating && ring.displayedValue == 0.8)
ring.configure(NativeMetricRing.Input(value: 0.2, color: .red, lineWidth: 3, trackOpacity: 0.17, inset: 2, animates: true))
ring.removeFromSuperview(); precondition(!ring.isAnimating && ring.displayedValue == 0.2)
window.orderOut(nil); window.close()
print("PASS: native curve pixels, real gaps, missing series, hover, appearance, duplicate-input invalidation and zero/quarter/full ring pixels")
print("PASS: native curve pixels, real gaps, missing series, hover, appearance, duplicate-input invalidation zero/quarter/full ring pixels and finite transitions/gap/policy/unmount cancellation")
fflush(stdout); NSApp.terminate(nil)
}
NSApp.run()