fix: improve label display in app-icons style
This commit is contained in:
1 parent
dd05ba239e
commit
7e501a460a
4 files changed
+16
-24
No files matched your search
@@ -21,7 +21,7 @@ class ThumbnailFontIconView: ThumbnailTitleView {
|
||||
color: NSColor = Appearance.fontColor,
|
||||
shadow: NSShadow? = ThumbnailView.makeShadow(Appearance.indicatedIconShadowColor)) {
|
||||
// This helps SF symbols display vertically centered and not clipped at the top
|
||||
self.init(size, shadow: shadow, font: NSFont(name: "SF Pro Text", size: (size * 0.85).rounded())!)
|
||||
self.init(shadow: shadow, font: NSFont(name: "SF Pro Text", size: (size * 0.85).rounded())!)
|
||||
stringValue = symbol.rawValue
|
||||
textColor = color
|
||||
addOrUpdateConstraint(widthAnchor, cell!.cellSize.width)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Cocoa
|
||||
|
||||
class ThumbnailTitleView: NSTextField {
|
||||
convenience init(_ height: CGFloat, shadow: NSShadow? = ThumbnailView.makeShadow(Appearance.titleShadowColor), font: NSFont = Appearance.font) {
|
||||
convenience init(shadow: NSShadow?, font: NSFont) {
|
||||
self.init(labelWithString: "")
|
||||
self.font = font
|
||||
textColor = Appearance.fontColor
|
||||
@@ -28,12 +28,4 @@ class ThumbnailTitleView: NSTextField {
|
||||
}
|
||||
return .byTruncatingHead
|
||||
}
|
||||
|
||||
static func extraLineSpacing(for fontSize: CGFloat) -> CGFloat {
|
||||
return fontSize * 0.2
|
||||
}
|
||||
|
||||
static func maxHeight() -> CGFloat {
|
||||
return Appearance.fontHeight + extraLineSpacing(for: Appearance.fontHeight)
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ class ThumbnailView: NSStackView {
|
||||
var windowlessIcon = NSImageView()
|
||||
var thumbnailContainer: NSStackView!
|
||||
var appIcon = NSImageView()
|
||||
var label = ThumbnailTitleView(Appearance.fontHeight)
|
||||
var label = ThumbnailTitleView(shadow: ThumbnailView.makeShadow(Appearance.titleShadowColor), font: Appearance.font)
|
||||
var fullscreenIcon = ThumbnailFontIconView(symbol: .circledPlusSign, tooltip: NSLocalizedString("Window is fullscreen", comment: ""))
|
||||
var minimizedIcon = ThumbnailFontIconView(symbol: .circledMinusSign, tooltip: NSLocalizedString("Window is minimized", comment: ""))
|
||||
var hiddenIcon = ThumbnailFontIconView(symbol: .circledSlashSign, tooltip: NSLocalizedString("App is hidden", comment: ""))
|
||||
@@ -84,8 +84,7 @@ class ThumbnailView: NSStackView {
|
||||
vStackView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
vStackView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||
vStackView.topAnchor.constraint(equalTo: topAnchor),
|
||||
label.topAnchor.constraint(equalTo: vStackView.bottomAnchor, constant: Appearance.intraCellPadding),
|
||||
bottomAnchor.constraint(equalTo: label.bottomAnchor, constant: Appearance.intraCellPadding)
|
||||
label.topAnchor.constraint(equalTo: vStackView.bottomAnchor),
|
||||
])
|
||||
} else {
|
||||
hStackView = NSStackView(views: [appIcon, label, hiddenIcon, fullscreenIcon, minimizedIcon, spaceIcon])
|
||||
@@ -579,15 +578,15 @@ class ThumbnailView: NSStackView {
|
||||
return NSSize(width: Appearance.iconSize, height: Appearance.iconSize)
|
||||
}
|
||||
|
||||
static func height(_ screen: NSScreen) -> CGFloat {
|
||||
static func height(_ screen: NSScreen, _ labelHeight: CGFloat) -> CGFloat {
|
||||
let topBottomEdgeInsetsSize = ThumbnailView.getTopBottomEdgeInsetsSize()
|
||||
if Preferences.appearanceStyle == .titles {
|
||||
return max(ThumbnailView.iconSize(screen).height, ThumbnailTitleView.maxHeight()) + topBottomEdgeInsetsSize
|
||||
return max(ThumbnailView.iconSize(screen).height, labelHeight) + topBottomEdgeInsetsSize
|
||||
} else if Preferences.appearanceStyle == .appIcons {
|
||||
return ThumbnailView.iconSize(screen).height
|
||||
+ topBottomEdgeInsetsSize
|
||||
+ Appearance.intraCellPadding
|
||||
+ ThumbnailTitleView.maxHeight()
|
||||
+ labelHeight
|
||||
+ Appearance.intraCellPadding
|
||||
}
|
||||
return ThumbnailView.maxThumbnailHeight(screen).rounded(.down)
|
||||
|
||||
@@ -99,8 +99,8 @@ class ThumbnailsView: NSVisualEffectView {
|
||||
|
||||
func updateItemsAndLayout(_ screen: NSScreen) {
|
||||
let widthMax = ThumbnailsPanel.maxThumbnailsWidth(screen).rounded()
|
||||
if let (maxX, maxY) = layoutThumbnailViews(screen, widthMax) {
|
||||
layoutParentViews(screen, maxX, widthMax, maxY)
|
||||
if let (maxX, maxY, labelHeight) = layoutThumbnailViews(screen, widthMax) {
|
||||
layoutParentViews(screen, maxX, widthMax, maxY, labelHeight)
|
||||
if Preferences.alignThumbnails == .center {
|
||||
centerRows(maxX)
|
||||
}
|
||||
@@ -116,8 +116,9 @@ class ThumbnailsView: NSVisualEffectView {
|
||||
}
|
||||
}
|
||||
|
||||
private func layoutThumbnailViews(_ screen: NSScreen, _ widthMax: CGFloat) -> (CGFloat, CGFloat)? {
|
||||
let height = ThumbnailView.height(screen)
|
||||
private func layoutThumbnailViews(_ screen: NSScreen, _ widthMax: CGFloat) -> (CGFloat, CGFloat, CGFloat)? {
|
||||
let labelHeight = ThumbnailsView.recycledViews.first!.label.cell!.cellSize.height
|
||||
let height = ThumbnailView.height(screen, labelHeight)
|
||||
let isLeftToRight = App.shared.userInterfaceLayoutDirection == .leftToRight
|
||||
let startingX = isLeftToRight ? Appearance.interCellPadding : widthMax - Appearance.interCellPadding
|
||||
var currentX = startingX
|
||||
@@ -151,7 +152,7 @@ class ThumbnailsView: NSVisualEffectView {
|
||||
window.rowIndex = rows.count - 1
|
||||
}
|
||||
scrollView.documentView!.subviews = newViews
|
||||
return (maxX, maxY)
|
||||
return (maxX, maxY, labelHeight)
|
||||
}
|
||||
|
||||
private func needNewLine(_ projectedX: CGFloat, _ widthMax: CGFloat) -> Bool {
|
||||
@@ -172,7 +173,7 @@ class ThumbnailsView: NSVisualEffectView {
|
||||
App.shared.userInterfaceLayoutDirection == .leftToRight ? currentX : currentX - width
|
||||
}
|
||||
|
||||
private func layoutParentViews(_ screen: NSScreen, _ maxX: CGFloat, _ widthMax: CGFloat, _ maxY: CGFloat) {
|
||||
private func layoutParentViews(_ screen: NSScreen, _ maxX: CGFloat, _ widthMax: CGFloat, _ maxY: CGFloat, _ labelHeight: CGFloat) {
|
||||
let heightMax = ThumbnailsPanel.maxThumbnailsHeight(screen).rounded()
|
||||
|
||||
ThumbnailsView.thumbnailsWidth = min(maxX, widthMax)
|
||||
@@ -183,8 +184,8 @@ class ThumbnailsView: NSVisualEffectView {
|
||||
var originY = Appearance.windowPadding
|
||||
if Preferences.appearanceStyle == .appIcons {
|
||||
// If there is title under the icon on the last line, the height of the title needs to be subtracted.
|
||||
frameHeight = frameHeight - Appearance.intraCellPadding - ThumbnailTitleView.maxHeight()
|
||||
originY = originY - Appearance.intraCellPadding - ThumbnailTitleView.maxHeight()
|
||||
frameHeight = frameHeight - Appearance.intraCellPadding - labelHeight
|
||||
originY = originY - Appearance.intraCellPadding - labelHeight
|
||||
}
|
||||
frame.size = NSSize(width: frameWidth, height: frameHeight)
|
||||
|
||||
|
||||
Reference in new issue
Block a user