This document captures design and implementation notes for ScrollBar.
For end-user usage and examples, see ScrollBar.
ScrollViewerScrollModel (via IScrollable) typically feed their model values into scroll barsScrollBar : Visual (abstract)VScrollBar : ScrollBar (Orientation.Vertical)HScrollBar : ScrollBar (Orientation.Horizontal)ScrollBar(bool focusable = true):
FocusableVerticalAlignment = Align.StretchHorizontalAlignment = Align.StretchSmallChange = 1Minimum : intMaximum : intValue : int
[min, max] (swaps if Maximum < Minimum)ViewportSize : int
0)SmallChange : int (wheel / arrow keys)LargeChange : int (page click / PageUp/PageDown)
<= 0, defaults to max(1, ViewportSize)ValueChanged (bubble): raised when Value changes after clamping, with old/new values.ScrollBarStyle.Thickness (min 1, clamped to finite).Rendering is glyph-based and uses Theme.ScrollBars:
glyphs.Track and a resolved “track style”.glyphs.Thumb and a resolved “thumb style”.Thumb is derived from Minimum/Maximum/Value/ViewportSize and available track length:
0 (or negative after normalization), thumb consumes the full track.contentSize = range + viewportthumbLength ≈ trackLength * viewport / contentSize (rounded)[ScrollBarStyle.MinThumbLength, trackLength]thumbStart ≈ offset * (trackLength - thumbLength) / range (rounded)The algorithm is designed to be stable for small tracks (track length <= 1 always yields a 1-cell thumb).
LargeChange if > 0, else max(1, ViewportSize)trackLength - thumbLength).SmallChange (min 1).Up/Down by SmallChangePageUp/PageDown by LargeChange (or ViewportSize fallback)Home/End to Minimum/MaximumLeft/Right by SmallChangePageUp/PageDown, Home/End behave similarlyScrollBarStyle controls:
Thickness (cells)MinThumbLength (cells)TrackStyle / ThumbStyleTheme.Muted/Theme.BorderScroll bars use Theme.ScrollBars.Track and Theme.ScrollBars.Thumb glyphs for rendering.
src/XenoAtom.Terminal.UI.Tests/ScrollViewer*Tests.cssrc/XenoAtom.Terminal.UI.Tests/ScrollViewerTextAreaInteractionTests.cs (hit testing + bar interaction)src/XenoAtom.Terminal.UI.Tests/ScrollViewerRenderingTests.cs