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