Skip to content

Commit

Permalink
mac/title: remove old libmpv color setter fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Akemi committed Dec 28, 2024
1 parent 51af3ca commit cd9fa6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
12 changes: 0 additions & 12 deletions osdep/mac/swift_extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
17 changes: 5 additions & 12 deletions video/out/mac/title_bar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit cd9fa6d

Please sign in to comment.