Skip to content

Commit a65613a

Browse files
authored
Allow change of of a group button width (#336)
1 parent aa69d5f commit a65613a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

MTMR/TouchBarController.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
100100
}
101101

102102
blacklistAppIdentifiers = AppSettings.blacklistedAppIds
103-
103+
104104
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didLaunchApplicationNotification, object: nil)
105105
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didTerminateApplicationNotification, object: nil)
106106
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didActivateApplicationNotification, object: nil)
@@ -123,20 +123,20 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
123123
let centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
124124
items[identifier]
125125
})
126-
126+
127127
let centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
128128
let scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)
129129

130130
touchBar.delegate = self
131131
touchBar.defaultItemIdentifiers = [basicViewIdentifier]
132-
132+
133133
let leftItems = leftIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
134134
items[identifier]
135135
})
136136
let rightItems = rightIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
137137
items[identifier]
138138
})
139-
139+
140140
basicView = BasicView(identifier: basicViewIdentifier, items:leftItems + [scrollArea] + rightItems, swipeItems: swipeItems)
141141
basicView?.legacyGesturesEnabled = AppSettings.multitouchGestures
142142

@@ -428,6 +428,12 @@ extension NSCustomTouchBarItem: CanSetWidth {
428428
}
429429
}
430430

431+
extension NSPopoverTouchBarItem: CanSetWidth {
432+
func setWidth(value: CGFloat) {
433+
view?.widthAnchor.constraint(equalToConstant: value).isActive = true
434+
}
435+
}
436+
431437
extension BarItemDefinition {
432438
var align: Align {
433439
if case let .align(result)? = additionalParameters[.align] {

0 commit comments

Comments
 (0)