summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/interface-changes.rst2
-rw-r--r--DOCS/man/options.rst73
-rw-r--r--osdep/macOS_mpv_helper.swift2
-rw-r--r--osdep/macosx_application.h2
-rw-r--r--osdep/macosx_application.m19
-rw-r--r--video/out/cocoa-cb/title_bar.swift149
-rw-r--r--video/out/cocoa_cb_common.swift8
7 files changed, 192 insertions, 63 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 160bc3679c..fc7a623af8 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -76,6 +76,8 @@ Interface changes
network streams should not freeze the player core (only playback in
uncached regions), and differing behavior should be reported as a bug.
If --demuxer-thread=no is used, there are no guarantees.
+ - remove `--macos-title-bar-style`, replaced by `--macos-title-bar-material`
+ and `--macos-title-bar-appearance`.
--- mpv 0.29.0 ---
- drop --opensles-sample-rate, as --audio-samplerate should be used if desired
- drop deprecated --videotoolbox-format, --ff-aid, --ff-vid, --ff-sid,
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index e3eb46495b..33fbc96a8d 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -4842,17 +4842,68 @@ The following video options are currently all specific to ``--vo=gpu`` and
OS X only.
-``--macos-title-bar-style=<dark|ultradark|light|mediumlight|auto>``
- Sets the styling of the title bar (default: dark).
- OS X and cocoa-cb only
-
- :dark: Dark title bar with vibrancy, a subtle blurring effect that
- dynamically blends the background (Video) into the title bar.
- :ultradark: Darker title bar with vibrancy (like QuickTime Player).
- :light: Bright title bar with vibrancy.
- :mediumlight: Less bright title bar with vibrancy.
- :auto: Detects the system settings and sets the title bar styling
- appropriately, either ultradark or mediumlight.
+``--macos-title-bar-appearance=<appearance>``
+ Sets the appearance of the title bar (default: auto). Not all combinations
+ of appearances and ``--macos-title-bar-material`` materials make sense or
+ are unique. Appearances that are not supported by you current macOS version
+ fall back to the default value.
+ macOS and cocoa-cb only
+
+ ``<appearance>`` can be one of the following:
+
+ :auto: Detects the system settings and sets the title
+ bar appearance appropriately. On macOS 10.14 it
+ also detects run time changes.
+ :aqua: The standard macOS Light appearance.
+ :darkAqua: The standard macOS Dark appearance. (macOS 10.14+)
+ :vibrantLight: Light vibrancy appearance with.
+ :vibrantDark: Dark vibrancy appearance with.
+ :aquaHighContrast: Light Accessibility appearance. (macOS 10.14+)
+ :darkAquaHighContrast: Dark Accessibility appearance. (macOS 10.14+)
+ :vibrantLightHighContrast: Light vibrancy Accessibility appearance.
+ (macOS 10.14+)
+ :vibrantDarkHighContrast: Dark vibrancy Accessibility appearance.
+ (macOS 10.14+)
+
+``--macos-title-bar-material=<material>``
+ Sets the material of the title bar (default: titlebar). All deprecated
+ materials should not be used on macOS 10.14+ because their functionality
+ is not guaranteed. Not all combinations of materials and
+ ``--macos-title-bar-appearance`` appearances make sense or are unique.
+ Materials that are not supported by you current macOS version fall back to
+ the default value.
+ macOS and cocoa-cb only
+
+ ``<material>`` can be one of the following:
+
+ :titlebar: The standard macOS titel bar material.
+ :selection: The standard macOS selection material.
+ :menu: The standard macOS menu material. (macOS 10.11+)
+ :popover: The standard macOS popover material. (macOS 10.11+)
+ :sidebar: The standard macOS sidebar material. (macOS 10.11+)
+ :headerView: The standard macOS header view material.
+ (macOS 10.14+)
+ :sheet: The standard macOS sheet material. (macOS 10.14+)
+ :windowBackground: The standard macOS window background material.
+ (macOS 10.14+)
+ :hudWindow: The standard macOS hudWindow material. (macOS 10.14+)
+ :fullScreen: The standard macOS full screen material.
+ (macOS 10.14+)
+ :toolTip: The standard macOS tool tip material. (macOS 10.14+)
+ :contentBackground: The standard macOS content background material.
+ (macOS 10.14+)
+ :underWindowBackground: The standard macOS under window background material.
+ (macOS 10.14+)
+ :underPageBackground: The standard macOS under page background material.
+ (deprecated in macOS 10.14+)
+ :dark: The standard macOS dark material.
+ (deprecated in macOS 10.14+)
+ :light: The standard macOS light material.
+ (macOS 10.14+)
+ :mediumLight: The standard macOS mediumLight material.
+ (macOS 10.11+, deprecated in macOS 10.14+)
+ :ultraDark: The standard macOS ultraDark material.
+ (macOS 10.11+ deprecated in macOS 10.14+)
``--macos-fs-animation-duration=<default|0-1000>``
Sets the fullscreen resize animation duration in ms (default: default).
diff --git a/osdep/macOS_mpv_helper.swift b/osdep/macOS_mpv_helper.swift
index 8ceada6d2e..b456c8d59e 100644
--- a/osdep/macOS_mpv_helper.swift
+++ b/osdep/macOS_mpv_helper.swift
@@ -57,6 +57,8 @@ class MPVHelper: NSObject {
mpv_observe_property(mpvHandle, 0, "border", MPV_FORMAT_FLAG)
mpv_observe_property(mpvHandle, 0, "keepaspect-window", MPV_FORMAT_FLAG)
mpv_observe_property(mpvHandle, 0, "macos-title-bar-style", MPV_FORMAT_STRING)
+ mpv_observe_property(mpvHandle, 0, "macos-title-bar-appearance", MPV_FORMAT_STRING)
+ mpv_observe_property(mpvHandle, 0, "macos-title-bar-material", MPV_FORMAT_STRING)
}
func initRender() {
diff --git a/osdep/macosx_application.h b/osdep/macosx_application.h
index 0301e49fcb..5f33a384f2 100644
--- a/osdep/macosx_application.h
+++ b/osdep/macosx_application.h
@@ -22,6 +22,8 @@
struct macos_opts {
int macos_title_bar_style;
+ int macos_title_bar_appearance;
+ int macos_title_bar_material;
int macos_fs_animation_duration;
int cocoa_cb_sw_renderer;
};
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index 086d51fef3..4653b7177d 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -43,14 +43,27 @@
#define OPT_BASE_STRUCT struct macos_opts
const struct m_sub_options macos_conf = {
.opts = (const struct m_option[]) {
- OPT_CHOICE("macos-title-bar-style", macos_title_bar_style, 0,
- ({"dark", 0}, {"ultradark", 1}, {"light", 2},
- {"mediumlight", 3}, {"auto", 4})),
+ OPT_CHOICE("macos-title-bar-appearance", macos_title_bar_appearance, 0,
+ ({"auto", 0}, {"aqua", 1}, {"darkAqua", 2},
+ {"vibrantLight", 3}, {"vibrantDark", 4},
+ {"aquaHighContrast", 5}, {"darkAquaHighContrast", 6},
+ {"vibrantLightHighContrast", 7},
+ {"vibrantDarkHighContrast", 8})),
+ OPT_CHOICE("macos-title-bar-material", macos_title_bar_material, 0,
+ ({"titlebar", 0}, {"selection", 1}, {"menu", 2},
+ {"popover", 3}, {"sidebar", 4}, {"headerView", 5},
+ {"sheet", 6}, {"windowBackground", 7}, {"hudWindow", 8},
+ {"fullScreen", 9}, {"toolTip", 10}, {"contentBackground", 11},
+ {"underWindowBackground", 12}, {"underPageBackground", 13},
+ {"dark", 14}, {"light", 15}, {"mediumLight", 16},
+ {"ultraDark", 17})),
OPT_CHOICE_OR_INT("macos-fs-animation-duration",
macos_fs_animation_duration, 0, 0, 1000,
({"default", -1})),
OPT_CHOICE("cocoa-cb-sw-renderer", cocoa_cb_sw_renderer, 0,
({"auto", -1}, {"no", 0}, {"yes", 1})),
+ OPT_REMOVED("macos-title-bar-style", "Split into --macos-title-bar-appearance "
+ "and --macos-title-bar-material"),
{0}
},
.size = sizeof(struct macos_opts),
diff --git a/video/out/cocoa-cb/title_bar.swift b/video/out/cocoa-cb/title_bar.swift
index fc8c208485..e9109d4a2b 100644
--- a/video/out/cocoa-cb/title_bar.swift
+++ b/video/out/cocoa-cb/title_bar.swift
@@ -34,6 +34,24 @@ class TitleBar: NSVisualEffectView {
get { return ([.closeButton, .miniaturizeButton, .zoomButton] as [NSWindowButton]).flatMap { cocoaCB.window.standardWindowButton($0) } }
}
+ override var material: NSVisualEffectView.Material {
+ get { return super.material }
+ 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
+ {
+ state = .active
+ } else {
+ state = .followsWindowActiveState
+ }
+
+ }
+ }
+
convenience init(frame: NSRect, window: NSWindow, cocoaCB ccb: CocoaCB) {
let f = NSMakeRect(0, frame.size.height - TitleBar.height,
frame.size.width, TitleBar.height)
@@ -43,11 +61,13 @@ class TitleBar: NSVisualEffectView {
blendingMode = .withinWindow
autoresizingMask = [.viewWidthSizable, .viewMinYMargin]
systemBar.alphaValue = 0
+ state = .followsWindowActiveState
window.contentView!.addSubview(self, positioned: .above, relativeTo: nil)
window.titlebarAppearsTransparent = true
window.styleMask.insert(.fullSizeContentView)
- setStyle(Int(mpv.macOpts!.macos_title_bar_style))
+ set(appearance: Int(mpv.macOpts!.macos_title_bar_appearance))
+ set(material: Int(mpv.macOpts!.macos_title_bar_material))
}
// catch these events so they are not propagated to the underlying view
@@ -72,55 +92,19 @@ class TitleBar: NSVisualEffectView {
}
}
- func setStyle(_ style: Any) {
- var effect: String
-
- if style is Int {
- switch style as! Int {
- case 4:
- effect = "auto"
- case 3:
- effect = "mediumlight"
- case 2:
- effect = "light"
- case 1:
- effect = "ultradark"
- case 0: fallthrough
- default:
- effect = "dark"
- }
+ func set(appearance: Any) {
+ if appearance is Int {
+ window!.appearance = appearanceFrom(string: String(appearance as! Int))
} else {
- effect = style as! String
+ window!.appearance = appearanceFrom(string: appearance as! String)
}
+ }
- switch effect {
- case "auto":
- if #available(macOS 10.14, *) {
- cocoaCB.window.appearance = nil
- material = .titlebar
- state = .followsWindowActiveState
- } else {
- let systemStyle = UserDefaults.standard.string(forKey: "AppleInterfaceStyle")
- effect = systemStyle == nil ? "mediumlight" : "ultradark"
- setStyle(effect)
- }
- case "mediumlight":
- cocoaCB.window.appearance = NSAppearance(named: NSAppearanceNameVibrantLight)
- material = .titlebar
- state = .followsWindowActiveState
- case "light":
- cocoaCB.window.appearance = NSAppearance(named: NSAppearanceNameVibrantLight)
- material = .light
- state = .active
- case "ultradark":
- cocoaCB.window.appearance = NSAppearance(named: NSAppearanceNameVibrantDark)
- material = .titlebar
- state = .followsWindowActiveState
- case "dark": fallthrough
- default:
- cocoaCB.window.appearance = NSAppearance(named: NSAppearanceNameVibrantDark)
- material = .dark
- state = .active
+ func set(material: Any) {
+ if material is Int {
+ self.material = materialFrom(string: String(material as! Int))
+ } else {
+ self.material = materialFrom(string: material as! String)
}
}
@@ -167,4 +151,75 @@ class TitleBar: NSVisualEffectView {
object: nil)
perform(#selector(hide), with: nil, afterDelay: 0.5)
}
+
+ func appearanceFrom(string: String) -> NSAppearance? {
+ switch string {
+ case "1", "aqua":
+ return NSAppearance(named: NSAppearanceNameAqua)
+ case "3", "vibrantLight":
+ return NSAppearance(named: NSAppearanceNameVibrantLight)
+ case "4", "vibrantDark":
+ return NSAppearance(named: NSAppearanceNameVibrantDark)
+ default: break
+ }
+
+ if #available(macOS 10.14, *) {
+ switch string {
+ case "2", "darkAqua":
+ return NSAppearance(named: NSAppearanceNameDarkAqua)
+ case "5", "aquaHighContrast":
+ return NSAppearance(named: NSAppearanceNameAccessibilityHighContrastAqua)
+ case "6", "darkAquaHighContrast":
+ return NSAppearance(named: NSAppearanceNameAccessibilityHighContrastDarkAqua)
+ case "7", "vibrantLightHighContrast":
+ return NSAppearance(named: NSAppearanceNameAccessibilityHighContrastVibrantLight)
+ case "8", "vibrantDarkHighContrast":
+ return NSAppearance(named: NSAppearanceNameAccessibilityHighContrastVibrantDark)
+ 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
+ }
+
+ 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
+ }
+ }
+
+ 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
+ }
+ }
+
+ return .titlebar
+ }
}
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift
index cf714bfa4d..a3fabd0324 100644
--- a/video/out/cocoa_cb_common.swift
+++ b/video/out/cocoa_cb_common.swift
@@ -513,9 +513,13 @@ class CocoaCB: NSObject {
if let data = MPVHelper.mpvFlagToBool(property.data) {
window.keepAspect = data
}
- case "macos-title-bar-style":
+ case "macos-title-bar-appearance":
if let data = MPVHelper.mpvStringArrayToString(property.data) {
- titleBar.setStyle(data)
+ titleBar.set(appearance: data)
+ }
+ case "macos-title-bar-material":
+ if let data = MPVHelper.mpvStringArrayToString(property.data) {
+ titleBar.set(material: data)
}
default:
break