Skip to content

fix(timeline): make room for a legacy scroll bar under the lane - #919

Merged
javierbq merged 1 commit into
masterfrom
fix/timeline-legacy-scroller
Oct 27, 2026
Merged

javierbq merged 1 commit into
masterfrom
fix/timeline-legacy-scroller

Conversation

@javierbq

Copy link
Copy Markdown
Owner

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 to rulerH + 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 backing NSScrollView is then 101 pt tall, centred in the 84 pt frame:

(900 pt panel, host points) NSScrollView top / height clip top scroller top panel height
overlay 45 / 84 45 (floats over content) 253
legacy, master 36.5 / 101 36.5 120.5 253
legacy, this PR 45 / 101 45 129 270

Fix (TimelinePanel.tracksSection, macOS only)

  • The track row (ScrollView, GeometryReader and HStack frames) grows by laneScrollerH. That is NSScroller.scrollerWidth(for: .regular, scrollerStyle: .legacy) while legacy scroll bars are in use and the lane overflows, and 0 otherwise.
    • The lane-overflows condition matters because AppKit autohides the scroller when the content fits. A probe showed the NSScrollView stays 84 pt then, so growing the row unconditionally would leave an empty 17 pt band under a short movie, including the empty timeline.
    • Overflow uses the same contentWidth > viewport test as the lane. The viewport width comes up through a LaneViewportWKey preference, like the scenes palette's existing width tracking.
  • legacyScrollers follows NSScroller.preferredScrollerStyleDidChangeNotification, so plugging in or removing a mouse re-lays the row.
  • The HStack is top-aligned, so the "Track" gutter stays level with the ruler and items, and the scroll-bar band is left below it.
  • Overlay layout is unchanged: the measurements are identical to master. iOS gets 0. The scroll bar stays, so mouse users can still scroll the lane horizontally.

Test

TimelineLaneLayoutTests.testTrackRowMakesRoomForALegacyScrollBar hosts TimelinePanel in an NSHostingView. It measures a fitting movie (2 s) and an overflowing one (40 s) and checks:

  • the lane's NSScrollView top, and its clip (ruler + items) top, are right under the header (y 45);
  • the clip is 84 pt and the scroll view is 84 pt plus the shown legacy scroller;
  • the legacy scroller sits between the items and the row's bottom;
  • the gutter's film icon, found in a drawn image, is level with the items;
  • the panel's fitting height grows by exactly the scroller's room (0 under overlay).

Under a forced -AppleShowScrollBars it 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, copy UnitTests_macOS_*.xctestrun from build-for-testing (keep the copy in Build/Products/). Add CommandLineArguments: ["-AppleShowScrollBars", "Always" | "WhenScrolling"] to the test target in the copy, then run xcodebuild test-without-building -xctestrun <copy>.

run master this PR
TimelineLaneLayoutTests, WhenScrolling (overlay) pass pass
TimelineLaneLayoutTests, Always (legacy) fail: lane top 36.5, scroller top 120.5, panel +0 pass
full UnitTests_macOS, Always 1752 tests, 0 failures, 4 skipped

Also checked:

  • Scroller drawing. In a standalone SwiftUI probe with this layout and the lane's edge-fade mask, an on-screen screencapture shows the legacy scroller's track and knob drawn in the 17 pt band. The hosted test can't show this, because layer.render(in:) doesn't capture AppKit's scroller drawing.
  • iOS. The iOS Simulator target compiles all its Swift, TimelinePanel.swift included, with no errors. It wasn't linked: this machine has no deps_ios.

The build used the two-stage flow: swiftui/build_macos.sh, then xcodebuild.

🤖 Generated with Claude Code

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@javierbq
javierbq merged commit 8800860 into master Oct 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants