feat: fade launcher list edges beneath bars

This commit is contained in:
Valdemar Lorenzen
2026-10-14 12:27:33 +02:00
parent 3fd9519169
commit f3d173d245
3 changed files with 59 additions and 1 deletions
@@ -0,0 +1,29 @@
import AppKit
import Testing
@testable import Conjure
@Test @MainActor
func launcherFadesStayAtViewportEdgesAfterScrollingAndResizing() throws {
_ = NSApplication.shared
let scroll = LauncherScrollView(frame: NSRect(x: 0, y: 0, width: 200, height: 120))
scroll.documentView = NSView(frame: NSRect(x: 0, y: 0, width: 200, height: 600))
for height in [120, 240] {
scroll.frame.size.height = CGFloat(height)
scroll.contentView.scroll(to: NSPoint(x: 0, y: 80))
scroll.layoutSubtreeIfNeeded()
let mask = try #require(scroll.layer?.mask)
let context = try #require(CGContext(data: nil, width: 200, height: height,
bitsPerComponent: 8, bytesPerRow: 800, space: CGColorSpaceCreateDeviceRGB(),
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue))
mask.render(in: context)
let pixels = try #require(context.data?.assumingMemoryBound(to: UInt8.self))
func alpha(_ y: Int) -> UInt8 { pixels[y * 800 + 100 * 4 + 3] }
#expect(alpha(0) < 20)
#expect(alpha(8) > 80 && alpha(8) < 180)
#expect(alpha(20) == 255)
#expect(alpha(height / 2) == 255)
#expect(alpha(height - 21) == 255)
#expect(alpha(height - 9) > 80 && alpha(height - 9) < 180)
#expect(alpha(height - 1) < 20)
}
}