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

Fixed a bug where the dock would not change size after the first time due to conflicting constraints

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

View File

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

View File

@ -18,6 +18,7 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
private let maxTicks: Int = 20
private var lastSelected: Int = 0
private var autoResize: Bool = false
private var widthConstraint: NSLayoutConstraint?
private var persistentAppIdentifiers: [String] = []
private var runningAppsIdentifiers: [String] = []
@ -87,16 +88,21 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
applications = newApplications
applications += getDockPersistentAppsList()
updateSize()
scrubber.reloadData()
updateSize()
scrubber.selectedIndex = index ?? 0
}
func updateSize() {
if self.autoResize {
if let constraint: NSLayoutConstraint = self.widthConstraint {
constraint.isActive = false
self.scrubber.removeConstraint(constraint)
}
let width = (AppScrubberTouchBarItem.iconWidth + AppScrubberTouchBarItem.spacingWidth) * self.applications.count - AppScrubberTouchBarItem.spacingWidth
self.setWidth(value: CGFloat(width))
self.widthConstraint = self.scrubber.widthAnchor.constraint(equalToConstant: CGFloat(width))
self.widthConstraint!.isActive = true
}
}