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