summaryrefslogtreecommitdiffstats
path: root/osdep/macOS_swift_extensions.swift
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2019-03-29 20:39:42 +0100
committerJan Ekström <jeebjp@gmail.com>2019-04-02 02:09:01 +0300
commit90e44d3ff2182749da8d7d255bef15fd99c18eee (patch)
treea20a2aa8bb26e8b9340aecb96cc9085b1475a2f9 /osdep/macOS_swift_extensions.swift
parent837e5058ff110247229057f7ab182a041d1c98b8 (diff)
downloadmpv-90e44d3ff2182749da8d7d255bef15fd99c18eee.tar.bz2
mpv-90e44d3ff2182749da8d7d255bef15fd99c18eee.tar.xz
cocoa-cb: add support for custom colored title bar
Diffstat (limited to 'osdep/macOS_swift_extensions.swift')
-rw-r--r--osdep/macOS_swift_extensions.swift13
1 files changed, 13 insertions, 0 deletions
diff --git a/osdep/macOS_swift_extensions.swift b/osdep/macOS_swift_extensions.swift
index 14d217f589..cc7438fd8c 100644
--- a/osdep/macOS_swift_extensions.swift
+++ b/osdep/macOS_swift_extensions.swift
@@ -56,3 +56,16 @@ extension NSScreen {
}
}
}
+
+extension NSColor {
+
+ convenience init(hex: String) {
+ let int = Int(hex.dropFirst(), radix: 16)
+ 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)
+ }
+}