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