Table of Contents

Class ScrollableLayoutNode

Namespace
SharpConsoleUI.Layout
Assembly
SharpConsoleUI.dll

A layout node that supports scrolling. Manages a viewport into a larger content area.

public class ScrollableLayoutNode : LayoutNode
Inheritance
ScrollableLayoutNode
Inherited Members

Constructors

ScrollableLayoutNode(IWindowControl?, ILayoutContainer?)

Creates a new scrollable layout node.

public ScrollableLayoutNode(IWindowControl? control = null, ILayoutContainer? layout = null)

Parameters

control IWindowControl
layout ILayoutContainer

Properties

CanScrollHorizontally

Gets whether horizontal scrolling is needed.

public bool CanScrollHorizontally { get; }

Property Value

bool

CanScrollVertically

Gets whether vertical scrolling is needed.

public bool CanScrollVertically { get; }

Property Value

bool

ContentSize

Gets the total content size (may be larger than viewport).

public LayoutSize ContentSize { get; }

Property Value

LayoutSize

MaxScrollX

Gets the maximum horizontal scroll offset.

public int MaxScrollX { get; }

Property Value

int

MaxScrollY

Gets the maximum vertical scroll offset.

public int MaxScrollY { get; }

Property Value

int

ScrollX

Gets or sets the scroll offset (top-left of visible area).

public int ScrollX { get; set; }

Property Value

int

ScrollY

Gets or sets the scroll offset (top-left of visible area).

public int ScrollY { get; set; }

Property Value

int

ViewportSize

Gets the viewport size (visible area).

public LayoutSize ViewportSize { get; }

Property Value

LayoutSize

Methods

EnsureVisible(LayoutRect)

Scrolls to ensure the specified rectangle is visible.

public void EnsureVisible(LayoutRect rect)

Parameters

rect LayoutRect

EnsureVisible(int)

Scrolls to ensure the specified Y position is visible.

public void EnsureVisible(int y)

Parameters

y int

GetVisibleChildRange()

Gets the visible range of children indices. Useful for virtual scrolling (only process visible items).

public (int StartIndex, int Count) GetVisibleChildRange()

Returns

(int absoluteLeft, int absoluteTop)

HitTest(int, int)

Hit test with scroll offset applied. Translates the hit test coordinates by the scroll offset before checking children.

public override LayoutNode? HitTest(int x, int y)

Parameters

x int
y int

Returns

LayoutNode

Measure(LayoutConstraints)

Measures the scrollable content. The content can exceed the available space (will scroll).

public LayoutSize Measure(LayoutConstraints constraints)

Parameters

constraints LayoutConstraints

Returns

LayoutSize

PageDown()

Scrolls down by one page.

public void PageDown()

PageUp()

Scrolls up by one page.

public void PageUp()

Paint(CharacterBuffer, LayoutRect)

Paints the scrollable content with scroll offset applied.

public void Paint(CharacterBuffer buffer, LayoutRect clipRect)

Parameters

buffer CharacterBuffer
clipRect LayoutRect

ScrollBy(int, int)

Scrolls by the specified amounts.

public void ScrollBy(int deltaX, int deltaY)

Parameters

deltaX int
deltaY int

ScrollTo(int, int)

Scrolls to the specified position.

public void ScrollTo(int x, int y)

Parameters

x int
y int

ScrollToBottom()

Scrolls to the bottom.

public void ScrollToBottom()

ScrollToTop()

Scrolls to the top.

public void ScrollToTop()