feat: separate favorite application suggestions

This commit is contained in:
Valdemar Lorenzen
2026-10-14 12:03:36 +02:00
parent fd010ac864
commit 3fd9519169
5 changed files with 47 additions and 8 deletions
+27 -1
View File
@@ -527,6 +527,18 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
resultCount
}
private func spacingBeforeRow(_ row: Int) -> CGFloat {
guard calculation == nil,
searchField.stringValue.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty,
row > 0, results.indices.contains(row),
history.isFavorite(results[row - 1]), !history.isFavorite(results[row]) else { return 0 }
return 12
}
func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
LauncherRowView.rowHeight + spacingBeforeRow(row)
}
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
let identifier = NSUserInterfaceItemIdentifier("applicationCell")
let cell = (tableView.makeView(withIdentifier: identifier, owner: self) as? ApplicationCell)
@@ -564,6 +576,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
let view = (tableView.makeView(withIdentifier: identifier, owner: self) as? LauncherRowView)
?? LauncherRowView()
view.identifier = identifier
view.topSpacing = spacingBeforeRow(row)
return view
}
@@ -1058,9 +1071,22 @@ final class LauncherRowView: NSTableRowView {
static let textSize: CGFloat = 14
static let iconSize: CGFloat = 22
static let iconToTextSpacing: CGFloat = 12
var topSpacing: CGFloat = 0 {
didSet { needsLayout = true; needsDisplay = true }
}
override func layout() {
super.layout()
for case let cell as ApplicationCell in subviews {
cell.frame = NSRect(x: 0, y: topSpacing, width: bounds.width, height: bounds.height - topSpacing)
}
}
override func drawSelection(in dirtyRect: NSRect) {
let selection = NSBezierPath(roundedRect: bounds.insetBy(dx: 0.75, dy: 0.75), xRadius: 10, yRadius: 10)
var selectionBounds = bounds
selectionBounds.origin.y += topSpacing
selectionBounds.size.height -= topSpacing
let selection = NSBezierPath(roundedRect: selectionBounds.insetBy(dx: 0.75, dy: 0.75), xRadius: 10, yRadius: 10)
SunsetPalette.selectionFill.setFill()
selection.fill()
let increasedContrast = NSWorkspace.shared.accessibilityDisplayShouldIncreaseContrast