// // 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 widgets: [TouchBarWidget] = [] 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 } }