From cd9fa6daf0be35d90ecea7dfb1204293cd84d2ee Mon Sep 17 00:00:00 2001 From: der richter Date: Thu, 26 Dec 2024 15:59:57 +0100 Subject: [PATCH] mac/title: remove old libmpv color setter fallback --- osdep/mac/swift_extensions.swift | 12 ------------ video/out/mac/title_bar.swift | 17 +++++------------ 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/osdep/mac/swift_extensions.swift b/osdep/mac/swift_extensions.swift index 8f3de98802b2a..81489f9a840ca 100644 --- a/osdep/mac/swift_extensions.swift +++ b/osdep/mac/swift_extensions.swift @@ -47,18 +47,6 @@ extension NSScreen { } } -extension NSColor { - convenience init(hex: String) { - let int = Int(hex.dropFirst(), radix: 16) ?? 0 - let alpha = CGFloat((int >> 24) & 0x000000FF)/255 - let red = CGFloat((int >> 16) & 0x000000FF)/255 - let green = CGFloat((int >> 8) & 0x000000FF)/255 - let blue = CGFloat((int) & 0x000000FF)/255 - - self.init(calibratedRed: red, green: green, blue: blue, alpha: alpha) - } -} - extension NSEvent.ModifierFlags { public static var optionLeft: NSEvent.ModifierFlags = .init(rawValue: UInt(NX_DEVICELALTKEYMASK)) public static var optionRight: NSEvent.ModifierFlags = .init(rawValue: UInt(NX_DEVICERALTKEYMASK)) diff --git a/video/out/mac/title_bar.swift b/video/out/mac/title_bar.swift index c776a66ec4aec..5d31b1615c4bc 100644 --- a/video/out/mac/title_bar.swift +++ b/video/out/mac/title_bar.swift @@ -132,18 +132,11 @@ class TitleBar: NSVisualEffectView { }() } - func set(color: Any) { - if color is String { - layer?.backgroundColor = NSColor(hex: color as? String ?? "#00000000").cgColor - } else { - let col = color as? m_color ?? m_color(r: 0, g: 0, b: 0, a: 0) - let red = CGFloat(col.r)/255 - let green = CGFloat(col.g)/255 - let blue = CGFloat(col.b)/255 - let alpha = CGFloat(col.a)/255 - layer?.backgroundColor = NSColor(calibratedRed: red, green: green, - blue: blue, alpha: alpha).cgColor - } + func set(color: m_color) { + layer?.backgroundColor = NSColor(calibratedRed: CGFloat(color.r)/255, + green: CGFloat(color.g)/255, + blue: CGFloat(color.b)/255, + alpha: CGFloat(color.a)/255).cgColor } func show() {