1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-10 17:08:39 +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> <key>CFBundleShortVersionString</key>
<string>0.20.3</string> <string>0.20.3</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>220</string> <string>223</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string> <string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>

View File

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