Pixel-based scroll-position seam (IScrollOffsetSource) — step 1 of #33#34
Open
andrewtheart wants to merge 1 commit into
Open
Pixel-based scroll-position seam (IScrollOffsetSource) — step 1 of #33#34andrewtheart wants to merge 1 commit into
andrewtheart wants to merge 1 commit into
Conversation
Introduce a small IScrollOffsetSource abstraction so the editor scroll position is expressed in pixels rather than legacy scrollbar units (SingleLineHeight / DefaultVerticalScrollSensitivity). ScrollManager routes every offset read/write through it; the ScrollBarOffsetSource adapter backs it with the existing two ScrollBar primitives and does the pixel<->scrollbar-unit conversion internally (ScrollOffsetMath). Behavior is unchanged. Foundation for word-wrap scrolling, long-line horizontal virtualization and diagonal 2-axis touchpad scrolling (FrozenAssassine#33). Adds ScrollOffsetMathTests.
This was referenced Jul 11, 2026
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.
Step 1 of the editor scroll/render series (#33)
This is the foundational piece agreed in #33: a small pixel-based scroll-position seam.
What & why
Today the editor's vertical scroll position is stored in legacy scrollbar units
(
SingleLineHeight / DefaultVerticalScrollSensitivity), while horizontal is in pixels. Thatmismatch makes the later work (word-wrap-aware scrolling, long-line horizontal virtualization, and
especially the eventual swap to a real
ScrollViewerfor diagonal 2-axis touchpad scrolling) into awhole-consumer unit rewrite.
This PR introduces
IScrollOffsetSource— a single funnel for the scroll position, expressed inpixels — and routes
ScrollManager's offset reads/writes through it. Phase 1 backs it with theexisting two
ScrollBarprimitives via aScrollBarOffsetSourceadapter that does thepixel↔scrollbar-unit conversion internally. The pure arithmetic lives in
ScrollOffsetMathso it'sunit-testable in isolation (a
ScrollBarcan't be created headless — this is exactly where a"scroll is 4× too fast" regression would hide).
Behavior
No user-visible behavior change.
VerticalScroll/HorizontalScrollkeep their existing publicsemantics; every mutator produces the same scrollbar values as before. Extent/viewport setup
(
VerticalScrollbar_Loaded,EnsureHorizontalScrollBounds) is intentionally left writing thescrollbars directly — the adapter reads those same scrollbars — to keep this PR a pure offset-seam
refactor. The
Extent/Viewport/ChangeViewmembers on the interface are the forward-lookingsurface that the
ScrollViewerbackend (a later PR) will drop into.Changes
Core/ScrollOffsetMath.cs— pure pixel↔scrollbar-unit conversions.Core/IScrollOffsetSource.cs— the seam interface +ScrollBarOffsetSourceadapter.Core/ScrollManager.cs— routes offset access throughOffsetSource.ScrollOffsetMathTests.cs— round-trips, sensitivity, extent, and clamping.Verification
TextControlBox(library) builds clean; the test project builds clean (x64). Happy to adjust namingor scope to your taste before the next PR in the series.