Unified · Split
| @@ -47,18 +47,6 @@ extension NSScreen { · 46 unmodified lines | |||
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | extension NSColor { | ||
| 51 | convenience init(hex: String) { | ||
| 52 | let int = Int(hex.dropFirst(), radix: 16) ?? 0 | ||
| 53 | let alpha = CGFloat((int >> 24) & 0x000000FF)/255 | ||
| 54 | let red = CGFloat((int >> 16) & 0x000000FF)/255 | ||
| 55 | let green = CGFloat((int >> 8) & 0x000000FF)/255 | ||
| 56 | let blue = CGFloat((int) & 0x000000FF)/255 | ||
| 57 | |||
| 58 | self.init(calibratedRed: red, green: green, blue: blue, alpha: alpha) | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | extension NSEvent.ModifierFlags { | 50 | extension NSEvent.ModifierFlags { |
| 63 | public static var optionLeft: NSEvent.ModifierFlags = .init(rawValue: UInt(NX_DEVICELALTKEYMASK)) | 51 | public static var optionLeft: NSEvent.ModifierFlags = .init(rawValue: UInt(NX_DEVICELALTKEYMASK)) |
| 64 | public static var optionRight: NSEvent.ModifierFlags = .init(rawValue: UInt(NX_DEVICERALTKEYMASK)) | 52 | public static var optionRight: NSEvent.ModifierFlags = .init(rawValue: UInt(NX_DEVICERALTKEYMASK)) |
| @@ -132,18 +132,11 @@ class TitleBar: NSVisualEffectView { · 131 unmodified lines | |||
| 132 | }() | 132 | }() |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | func set(color: Any) { | 135 | func set(color: m_color) { |
| 136 | if color is String { | 136 | layer?.backgroundColor = NSColor(calibratedRed: CGFloat(color.r)/255, |
| 137 | layer?.backgroundColor = NSColor(hex: color as? String ?? "#00000000").cgColor | 137 | green: CGFloat(color.g)/255, |
| 138 | } else { | 138 | blue: CGFloat(color.b)/255, |
| 139 | let col = color as? m_color ?? m_color(r: 0, g: 0, b: 0, a: 0) | 139 | alpha: CGFloat(color.a)/255).cgColor |
| 140 | let red = CGFloat(col.r)/255 | ||
| 141 | let green = CGFloat(col.g)/255 | ||
| 142 | let blue = CGFloat(col.b)/255 | ||
| 143 | let alpha = CGFloat(col.a)/255 | ||
| 144 | layer?.backgroundColor = NSColor(calibratedRed: red, green: green, | ||
| 145 | blue: blue, alpha: alpha).cgColor | ||
| 146 | } | ||
| 147 | } | 140 | } |
| 148 | 141 | ||
| 149 | func show() { | 142 | func show() { |