Skip to content

Commit

Permalink
Allow change of of a group button width (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParsleyJ authored Jun 17, 2020
1 parent aa69d5f commit a65613a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions MTMR/TouchBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
}

blacklistAppIdentifiers = AppSettings.blacklistedAppIds

NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didLaunchApplicationNotification, object: nil)
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didTerminateApplicationNotification, object: nil)
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didActivateApplicationNotification, object: nil)
Expand All @@ -123,20 +123,20 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
let centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
items[identifier]
})

let centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
let scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)

touchBar.delegate = self
touchBar.defaultItemIdentifiers = [basicViewIdentifier]

let leftItems = leftIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
items[identifier]
})
let rightItems = rightIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
items[identifier]
})

basicView = BasicView(identifier: basicViewIdentifier, items:leftItems + [scrollArea] + rightItems, swipeItems: swipeItems)
basicView?.legacyGesturesEnabled = AppSettings.multitouchGestures

Expand Down Expand Up @@ -428,6 +428,12 @@ extension NSCustomTouchBarItem: CanSetWidth {
}
}

extension NSPopoverTouchBarItem: CanSetWidth {
func setWidth(value: CGFloat) {
view?.widthAnchor.constraint(equalToConstant: value).isActive = true
}
}

extension BarItemDefinition {
var align: Align {
if case let .align(result)? = additionalParameters[.align] {
Expand Down

0 comments on commit a65613a

Please sign in to comment.