Table of Contents

Namespace SharpConsoleUI.Layout

Classes

CharacterBuffer

A 2D buffer of character cells for rendering. Supports double-buffering for efficient diff-based output.

CollapsibleLayout

Layout algorithm for CollapsiblePanel. Reserves a header region at the top of the panel and stacks the visible body children vertically beneath it. When the panel is collapsed its children are invisible and contribute no height; when expanded the body height is capped by MaxContentHeight.

ControlBounds

Represents the complete bounds and coordinate information for a control within a window

GridLayout

A WinUI-<Grid>-style 2D layout algorithm. Sizes its row and column tracks from the IGridSource seam (fixed, auto-to-content, or proportional star) and places each cell into its assigned tracks. Auto tracks are sized to the largest desired size of the cells that occupy them; spanning cells contribute their desired size spread evenly across the auto tracks they cover.

GridTrackSizer

Turns a list of GridLength track definitions into concrete integer track sizes along a single axis (columns or rows). This is a pure function: it performs no rendering and holds no state, which makes it fully unit-testable in isolation.

HorizontalLayout

Layout algorithm that arranges children horizontally. Similar to HorizontalGridControl behavior.

LayoutNode

Represents a node in the layout DOM tree. Wraps an IWindowControl and manages layout state (measure/arrange/paint).

LayoutNodeFactory

Shared utility for building layout subtrees from controls. Extracts the control-type to layout-algorithm mapping so both WindowRenderer and ScrollablePanelControl can build proper layout trees.

PortalPositioner

Static utility for calculating portal overlay positions with automatic flip and clamping logic. Extracts the shared positioning pattern from DropdownControl and MenuControl into a reusable component.

ScrollLayout

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

ScrollableLayoutNode

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

TabLayout

Layout algorithm for TabControl that positions tab content below a header row. Similar to VerticalStackLayout but reserves space for tab headers.

VerticalStackLayout

Layout algorithm that stacks children vertically. Similar to ColumnContainer behavior.

WindowContentLayout

Root layout for window content. Handles sticky top, scrollable middle, and sticky bottom sections.

WindowLayoutManager

Manages layout calculations and coordinate translations for all controls in a window

Structs

BufferSnapshot

Immutable snapshot of a CharacterBuffer at a point in time.

Cell

Represents a single character cell in the character buffer. Contains the character, foreground color, background color, decorations, and dirty state.

CellChange

Represents a change to a single cell in the buffer.

GridLength

A sizing primitive for a grid row or column. Describes whether the track is Fixed (exact cells), Auto (size-to-content), or Star (proportional share of leftover space), with optional minimum and maximum cell clamps.

GridPlacement

Describes where a single cell sits within a grid: its starting row and column (both zero-based), how many rows and columns it spans, and its optional per-cell styling (background fill, border, and content padding).

LayoutConstraints

Represents layout constraints for measuring controls. Defines minimum and maximum width/height bounds.

LayoutRect

Represents a rectangle with position and size. Immutable value type for layout calculations and hit testing. Named LayoutRect to avoid conflicts with System.Drawing.Rectangle during transition.

LayoutSize

Represents a size with width and height dimensions. Immutable value type for layout calculations. Named LayoutSize to avoid conflicts with System.Drawing.Size during transition.

Padding

Immutable padding values for content spacing. Replaces Spectre.Console.Padding.

PortalPositionRequest

Describes a portal positioning request.

PortalPositionResult

The calculated portal position after applying placement and clamping logic.

Interfaces

IDOMMeasurable

Interface for controls that support native DOM-based measurement only. Controls implementing this interface provide optimized size calculation.

IDOMPaintable

Interface for controls that support DOM-based painting. Controls implementing this interface can paint directly to a CharacterBuffer. All controls must implement this interface for the DOM layout system.

IFillReportsMinimumHeight

Marks a control that, when placed with Fill inside a scroll viewport (e.g. ScrollablePanelControl), has a hard minimum height it cannot shrink below and does not scroll its own content internally — so when the viewport is shorter than that minimum the hosting panel must scroll on its behalf.

IGridSource

The seam between a grid container and the GridLayout algorithm that measures and arranges it. A grid control implements this interface to expose exactly what the layout needs: the row and column track definitions, the inter-track gaps, the grid's own margin and padding, and the ordered set of cells with their placements.

IHasPortalBounds

Implemented by portal content controls that need custom absolute positioning. When Window.CreatePortal() receives a content that implements this interface, it uses GetPortalBounds() to position the overlay instead of defaulting to (0,0).

ILayoutContainer

Interface for layout algorithms that determine how children are measured and arranged. Different implementations provide different layout strategies (vertical stack, horizontal, grid, etc.)

IRegionClippingLayout

Interface for layout containers that support region-specific clipping. This allows different clip rectangles to be applied to children based on their properties, such as preventing scrollable content from painting over sticky controls.

Enums

GridUnitType

Describes how a grid row or column is sized.

HorizontalAlignment

Horizontal alignment options for controls within their container.

PortalPlacement

Preferred placement direction for a portal overlay relative to its anchor.

TextJustification

Text justification for content alignment within controls. Replaces Spectre.Console.Justify.

VerticalAlignment

Vertical alignment options for controls within their container.