1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-10 00:58:37 +00:00

Made the dock resize when Apps are removed

This commit is contained in:
willsunnn 2019-05-09 22:20:45 -07:00
parent 3bde1fe4b1
commit a81d6fc595
No known key found for this signature in database
GPG Key ID: CFC1084E3C414094
2 changed files with 14 additions and 3 deletions

View File

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>0.20.3</string>
<key>CFBundleVersion</key>
<string>220</string>
<string>223</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>

View File

@ -32,6 +32,9 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
convenience override init(identifier: NSTouchBarItem.Identifier) {
self.init(identifier: identifier, autoResize: false)
}
static var iconWidth = 36
static var spacingWidth = 2
init(identifier: NSTouchBarItem.Identifier, autoResize: Bool) {
super.init(identifier: identifier)
@ -42,8 +45,8 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
scrubber.dataSource = self
scrubber.mode = .free // .fixed
let layout = NSScrubberFlowLayout()
layout.itemSize = NSSize(width: 36, height: 32)
layout.itemSpacing = 2
layout.itemSize = NSSize(width: AppScrubberTouchBarItem.iconWidth, height: 32)
layout.itemSpacing = CGFloat(AppScrubberTouchBarItem.spacingWidth)
scrubber.scrubberLayout = layout
scrubber.selectionBackgroundStyle = .roundedBackground
scrubber.showsAdditionalContentIndicators = true
@ -84,10 +87,18 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
applications = newApplications
applications += getDockPersistentAppsList()
updateSize()
scrubber.reloadData()
scrubber.selectedIndex = index ?? 0
}
func updateSize() {
if self.autoResize {
let width = (AppScrubberTouchBarItem.iconWidth + AppScrubberTouchBarItem.spacingWidth) * self.applications.count - AppScrubberTouchBarItem.spacingWidth
self.setWidth(value: CGFloat(width))
}
}
public func numberOfItems(for _: NSScrubber) -> Int {
return applications.count