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:
parent
3bde1fe4b1
commit
a81d6fc595
@ -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>
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user