Commit 5119e459 authored by Kourser's avatar Kourser
Browse files

fix(macos): give the Touch Bar scrubbers a stretchable width

An NSScrubber has no intrinsic width, so at launch — when the
subscriptions strip is the only item in the bar — it collapsed to
nothing (no artwork visible). While playing it borrowed the leftover
space between the transport items, which masked the defect. Both
scrubbers now carry a low-priority preferred width that soaks up the
available space while still yielding to the other items and to the
320 pt cap active during playback.

Co-Authored-By: Claude (RCA)
parent 9dc91392
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ extension TouchBarController: NSTouchBarDelegate {
            layout.itemSize = NSSize(width: 36, height: 30)
            layout.itemSpacing = 4
            scrubber.scrubberLayout = layout
            Self.stretch(scrubber)
            let cap = scrubber.widthAnchor.constraint(lessThanOrEqualToConstant: 320)
            cap.isActive = playback.currentEpisode != nil
            podcastScrubberWidthCap = cap
@@ -248,6 +249,7 @@ extension TouchBarController: NSTouchBarDelegate {
            let scrubber = makeScrubber()
            scrubber.register(NSScrubberTextItemView.self, forItemIdentifier: Self.episodeCell)
            scrubber.scrubberLayout = NSScrubberFlowLayout() // sized per title below
            Self.stretch(scrubber)
            item.view = scrubber
            episodeScrubber = scrubber
            return item
@@ -265,6 +267,15 @@ extension TouchBarController: NSTouchBarDelegate {
        scrubber.showsAdditionalContentIndicators = true
        return scrubber
    }

    /// A scrubber has no intrinsic width: alone in the bar it collapses to
    /// nothing. This low-priority width makes it soak up the available space
    /// while still yielding to the other items (and to the 320 pt cap).
    private static func stretch(_ scrubber: NSScrubber) {
        let width = scrubber.widthAnchor.constraint(equalToConstant: 1200)
        width.priority = .defaultLow
        width.isActive = true
    }
}

extension TouchBarController: NSScrubberDataSource, NSScrubberDelegate, NSScrubberFlowLayoutDelegate {