Table of Contents

Class ScrollLayout

Namespace
SharpConsoleUI.Layout
Assembly
SharpConsoleUI.dll

Layout algorithm for ScrollablePanelControl. Stacks the panel's visible children vertically inside a clipped content viewport and offsets them by the panel's scroll position, so the scroll offset flows into each child's AbsoluteBounds via the standard Arrange(LayoutRect).

public class ScrollLayout : ILayoutContainer, IRegionClippingLayout
Inheritance
ScrollLayout
Implements
Inherited Members
Extension Methods

Remarks

This layout DOES NOT own scroll state — the panel remains the single source of truth for the scroll offset, viewport size and scrollbar reservation. ScrollLayout only READS those values (via internal accessors) and reuses the panel's shared Fill helpers (ComputeFillMetrics/ComputeChildHeight) so the arranged layout is byte-identical to the panel's existing self-paint. It mirrors CollapsibleLayout's shape: a tree-participating container that reads its control's state and arranges a clipped region.

The crux: ArrangeChildren(LayoutNode, LayoutRect) arranges each child at y = -verticalOffset + cumH; because Arrange(LayoutRect) computes AbsoluteBounds.Y = Parent.AbsoluteBounds.Y + finalRect.Y, the negative scroll offset flows straight into the child's absolute bounds — no SPC-specific hit-test/cursor override is needed.

Methods

ArrangeChildren(LayoutNode, LayoutRect)

Arranges the visible children stacked vertically from y = -verticalScrollOffset (and x = -horizontalScrollOffset), each at its full measured height, within the content region. Off-viewport children are arranged too (correct bounds; paint culls them).

public void ArrangeChildren(LayoutNode node, LayoutRect finalRect)

Parameters

node LayoutNode
finalRect LayoutRect

GetPaintClipRect(LayoutNode, LayoutRect)

Restricts a child's paint area to the panel's content viewport (inside the scrollbar chrome), intersected with the parent clip. Scrolled-out rows are clipped away.

public LayoutRect GetPaintClipRect(LayoutNode child, LayoutRect parentClipRect)

Parameters

child LayoutNode
parentClipRect LayoutRect

Returns

LayoutRect

MeasureChildren(LayoutNode, LayoutConstraints)

Measures the visible children at the content width and returns the VIEWPORT size as the node's desired size (NOT the full content extent). The panel computes the full content extent internally for scrollbar math; the layout slot only ever occupies the viewport.

public LayoutSize MeasureChildren(LayoutNode node, LayoutConstraints constraints)

Parameters

node LayoutNode
constraints LayoutConstraints

Returns

LayoutSize