feat: fade launcher list edges beneath bars
This commit is contained in:
@@ -257,7 +257,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
}
|
||||
tableView.setAccessibilityLabel("Applications")
|
||||
|
||||
let scrollView = NSScrollView()
|
||||
let scrollView = LauncherScrollView()
|
||||
scrollView.documentView = tableView
|
||||
scrollView.hasVerticalScroller = true
|
||||
scrollView.autohidesScrollers = true
|
||||
@@ -909,6 +909,33 @@ final class ApplicationCell: NSTableCellView {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
final class LauncherScrollView: NSScrollView {
|
||||
private let edgeFade = CAGradientLayer()
|
||||
|
||||
override init(frame frameRect: NSRect) {
|
||||
super.init(frame: frameRect)
|
||||
wantsLayer = true
|
||||
edgeFade.colors = [NSColor.clear.cgColor, NSColor.black.cgColor,
|
||||
NSColor.black.cgColor, NSColor.clear.cgColor]
|
||||
edgeFade.startPoint = CGPoint(x: 0.5, y: 0)
|
||||
edgeFade.endPoint = CGPoint(x: 0.5, y: 1)
|
||||
layer?.mask = edgeFade
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { fatalError("Conjure creates its scroll view programmatically") }
|
||||
|
||||
override func layout() {
|
||||
super.layout()
|
||||
let fade = min(0.5, 16 / max(bounds.height, 1))
|
||||
CATransaction.begin()
|
||||
CATransaction.setDisableActions(true)
|
||||
edgeFade.frame = bounds
|
||||
edgeFade.locations = [0, NSNumber(value: Double(fade)), NSNumber(value: Double(1 - fade)), 1]
|
||||
CATransaction.commit()
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private final class ApplicationTableView: NSTableView {
|
||||
var openSelection: (() -> Void)?
|
||||
|
||||
Reference in New Issue
Block a user