47 lines
1.1 KiB
Swift
47 lines
1.1 KiB
Swift
|
//
|
||
|
// TouchBarController.swift
|
||
|
// Underbar
|
||
|
//
|
||
|
// Created by Shadowfacts on 7/13/19.
|
||
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import Cocoa
|
||
|
|
||
|
class TouchBarController: NSObject, NSTouchBarDelegate {
|
||
|
let touchBar = NSTouchBar()
|
||
|
|
||
|
var isVisible = false
|
||
|
|
||
|
override init() {
|
||
|
super.init()
|
||
|
|
||
|
touchBar.delegate = self
|
||
|
}
|
||
|
|
||
|
@objc func toggle() {
|
||
|
if isVisible {
|
||
|
minimize()
|
||
|
} else {
|
||
|
present()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func present() {
|
||
|
NSTouchBar.presentSystemModalTouchBar(touchBar, placement: 1, systemTrayItemIdentifier: .underbar)
|
||
|
isVisible = true
|
||
|
DFRElementSetControlStripPresenceForIdentifier(.underbar, true)
|
||
|
}
|
||
|
|
||
|
func minimize() {
|
||
|
NSTouchBar.minimizeSystemModalTouchBar(touchBar)
|
||
|
isVisible = false
|
||
|
DFRElementSetControlStripPresenceForIdentifier(.underbar, true)
|
||
|
}
|
||
|
|
||
|
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
}
|