Skip to content

Pixel-based scroll-position seam (IScrollOffsetSource) — step 1 of #33#34

Open
andrewtheart wants to merge 1 commit into
FrozenAssassine:masterfrom
andrewtheart:feat/pixel-offset-scroll-seam
Open

Pixel-based scroll-position seam (IScrollOffsetSource) — step 1 of #33#34
andrewtheart wants to merge 1 commit into
FrozenAssassine:masterfrom
andrewtheart:feat/pixel-offset-scroll-seam

Conversation

@andrewtheart

Copy link
Copy Markdown
Contributor

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. That
mismatch makes the later work (word-wrap-aware scrolling, long-line horizontal virtualization, and
especially the eventual swap to a real ScrollViewer for diagonal 2-axis touchpad scrolling) into a
whole-consumer unit rewrite.

This PR introduces IScrollOffsetSource — a single funnel for the scroll position, expressed in
pixels — and routes ScrollManager's offset reads/writes through it. Phase 1 backs it with the
existing two ScrollBar primitives via a ScrollBarOffsetSource adapter that does the
pixel↔scrollbar-unit conversion internally. The pure arithmetic lives in ScrollOffsetMath so it's
unit-testable in isolation (a ScrollBar can't be created headless — this is exactly where a
"scroll is 4× too fast" regression would hide).

Behavior

No user-visible behavior change. VerticalScroll / HorizontalScroll keep their existing public
semantics; every mutator produces the same scrollbar values as before. Extent/viewport setup
(VerticalScrollbar_Loaded, EnsureHorizontalScrollBounds) is intentionally left writing the
scrollbars directly — the adapter reads those same scrollbars — to keep this PR a pure offset-seam
refactor. The Extent/Viewport/ChangeView members on the interface are the forward-looking
surface that the ScrollViewer backend (a later PR) will drop into.

Changes

  • new Core/ScrollOffsetMath.cs — pure pixel↔scrollbar-unit conversions.
  • new Core/IScrollOffsetSource.cs — the seam interface + ScrollBarOffsetSource adapter.
  • Core/ScrollManager.cs — routes offset access through OffsetSource.
  • tests ScrollOffsetMathTests.cs — round-trips, sensitivity, extent, and clamping.

Verification

TextControlBox (library) builds clean; the test project builds clean (x64). Happy to adjust naming
or scope to your taste before the next PR in the series.

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.
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.

1 participant