summaryrefslogtreecommitdiffstats
path: root/video/out/mac/title_bar.swift
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/mac/title_bar.swift')
-rw-r--r--video/out/mac/title_bar.swift114
1 files changed, 41 insertions, 73 deletions
diff --git a/video/out/mac/title_bar.swift b/video/out/mac/title_bar.swift
index 623fe8f57d..b274100dcf 100644
--- a/video/out/mac/title_bar.swift
+++ b/video/out/mac/title_bar.swift
@@ -19,7 +19,7 @@ import Cocoa
class TitleBar: NSVisualEffectView {
unowned var common: Common
- var mpv: MPVHelper? { get { return common.mpv } }
+ var option: OptionHelper { get { return common.option } }
var systemBar: NSView? {
get { return common.window?.standardWindowButton(.closeButton)?.superview }
@@ -36,10 +36,8 @@ class TitleBar: NSVisualEffectView {
set {
super.material = newValue
// fix for broken deprecated materials
- if material == .light || material == .dark {
- state = .active
- } else if #available(macOS 10.11, *),
- material == .mediumLight || material == .ultraDark
+ if material == .light || material == .dark || material == .mediumLight ||
+ material == .ultraDark
{
state = .active
} else {
@@ -51,7 +49,7 @@ class TitleBar: NSVisualEffectView {
init(frame: NSRect, window: NSWindow, common com: Common) {
let f = NSMakeRect(0, frame.size.height - TitleBar.height,
- frame.size.width, TitleBar.height)
+ frame.size.width, TitleBar.height + 1)
common = com
super.init(frame: f)
buttons.forEach { $0.isHidden = true }
@@ -66,9 +64,9 @@ class TitleBar: NSVisualEffectView {
window.contentView?.addSubview(self, positioned: .above, relativeTo: nil)
window.titlebarAppearsTransparent = true
window.styleMask.insert(.fullSizeContentView)
- set(appearance: Int(mpv?.macOpts.macos_title_bar_appearance ?? 0))
- set(material: Int(mpv?.macOpts.macos_title_bar_material ?? 0))
- set(color: mpv?.macOpts.macos_title_bar_color ?? "#00000000")
+ set(appearance: Int(option.mac.macos_title_bar_appearance))
+ set(material: Int(option.mac.macos_title_bar_material))
+ set(color: option.mac.macos_title_bar_color)
}
required init?(coder: NSCoder) {
@@ -151,7 +149,7 @@ class TitleBar: NSVisualEffectView {
}
}
- @objc func hide() {
+ @objc func hide(_ duration: TimeInterval = 0.20) {
guard let window = common.window else { return }
if window.isInFullscreen && !window.isAnimating {
alphaValue = 0
@@ -159,7 +157,7 @@ class TitleBar: NSVisualEffectView {
return
}
NSAnimationContext.runAnimationGroup({ (context) -> Void in
- context.duration = 0.20
+ context.duration = duration
systemBar?.animator().alphaValue = 0
animator().alphaValue = 0
}, completionHandler: {
@@ -179,77 +177,47 @@ class TitleBar: NSVisualEffectView {
switch string {
case "1", "aqua":
return NSAppearance(named: .aqua)
+ case "2", "darkAqua":
+ return NSAppearance(named: .darkAqua)
case "3", "vibrantLight":
return NSAppearance(named: .vibrantLight)
case "4", "vibrantDark":
return NSAppearance(named: .vibrantDark)
- default: break
- }
-
- if #available(macOS 10.14, *) {
- switch string {
- case "2", "darkAqua":
- return NSAppearance(named: .darkAqua)
- case "5", "aquaHighContrast":
- return NSAppearance(named: .accessibilityHighContrastAqua)
- case "6", "darkAquaHighContrast":
- return NSAppearance(named: .accessibilityHighContrastDarkAqua)
- case "7", "vibrantLightHighContrast":
- return NSAppearance(named: .accessibilityHighContrastVibrantLight)
- case "8", "vibrantDarkHighContrast":
- return NSAppearance(named: .accessibilityHighContrastVibrantDark)
- case "0", "auto": fallthrough
- default:
-#if HAVE_MACOS_10_14_FEATURES
- return nil
-#else
- break
-#endif
- }
+ case "5", "aquaHighContrast":
+ return NSAppearance(named: .accessibilityHighContrastAqua)
+ case "6", "darkAquaHighContrast":
+ return NSAppearance(named: .accessibilityHighContrastDarkAqua)
+ case "7", "vibrantLightHighContrast":
+ return NSAppearance(named: .accessibilityHighContrastVibrantLight)
+ case "8", "vibrantDarkHighContrast":
+ return NSAppearance(named: .accessibilityHighContrastVibrantDark)
+ case "0", "auto": fallthrough
+ default:
+ return nil
}
-
- let style = UserDefaults.standard.string(forKey: "AppleInterfaceStyle")
- return appearanceFrom(string: style == nil ? "aqua" : "vibrantDark")
}
func materialFrom(string: String) -> NSVisualEffectView.Material {
switch string {
- case "1", "selection": return .selection
- case "0", "titlebar": return .titlebar
- case "14", "dark": return .dark
- case "15", "light": return .light
- default: break
+ case "0", "titlebar": return .titlebar
+ case "1", "selection": return .selection
+ case "2,", "menu": return .menu
+ case "3", "popover": return .popover
+ case "4", "sidebar": return .sidebar
+ case "5,", "headerView": return .headerView
+ case "6", "sheet": return .sheet
+ case "7", "windowBackground": return .windowBackground
+ case "8", "hudWindow": return .hudWindow
+ case "9", "fullScreen": return .fullScreenUI
+ case "10", "toolTip": return .toolTip
+ case "11", "contentBackground": return .contentBackground
+ case "12", "underWindowBackground": return .underWindowBackground
+ case "13", "underPageBackground": return .underPageBackground
+ case "14", "dark": return .dark
+ case "15", "light": return .light
+ case "16", "mediumLight": return .mediumLight
+ case "17", "ultraDark": return .ultraDark
+ default: return .titlebar
}
-
-#if HAVE_MACOS_10_11_FEATURES
- if #available(macOS 10.11, *) {
- switch string {
- case "2,", "menu": return .menu
- case "3", "popover": return .popover
- case "4", "sidebar": return .sidebar
- case "16", "mediumLight": return .mediumLight
- case "17", "ultraDark": return .ultraDark
- default: break
- }
- }
-#endif
-#if HAVE_MACOS_10_14_FEATURES
- if #available(macOS 10.14, *) {
- switch string {
- case "5,", "headerView": return .headerView
- case "6", "sheet": return .sheet
- case "7", "windowBackground": return .windowBackground
- case "8", "hudWindow": return .hudWindow
- case "9", "fullScreen": return .fullScreenUI
- case "10", "toolTip": return .toolTip
- case "11", "contentBackground": return .contentBackground
- case "12", "underWindowBackground": return .underWindowBackground
- case "13", "underPageBackground": return .underPageBackground
- default: break
- }
- }
-#endif
-
- return .titlebar
}
}