mirror of
https://github.com/lwouis/alt-tab-macos.git
synced 2026-05-24 11:20:36 +00:00
feat: show app icon for app with no open window (closes #2561)
This commit is contained in:
@@ -11,25 +11,6 @@ enum Symbols: String {
|
||||
case filledCircled = ""
|
||||
case filledCircledNumber0 = ""
|
||||
case filledCircledNumber10 = ""
|
||||
case newWindow = ""
|
||||
}
|
||||
|
||||
class FontIcon: NSView {
|
||||
var labelView: BaseLabel!
|
||||
|
||||
convenience init(_ symbol: Symbols, _ tooltip: String?) {
|
||||
self.init(frame: .zero)
|
||||
shadow = ThumbnailView.makeShadow(.darkGray)
|
||||
wantsLayer = true
|
||||
layer!.cornerRadius = 2
|
||||
layer!.backgroundColor = NSColor(red: 0.9, green: 0.9, blue: 0.9, alpha: 1).cgColor
|
||||
labelView = BaseLabel(symbol.rawValue)
|
||||
labelView.font = NSFont(name: "SF Pro Text", size: Preferences.fontHeight)!
|
||||
labelView.textColor = .darkGray
|
||||
labelView.alignment = .center
|
||||
labelView.toolTip = tooltip
|
||||
addSubview(labelView)
|
||||
}
|
||||
}
|
||||
|
||||
// Font icon using SF Symbols from the SF Pro font from Apple
|
||||
|
||||
@@ -25,7 +25,7 @@ class ThumbnailView: NSStackView {
|
||||
var indexInRecycledViews: Int!
|
||||
var shouldShowWindowControls = false
|
||||
var isShowingWindowControls = false
|
||||
var windowlessIcon = FontIcon(.newWindow, NSLocalizedString("App is running but has no open window", comment: ""))
|
||||
var windowlessIcon = NSImageView()
|
||||
var frameInset = Preferences.intraCellPadding
|
||||
|
||||
// for VoiceOver cursor
|
||||
@@ -50,6 +50,7 @@ class ThumbnailView: NSStackView {
|
||||
orientation = .vertical
|
||||
let shadow = ThumbnailView.makeShadow(.gray)
|
||||
thumbnail.shadow = shadow
|
||||
windowlessIcon.toolTip = NSLocalizedString("App is running but has no open window", comment: "")
|
||||
windowlessIcon.shadow = shadow
|
||||
appIcon.shadow = shadow
|
||||
hStackView = NSStackView(views: [appIcon, label, hiddenIcon, fullscreenIcon, minimizedIcon, spaceIcon])
|
||||
@@ -176,14 +177,12 @@ class ThumbnailView: NSStackView {
|
||||
label.toolTip = label.textStorage!.size().width >= label.textContainer!.size.width ? label.string : nil
|
||||
assignIfDifferent(&windowlessIcon.isHidden, !element.isWindowlessApp || Preferences.hideThumbnails)
|
||||
if element.isWindowlessApp {
|
||||
let maxWidth = (frame.size.width - Preferences.intraCellPadding * 2).rounded()
|
||||
let maxHeight = (frame.size.height - hStackView.fittingSize.height - Preferences.intraCellPadding * 2).rounded()
|
||||
// heuristic to determine font size based on bounding box
|
||||
let fontSize = (min(maxWidth - Preferences.intraCellPadding * 2, maxHeight - Preferences.intraCellPadding * 2) * 0.6).rounded()
|
||||
// heuristic to fit the SF Symbol into the bounding box
|
||||
let labelViewHeight = (fontSize * 1.4).rounded()
|
||||
windowlessIcon.labelView.frame = NSRect(x: Preferences.intraCellPadding, y: ((maxHeight - labelViewHeight) / 2).rounded(), width: maxWidth - Preferences.intraCellPadding * 2, height: labelViewHeight - Preferences.intraCellPadding * 2)
|
||||
windowlessIcon.labelView.font = NSFont(name: windowlessIcon.labelView.font!.fontName, size: fontSize)
|
||||
windowlessIcon.image = appIcon.image!.copy() as! NSImage
|
||||
windowlessIcon.image?.size = NSSize(width: 1024, height: 1024)
|
||||
let (thumbnailWidth, thumbnailHeight) = ThumbnailView.thumbnailSize(windowlessIcon.image, screen)
|
||||
let windowlessIconSize = NSSize(width: thumbnailWidth, height: thumbnailHeight)
|
||||
windowlessIcon.image!.size = windowlessIconSize
|
||||
windowlessIcon.frame.size = windowlessIconSize
|
||||
windowlessIcon.needsDisplay = true
|
||||
}
|
||||
self.mouseUpCallback = { () -> Void in App.app.focusSelectedWindow(element) }
|
||||
|
||||
Reference in New Issue
Block a user