Unified · Split
| @@ -208,14 +208,9 @@ class TouchBar: NSTouchBar, NSTouchBarDelegate { · 207 unmodified lines | |||
| 208 | guard let config = configs[.seekBar], let slider = config.view as? NSSlider else { return } | 208 | guard let config = configs[.seekBar], let slider = config.view as? NSSlider else { return } |
| 209 | if !(config.item?.isVisible ?? false) { return } | 209 | if !(config.item?.isVisible ?? false) { return } |
| 210 | 210 | ||
| 211 | if duration <= 0 { | 211 | slider.isEnabled = duration > 0 |
| 212 | slider.isEnabled = false | 212 | if !slider.isHighlighted { |
| 213 | slider.doubleValue = 0 | 213 | slider.doubleValue = slider.isEnabled ? (position / duration) * 100 : 0 |
| 214 | } else { | ||
| 215 | slider.isEnabled = true | ||
| 216 | if (!slider.isHighlighted) { | ||
| 217 | slider.doubleValue = (position / duration) * 100 | ||
| 218 | } | ||
| 219 | } | 214 | } |
| 220 | } | 215 | } |
| 221 | 216 | ||
| @@ -224,14 +219,9 @@ class TouchBar: NSTouchBar, NSTouchBarDelegate { · 2 unmodified lines | |||
| 224 | if !(config.item?.isVisible ?? false) { return } | 219 | if !(config.item?.isVisible ?? false) { return } |
| 225 | 220 | ||
| 226 | removeConstraintFor(identifier: .timeLeft) | 221 | removeConstraintFor(identifier: .timeLeft) |
| 227 | if duration <= 0 { | 222 | text.stringValue = duration > 0 ? "-" + format(time: Int(floor(duration) - floor(position))) : "" |
| 228 | text.stringValue = "" | 223 | if !text.stringValue.isEmpty { |
| 229 | } else { | 224 | applyConstraintFrom(string: "-" + format(time: Int(duration)), identifier: .timeLeft) |
| 230 | let left = Int(floor(duration) - floor(position)) | ||
| 231 | let leftFormat = format(time: left) | ||
| 232 | let durationFormat = format(time: Int(duration)) | ||
| 233 | text.stringValue = "-\(leftFormat)" | ||
| 234 | applyConstraintFrom(string: "-\(durationFormat)", identifier: .timeLeft) | ||
| 235 | } | 225 | } |
| 236 | } | 226 | } |
| 237 | 227 | ||
| @@ -241,22 +231,13 @@ class TouchBar: NSTouchBar, NSTouchBarDelegate { · 3 unmodified lines | |||
| 241 | 231 | ||
| 242 | text.stringValue = format(time: Int(floor(position))) | 232 | text.stringValue = format(time: Int(floor(position))) |
| 243 | removeConstraintFor(identifier: .currentPosition) | 233 | removeConstraintFor(identifier: .currentPosition) |
| 244 | if duration <= 0 { | 234 | applyConstraintFrom(string: format(time: Int(duration > 0 ? duration : position)), identifier: .currentPosition) |
| 245 | applyConstraintFrom(string: format(time: Int(position)), identifier: .currentPosition) | ||
| 246 | } else { | ||
| 247 | applyConstraintFrom(string: format(time: Int(duration)), identifier: .currentPosition) | ||
| 248 | } | ||
| 249 | } | 235 | } |
| 250 | 236 | ||
| 251 | func updatePlayButton() { | 237 | func updatePlayButton() { |
| 252 | guard let config = configs[.play], let button = config.view as? NSButton else { return } | 238 | guard let config = configs[.play], let button = config.view as? NSButton else { return } |
| 253 | if !isVisible || !(config.item?.isVisible ?? false) { return } | 239 | if !isVisible || !(config.item?.isVisible ?? false) { return } |
| 254 | 240 | button.image = isPaused ? configs[.play]?.imageAlt : configs[.play]?.image | |
| 255 | if isPaused { | ||
| 256 | button.image = configs[.play]?.imageAlt | ||
| 257 | } else { | ||
| 258 | button.image = configs[.play]?.image | ||
| 259 | } | ||
| 260 | } | 241 | } |
| 261 | 242 | ||
| 262 | @objc func buttonAction(_ button: NSButton) { | 243 | @objc func buttonAction(_ button: NSButton) { |