mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-10 17:08:39 +00:00
Merge pull request #32 from ad/master
Background color parameter moved to CustomButtonTouchBarItem
This commit is contained in:
commit
41a859aea3
@ -15,7 +15,6 @@ class BatteryBarItem: CustomButtonTouchBarItem {
|
||||
init(identifier: NSTouchBarItem.Identifier, onTap: @escaping () -> (), onLongTap: @escaping () -> ()) {
|
||||
super.init(identifier: identifier, title: " ", onTap: onTap, onLongTap: onLongTap)
|
||||
self.view = button
|
||||
button.bezelColor = .clear
|
||||
|
||||
let batteryInfo = BatteryInfo(button: button)
|
||||
batteryInfo.start()
|
||||
|
||||
@ -50,7 +50,6 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
|
||||
super.init(identifier: identifier, title: "⏳", onTap: onTap, onLongTap: onLongTap)
|
||||
|
||||
button.bezelColor = .clear
|
||||
self.view = button
|
||||
|
||||
timer = Timer.scheduledTimer(timeInterval: interval, target: self, selector: #selector(updateCurrency), userInfo: nil, repeats: true)
|
||||
|
||||
@ -16,12 +16,13 @@ class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegat
|
||||
private var singleClick: NSClickGestureRecognizer!
|
||||
private var longClick: NSPressGestureRecognizer!
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, title: String, onTap callback: @escaping () -> (), onLongTap callbackLong: @escaping () -> ()) {
|
||||
init(identifier: NSTouchBarItem.Identifier, title: String, onTap callback: @escaping () -> (), onLongTap callbackLong: @escaping () -> (), bezelColor: NSColor? = .clear) {
|
||||
self.tapClosure = callback
|
||||
self.longTapClosure = callbackLong
|
||||
|
||||
super.init(identifier: identifier)
|
||||
button = NSButton(title: title, target: self, action: nil)
|
||||
button.bezelColor = bezelColor
|
||||
button.title = title
|
||||
self.view = button
|
||||
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
import Cocoa
|
||||
|
||||
class TimeTouchBarItem: NSCustomTouchBarItem {
|
||||
class TimeTouchBarItem: CustomButtonTouchBarItem {
|
||||
private let dateFormatter = DateFormatter()
|
||||
private var timer: Timer!
|
||||
private let button = NSButton(title: "", target: nil, action: nil)
|
||||
// private let button = NSButton(title: "", target: nil, action: nil)
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, formatTemplate: String) {
|
||||
init(identifier: NSTouchBarItem.Identifier, formatTemplate: String, onTap: @escaping () -> (), onLongTap: @escaping () -> ()) {
|
||||
dateFormatter.setLocalizedDateFormatFromTemplate(formatTemplate)
|
||||
super.init(identifier: identifier)
|
||||
super.init(identifier: identifier, title: " ", onTap: onTap, onLongTap: onLongTap)
|
||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTime), userInfo: nil, repeats: true)
|
||||
self.view = button
|
||||
button.bezelColor = .clear
|
||||
updateTime()
|
||||
}
|
||||
|
||||
|
||||
@ -165,11 +165,11 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
var barItem: NSTouchBarItem!
|
||||
switch item.type {
|
||||
case .staticButton(title: let title):
|
||||
barItem = CustomButtonTouchBarItem(identifier: identifier, title: title, onTap: action, onLongTap: longAction)
|
||||
barItem = CustomButtonTouchBarItem(identifier: identifier, title: title, onTap: action, onLongTap: longAction, bezelColor: NSColor.controlColor)
|
||||
case .appleScriptTitledButton(source: let source, refreshInterval: let interval):
|
||||
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval, onTap: action, onLongTap: longAction)
|
||||
case .timeButton(formatTemplate: let template):
|
||||
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template)
|
||||
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template, onTap: action, onLongTap: longAction)
|
||||
case .battery():
|
||||
barItem = BatteryBarItem(identifier: identifier, onTap: action, onLongTap: longAction)
|
||||
case .dock:
|
||||
|
||||
@ -45,7 +45,6 @@ class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
||||
|
||||
super.init(identifier: identifier, title: "⏳", onTap: onTap, onLongTap: onLongTap)
|
||||
|
||||
button.bezelColor = .clear
|
||||
self.view = button
|
||||
|
||||
let status = CLLocationManager.authorizationStatus()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user