Repository navigation
fix(timeline): make room for a legacy scroll bar under the lane - #919
Merged
Merged
Conversation
With legacy (always-visible) scroll bars, the Timeline lane's ScrollView(.horizontal, showsIndicators: true) puts a 17 pt scroller below its 84 pt content once the lane overflows. SwiftUI grows the backing NSScrollView past the lane's .frame(height:) to 101 pt and centres it. The ruler started 8.5 pt up inside the header and the bar hung 8.5 pt over the scenes strip. Legacy scroll bars come from "Show scroll bars: Always", or "Automatically" with a mouse or virtual pointer attached, as on GitHub's macOS runners and in VMs. The track row now grows by the legacy scroller thickness while legacy scroll bars are in use and the lane overflows, and the gutter stays at the row's top. It reacts to NSScroller.preferredScrollerStyleDidChangeNotification. A lane that fits gets no extra room, because AppKit hides the scroller then. Overlay layout is unchanged, and iOS gets 0. TimelineLaneLayoutTests hosts the panel with a fitting and an overflowing movie. It checks the lane's top edge, the ruler + items clip, the scroll bar's frame, the row height, the gutter icon's level and the panel's growth. Run it under both styles by adding -AppleShowScrollBars Always / WhenScrolling to the test target's CommandLineArguments in a copy of the .xctestrun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are blocking the Timeline lane alignment changes.
No open issues 🎉
What changed in this PR
Fixes the Timeline lane’s vertical alignment on macOS when legacy scroll bars are visible, preventing overlap with the header and Scenes strip.
Changes:
- Reserves scroll-bar space only when the lane overflows and legacy scrollers are active, leaving overlay and iOS layouts unchanged.
- Keeps the Track gutter top-aligned and updates the layout when the preferred scroller style changes.
- Adds regression coverage for fitting and overflowing lanes, including clip geometry, gutter alignment, and panel height.
| File | Description |
|---|---|
swiftui/PyMOLViewerTests/TimelineLaneLayoutTests.swift |
Adds hosted layout tests for lane and scroll-bar positioning. |
swiftui/PyMOLViewer/Panels/TimelinePanel.swift |
Tracks viewport width and scroller style to reserve the required space. |
swiftui/PyMOLViewer.xcodeproj/project.pbxproj |
Registers the new layout tests in the macOS test target. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS with legacy (always-visible) scroll bars, the Timeline lane sits 8.5 pt too high. It starts inside the header, and its scroll bar hangs 8.5 pt over the Scenes strip. Legacy scroll bars come from "Show scroll bars: Always", or "Automatically" with a mouse or virtual pointer attached. GitHub's macOS runners and VMs have them too. Found while fixing PR #918's XCTest; master has the same code.
The lane is
ScrollView(.horizontal, showsIndicators: true)framed torulerH + laneH(84 pt). With legacy scroll bars and a lane that overflows, SwiftUI puts the 17 pt scroller below the 84 pt clip view. The backingNSScrollViewis then 101 pt tall, centred in the 84 pt frame:Fix (
TimelinePanel.tracksSection, macOS only)laneScrollerH. That isNSScroller.scrollerWidth(for: .regular, scrollerStyle: .legacy)while legacy scroll bars are in use and the lane overflows, and 0 otherwise.contentWidth > viewporttest as the lane. The viewport width comes up through aLaneViewportWKeypreference, like the scenes palette's existing width tracking.legacyScrollersfollowsNSScroller.preferredScrollerStyleDidChangeNotification, so plugging in or removing a mouse re-lays the row.Test
TimelineLaneLayoutTests.testTrackRowMakesRoomForALegacyScrollBarhostsTimelinePanelin anNSHostingView. It measures a fitting movie (2 s) and an overflowing one (40 s) and checks:Under a forced
-AppleShowScrollBarsit also asserts that the run really got that style. CI's runner has legacy scroll bars, so CI covers the legacy path. To force a style locally without touching system settings, copyUnitTests_macOS_*.xctestrunfrombuild-for-testing(keep the copy inBuild/Products/). AddCommandLineArguments: ["-AppleShowScrollBars", "Always" | "WhenScrolling"]to the test target in the copy, then runxcodebuild test-without-building -xctestrun <copy>.TimelineLaneLayoutTests,WhenScrolling(overlay)TimelineLaneLayoutTests,Always(legacy)UnitTests_macOS,AlwaysAlso checked:
screencaptureshows the legacy scroller's track and knob drawn in the 17 pt band. The hosted test can't show this, becauselayer.render(in:)doesn't capture AppKit's scroller drawing.TimelinePanel.swiftincluded, with no errors. It wasn't linked: this machine has nodeps_ios.The build used the two-stage flow:
swiftui/build_macos.sh, thenxcodebuild.🤖 Generated with Claude Code