fix: paint window-aligned gradients within popup bounds

This commit is contained in:
2026-10-18 01:30:58 +02:00
parent 75c9a329d6
commit cea12f819b
4 changed files with 58 additions and 32 deletions
@@ -118,6 +118,10 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
content.trailingAnchor.constraint(equalTo: view.trailingAnchor),
content.topAnchor.constraint(equalTo: view.topAnchor),
content.bottomAnchor.constraint(equalTo: view.bottomAnchor),
background.leadingAnchor.constraint(equalTo: content.leadingAnchor),
background.trailingAnchor.constraint(equalTo: content.trailingAnchor),
background.topAnchor.constraint(equalTo: content.topAnchor),
background.bottomAnchor.constraint(equalTo: content.bottomAnchor),
applicationLabel.leadingAnchor.constraint(equalTo: content.leadingAnchor, constant: 16),
applicationLabel.trailingAnchor.constraint(equalTo: content.trailingAnchor, constant: -16),
applicationLabel.topAnchor.constraint(equalTo: content.topAnchor, constant: 14),
@@ -197,13 +201,8 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
view.alphaValue = 0
view.translatesAutoresizingMaskIntoConstraints = false
host.addSubview(view)
// Crop the window-sized background; filtering must not rescale its glows.
NSLayoutConstraint.activate([
background.leadingAnchor.constraint(equalTo: host.leadingAnchor),
background.trailingAnchor.constraint(equalTo: host.trailingAnchor),
background.topAnchor.constraint(equalTo: host.topAnchor),
background.bottomAnchor.constraint(equalTo: host.bottomAnchor)
])
// Paint only the popup's bounds, using the window's gradient coordinates.
background.canvas = host
NSLayoutConstraint.activate([
view.trailingAnchor.constraint(equalTo: pill.trailingAnchor),
belowAnchor
@@ -214,7 +213,6 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
coveredPillAlpha = pill.alphaValue
}
coveredPill?.setAccessibilityHidden(true)
// Resolve the background crop before fading in a newly positioned popup.
host.layoutSubtreeIfNeeded()
background.needsDisplay = true
NSAnimationContext.runAnimationGroup { context in
+11 -6
View File
@@ -13,6 +13,7 @@ enum SunsetPalette {
@MainActor
final class LauncherBackground: NSView {
weak var canvas: NSView?
private let amber = NSGradient(colors: [
SunsetPalette.accent.withAlphaComponent(0.18),
SunsetPalette.accent.withAlphaComponent(0.065),
@@ -29,17 +30,21 @@ final class LauncherBackground: NSView {
override func draw(_ dirtyRect: NSRect) {
SunsetPalette.background.setFill()
dirtyRect.fill()
let upperGlow = NSPoint(x: bounds.width * 0.58, y: bounds.height * 0.94)
let canvasBounds = canvas.map { convert($0.bounds, from: $0) } ?? bounds
let upperGlow = NSPoint(x: canvasBounds.minX + canvasBounds.width * 0.58,
y: canvasBounds.minY + canvasBounds.height * 0.94)
ember.draw(fromCenter: upperGlow, radius: 0, toCenter: upperGlow,
radius: bounds.width * 0.40, options: [])
let lowerGlow = NSPoint(x: bounds.width * 0.88, y: bounds.height * 0.10)
radius: canvasBounds.width * 0.40, options: [])
let lowerGlow = NSPoint(x: canvasBounds.minX + canvasBounds.width * 0.88,
y: canvasBounds.minY + canvasBounds.height * 0.10)
amber.draw(fromCenter: lowerGlow, radius: 0, toCenter: lowerGlow,
radius: bounds.width * 0.55, options: [])
let leftGlow = NSPoint(x: bounds.width * 0.08, y: bounds.height * 0.65)
radius: canvasBounds.width * 0.55, options: [])
let leftGlow = NSPoint(x: canvasBounds.minX + canvasBounds.width * 0.08,
y: canvasBounds.minY + canvasBounds.height * 0.65)
NSGraphicsContext.saveGraphicsState()
NSGraphicsContext.current?.cgContext.setAlpha(0.45)
amber.draw(fromCenter: leftGlow, radius: 0, toCenter: leftGlow,
radius: bounds.width * 0.32, options: [])
radius: canvasBounds.width * 0.32, options: [])
NSGraphicsContext.restoreGraphicsState()
}
}