Skip to content

Layout, scrolling, and virtualization API

Declared by <huxerui/layout.h>, <huxerui/scroll.h>, and <huxerui/virtual_layout.h>.

  • MainAxisAlignment: Start, Center, End, SpaceBetween, SpaceAround, SpaceEvenly.
  • CrossAxisAlignment: Start, Center, End, Stretch.
  • HorizontalAlignment: Start, Center, End, Stretch.
  • VerticalAlignment: Start, Center, End, Stretch.

MountedNode is a non-owning view of a reconciled node during layout and extension callbacks. It exposes child iteration, current layout and presentation geometry, interaction and alignment values, typed LayoutValue lookup, and a type-indexed Cache<T> owned by that node. ChildAt throws std::out_of_range for an invalid index and a cache type mismatch throws std::logic_error; do not retain a node or child reference across reconciliation.

LayoutContext::Measure(child, constraints) measures one child. SafeAreaInsets() returns the edges not consumed by ancestor safe-area padding, and TitleBarMetrics() returns optional frame-local native title-bar geometry. LayoutResult contains the constrained layout size and child placements. Applications implement the static measurement contract on Layout<Derived> and do not retain child or mounted-node state.

LayoutValue<Key> is typed parent-child metadata for values understood by the immediate parent layout.

  • ScrollAlignment: Start, Center, End.
  • ScrollMetrics: axis, offset, maximum offset, viewport extent, and content extent.
  • ScrollController: Metrics, Offset, MaxOffset, ViewportExtent, ContentExtent, IsConnected, ScrollTo, ScrollBy, and ScrollToItem.
  • UseScrollController(initial_offset = 0, source_location) creates a scope-stable controller.

Attach a controller through ScrollView::Controller or the matching virtual component method; the binding used to connect it to a mounted scroll node is internal.

  • GridColumns::Fixed(count) and GridColumns::Adaptive(minimum_width) create the two public column policies; Resolve(available_width, spacing) returns the effective count.
  • VirtualViewport: logical offset and viewport size; Bounds() combines them into a rectangle.
  • VirtualLayoutContext: item count, current viewport, indexed item realization, and constrained item measurement.
  • VirtualLayoutResult: total content extent and placed virtual items.

VirtualLayout<Derived> accepts either a range/factory pair or an item count/factory pair and invokes the derived static measurement contract. Its erased descriptor and realized-item source are internal.

The built-in lazy components are VirtualList and VirtualGrid.