nano-ui
Safe HaskellNone
LanguageGHC2024

NanoUI.Layout.Arena

Description

The node arena: one frame's layout nodes stored column-wise in primitive arrays (geometry, style, tags and tree links), with accessors, traversals and the layout cache.

Synopsis

Documentation

data NodeArenaArrays Source #

Node columns. Each array holds one row of *Stride slots per node; the column constants below name the slots.

hasCenteredLabel :: NodeType -> Bool Source #

Widgets that paint one line of label text vertically centered in their box (computeWidgetLabel), which is also their baseline.

data DirTag Source #

Constructors

DirRow 
DirColumn 

Instances

Instances details
Eq DirTag Source # 
Instance details

Defined in NanoUI.Layout.Arena

Methods

(==) :: DirTag -> DirTag -> Bool #

(/=) :: DirTag -> DirTag -> Bool #

Bounded DirTag Source # 
Instance details

Defined in NanoUI.Layout.Arena

Enum DirTag Source # 
Instance details

Defined in NanoUI.Layout.Arena

Show DirTag Source # 
Instance details

Defined in NanoUI.Layout.Arena

data NodeArena Source #

Constructors

NodeArena 

Fields

data FlexScratch Source #

Flex solver scratch: child node indices, their measured widths and heights, and the distributed output sizes.

topModalNode :: NodeArena -> IO (Maybe NodeIdx) Source #

The topmost (last added) modal node, if any.

withArenaArraysSnap :: NodeArena -> IO a -> IO a Source #

Pin arena column arrays for a layout pass so field reads skip naArrays IORef.

geomX :: Int Source #

Geometry columns: solved rect, the position snapshot taken by snapshotLayoutRects, and the clip rect.

geomY :: Int Source #

Geometry columns: solved rect, the position snapshot taken by snapshotLayoutRects, and the clip rect.

geomW :: Int Source #

Geometry columns: solved rect, the position snapshot taken by snapshotLayoutRects, and the clip rect.

geomH :: Int Source #

Geometry columns: solved rect, the position snapshot taken by snapshotLayoutRects, and the clip rect.

styleWVal :: Int Source #

Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).

styleHVal :: Int Source #

Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).

stylePadL :: Int Source #

Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).

stylePadR :: Int Source #

Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).

stylePadT :: Int Source #

Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).

stylePadB :: Int Source #

Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).

tagNodeType :: Int Source #

Tag columns (enum values as Word8). Column 7 is unused. The scrollbar slot is a solver output: measurement writes it for scroll containers, so the layout cache skips it when comparing inputs and restores it on a hit.

tagDirection :: Int Source #

Tag columns (enum values as Word8). Column 7 is unused. The scrollbar slot is a solver output: measurement writes it for scroll containers, so the layout cache skips it when comparing inputs and restores it on a hit.

tagWSizing :: Int Source #

Tag columns (enum values as Word8). Column 7 is unused. The scrollbar slot is a solver output: measurement writes it for scroll containers, so the layout cache skips it when comparing inputs and restores it on a hit.

tagHSizing :: Int Source #

Tag columns (enum values as Word8). Column 7 is unused. The scrollbar slot is a solver output: measurement writes it for scroll containers, so the layout cache skips it when comparing inputs and restores it on a hit.

tagScrollBarSlot :: Int Source #

Tag columns (enum values as Word8). Column 7 is unused. The scrollbar slot is a solver output: measurement writes it for scroll containers, so the layout cache skips it when comparing inputs and restores it on a hit.

treeParent :: Int Source #

Tree columns: links, widget id, style index, text index (-1 for no text), and the grid column count (containers only).

treeFirstChild :: Int Source #

Tree columns: links, widget id, style index, text index (-1 for no text), and the grid column count (containers only).

treeNextSibling :: Int Source #

Tree columns: links, widget id, style index, text index (-1 for no text), and the grid column count (containers only).

getNodeFontColor :: NodeArena -> NodeIdx -> IO (Maybe Color) Source #

Per-node font color (paint-only, kept out of naArrTree where treeGridCols holds the grid column count for containers).

ensureScratchCapacity :: NodeArena -> Int -> IO FlexScratch Source #

The flex scratch, grown to hold at least needed entries.

data AxisSnapshot Source #

One depth level's frozen child indices and distributed main-axis sizes.

ensureAxisSnapshot :: NodeArena -> Int -> Int -> IO AxisSnapshot Source #

Get the snapshot buffers for a recursion depth, grown to hold at least needed entries. Buffers are reused across frames; nothing is allocated in steady state once capacity is warm.

memoizeWidth :: NodeArena -> IORef WidthMemo -> NodeIdx -> Float -> IO (Float, Float) -> IO (Float, Float) Source #

Memoize compute for node idx at width key in one of the arena's per-frame memos. Widths within 0.25 px share an entry so near-identical reflows still hit.

forNodes_ :: NodeArena -> (NodeIdx -> IO ()) -> IO () Source #

foldFlowChildrenM :: NodeArena -> NodeIdx -> (acc -> NodeIdx -> IO acc) -> acc -> IO acc Source #

Fold over a node's children in sibling order, skipping floating (modal, window, popup) children, which are placed outside the flow.

foldNodeRevM :: NodeArena -> (a -> NodeIdx -> IO a) -> a -> IO a Source #

findNodeM :: NodeArena -> (NodeIdx -> IO Bool) -> IO (Maybe NodeIdx) Source #

First node, in arena order, satisfying the predicate.

foldNodesM :: NodeArena -> (a -> NodeIdx -> IO a) -> a -> IO a Source #

Left fold over every node in arena order.

findChildM :: NodeArena -> NodeIdx -> (NodeIdx -> IO Bool) -> IO (Maybe NodeIdx) Source #

First direct child of parentIdx satisfying the predicate.

data LayoutCache Source #

Cached layout signature and solved geometry for whole-layout reuse. The backing arrays are reused; only cache misses capture a new solved frame. The font colour and scope columns are paint state and stay unused.

Constructors

LayoutCache 

captureLayoutCache :: NodeArena -> LayoutCache -> IO LayoutCache Source #

Snapshot the current (post-solve) arena form, constraints and rects.

layoutCacheEligible :: NodeArena -> IO Bool Source #

Floating placement depends on state outside the arena descriptor. Custom measurement is checked separately by Frame, which owns its registration.

layoutInputsMatch :: NodeArena -> LayoutCache -> IO Bool Source #

Compare layout inputs, stopping at the first mismatch. Node values are paint state except on scroll containers, where they are solver outputs. Neither belongs in the layout-input signature.

restoreLayoutCache :: NodeArena -> LayoutCache -> IO () Source #

Restore only solver outputs. Rebuilt paint values/colors must survive a cache hit; copying the entire cached style array would revert them.