NotifierUI // Share changes across releases.

This commit is contained in:
ShikiSuen 2023-09-24 19:50:39 +08:00
parent 6b544c571d
commit 711767df93
1 changed files with 20 additions and 6 deletions

View File

@ -71,9 +71,15 @@ public class Notifier: NSWindowController {
.paragraphStyle: paraStyle, .paragraphStyle: paraStyle,
] ]
let attrString = NSMutableAttributedString(string: messageArray[0], attributes: attrTitle) let attrString = NSMutableAttributedString(string: messageArray[0], attributes: attrTitle)
let foregroundColor: NSColor = {
if #available(macOS 10.10, *) {
return NSColor.secondaryLabelColor
}
return NSColor.controlTextColor
}()
let attrAlt: [NSAttributedString.Key: Any] = [ let attrAlt: [NSAttributedString.Key: Any] = [
.kern: 0, .kern: 0,
.foregroundColor: NSColor.secondaryLabelColor, .foregroundColor: foregroundColor,
.font: NSFont.systemFont(ofSize: kSmallFontSize), .font: NSFont.systemFont(ofSize: kSmallFontSize),
.paragraphStyle: paraStyle, .paragraphStyle: paraStyle,
] ]
@ -99,9 +105,15 @@ public class Notifier: NSWindowController {
windowRect.origin.y = screenRect.maxY - windowRect.height - 10 windowRect.origin.y = screenRect.maxY - windowRect.height - 10
let styleMask: NSWindow.StyleMask = [.borderless] let styleMask: NSWindow.StyleMask = [.borderless]
let transparentVisualEffect = NSVisualEffectView() let transparentVisualEffect: NSView = {
transparentVisualEffect.blendingMode = .behindWindow if #available(macOS 10.10, *) {
transparentVisualEffect.state = .active let transparentVisualEffect = NSVisualEffectView()
transparentVisualEffect.blendingMode = .behindWindow
transparentVisualEffect.state = .active
return transparentVisualEffect
}
return .init()
}()
let theWindow = NSWindow( let theWindow = NSWindow(
contentRect: windowRect, styleMask: styleMask, backing: .buffered, defer: false contentRect: windowRect, styleMask: styleMask, backing: .buffered, defer: false
@ -112,8 +124,10 @@ public class Notifier: NSWindowController {
theWindow.hasShadow = true theWindow.hasShadow = true
theWindow.backgroundColor = .textBackgroundColor theWindow.backgroundColor = .textBackgroundColor
theWindow.title = "" theWindow.title = ""
theWindow.titlebarAppearsTransparent = true if #available(macOS 10.10, *) {
theWindow.titleVisibility = .hidden theWindow.titlebarAppearsTransparent = true
theWindow.titleVisibility = .hidden
}
theWindow.showsToolbarButton = false theWindow.showsToolbarButton = false
theWindow.standardWindowButton(NSWindow.ButtonType.zoomButton)?.isHidden = true theWindow.standardWindowButton(NSWindow.ButtonType.zoomButton)?.isHidden = true
theWindow.standardWindowButton(NSWindow.ButtonType.miniaturizeButton)?.isHidden = true theWindow.standardWindowButton(NSWindow.ButtonType.miniaturizeButton)?.isHidden = true