fix: scale app red badge with app icon size (closes #559)

This commit is contained in:
Louis Pontoise committed 2022-12-28 19:33:08 +01:00
1 parent 6526caae30
commit 4b2f134f32
2 files changed
+10 -4

No files matched your search

@@ -71,10 +71,10 @@ class ThumbnailFontIconView: ThumbnailTitleView {
}
class ThumbnailFilledFontIconView: NSView {
convenience init(_ thumbnailFontIconView: ThumbnailFontIconView, _ backgroundColor: NSColor) {
convenience init(_ thumbnailFontIconView: ThumbnailFontIconView, _ backgroundColor: NSColor, _ size: CGFloat) {
self.init(frame: .zero)
translatesAutoresizingMaskIntoConstraints = false
let backgroundView = ThumbnailFontIconView(.filledCircled, nil, 14 - 2, backgroundColor, nil)
let backgroundView = ThumbnailFontIconView(.filledCircled, nil, size - 2, backgroundColor, nil)
addSubview(backgroundView)
addSubview(thumbnailFontIconView, positioned: .above, relativeTo: nil)
backgroundView.frame.origin = CGPoint(x: backgroundView.frame.origin.x + 1, y: backgroundView.frame.origin.y + 1)
+8 -2
View File
@@ -11,7 +11,7 @@ class ThumbnailView: NSStackView {
var minimizedIcon = ThumbnailFontIconView(.circledMinusSign, NSLocalizedString("Window is minimized", comment: ""))
var hiddenIcon = ThumbnailFontIconView(.circledSlashSign, NSLocalizedString("App is hidden", comment: ""))
var spaceIcon = ThumbnailFontIconView(.circledNumber0, nil)
var dockLabelIcon = ThumbnailFilledFontIconView(ThumbnailFontIconView(.filledCircledNumber0, nil, 14, NSColor(srgbRed: 1, green: 0.30, blue: 0.25, alpha: 1), nil), NSColor.white)
var dockLabelIcon = ThumbnailFilledFontIconView(ThumbnailFontIconView(.filledCircledNumber0, nil, dockLabelLabelSize(), NSColor(srgbRed: 1, green: 0.30, blue: 0.25, alpha: 1), nil), NSColor.white, dockLabelLabelSize())
var quitIcon = TrafficLightButton(.quit, NSLocalizedString("Quit app", comment: ""), windowsControlSize)
var closeIcon = TrafficLightButton(.close, NSLocalizedString("Close window", comment: ""), windowsControlSize)
var minimizeIcon = TrafficLightButton(.miniaturize, NSLocalizedString("Minimize/Deminimize window", comment: ""), windowsControlSize)
@@ -206,7 +206,9 @@ class ThumbnailView: NSStackView {
} else {
view.setNumber(dockLabel, true)
}
dockLabelIcon.setFrameOrigin(NSPoint(x: appIcon.frame.maxX - dockLabelIcon.fittingSize.width - 1, y: appIcon.frame.maxY - dockLabelIcon.fittingSize.height + 4))
dockLabelIcon.setFrameOrigin(NSPoint(
x: appIcon.frame.maxX - (dockLabelIcon.fittingSize.width / 2) - (appIcon.frame.width / 7),
y: appIcon.frame.maxY - (dockLabelIcon.fittingSize.height / 2) - (appIcon.frame.height / 5)))
view.setAccessibilityLabel(getAccessibilityTextForBadge(dockLabel))
return true
}
@@ -277,6 +279,10 @@ class ThumbnailView: NSStackView {
}
}
static func dockLabelLabelSize() -> CGFloat {
return (max(Double(Preferences.defaultValues["iconSize"]!)!, Preferences.iconSize) * 0.43).rounded()
}
static func makeShadow(_ color: NSColor) -> NSShadow {
let shadow = NSShadow()
shadow.shadowColor = color