| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
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
- type NodeIdx = Int
- data NodeType
- data NodeArenaArrays = NodeArenaArrays {
- naArrGeom :: !(MutablePrimArray RealWorld Float)
- naArrStyle :: !(MutablePrimArray RealWorld Float)
- naArrTags :: !(MutablePrimArray RealWorld Word8)
- naArrTree :: !(MutablePrimArray RealWorld Int)
- naArrTextStore :: !(MutableArray RealWorld Text)
- naArrOptionsStore :: !(MutableArray RealWorld [Text])
- naArrFontColor :: !(MutablePrimArray RealWorld Int)
- naArrScope :: !(MutablePrimArray RealWorld Int)
- isWidgetNode :: NodeType -> Bool
- hasCenteredLabel :: NodeType -> Bool
- isContainerNode :: NodeType -> Bool
- isScrollNode :: NodeType -> Bool
- isFloatingNode :: NodeType -> Bool
- data SizingTag
- data DirTag
- data NodeArena = NodeArena {
- naCount :: IORef Int
- naCapacity :: IORef Int
- naArrays :: IORef NodeArenaArrays
- naArraysSnap :: IORef (Maybe NodeArenaArrays)
- naScratch :: IORef FlexScratch
- naSnapCap :: IORef Int
- naSnapLevels :: IORef (MutableArray RealWorld (Maybe AxisSnapshot))
- naFrameTag :: IORef Word32
- naWrapMemo :: IORef WidthMemo
- naFitMemo :: IORef WidthMemo
- naEpoch :: IORef Word32
- naIndex :: IORef (BasicHashTable WidgetId Word64)
- naScope :: IORef Int
- naScopeSig :: IORef Word64
- naTopModal :: IORef Int
- naFloatingCount :: IORef Int
- data FlexScratch = FlexScratch {
- fsCap :: !Int
- fsIdx :: !(MutablePrimArray RealWorld Int)
- fsW :: !(MutablePrimArray RealWorld Float)
- fsH :: !(MutablePrimArray RealWorld Float)
- fsOutW :: !(MutablePrimArray RealWorld Float)
- fsOutH :: !(MutablePrimArray RealWorld Float)
- newNodeArena :: IO NodeArena
- resetNodeArena :: NodeArena -> IO ()
- arenaCount :: NodeArena -> IO Int
- topModalNode :: NodeArena -> IO (Maybe NodeIdx)
- floatingNodeCount :: NodeArena -> IO Int
- arenaArrays :: NodeArena -> IO NodeArenaArrays
- withArenaArraysSnap :: NodeArena -> IO a -> IO a
- geomX :: Int
- geomY :: Int
- geomW :: Int
- geomH :: Int
- styleWVal :: Int
- styleHVal :: Int
- styleMinW :: Int
- styleMinH :: Int
- styleMaxW :: Int
- styleMaxH :: Int
- stylePadL :: Int
- stylePadR :: Int
- stylePadT :: Int
- stylePadB :: Int
- styleGap :: Int
- styleGridMinColW :: Int
- tagNodeType :: Int
- tagDirection :: Int
- tagWSizing :: Int
- tagHSizing :: Int
- tagScrollBarSlot :: Int
- treeParent :: Int
- treeFirstChild :: Int
- treeNextSibling :: Int
- treeStyleIdx :: Int
- treeGridCols :: Int
- readGeom :: NodeArenaArrays -> NodeIdx -> Int -> IO Float
- writeGeom :: NodeArenaArrays -> NodeIdx -> Int -> Float -> IO ()
- readStyle :: NodeArenaArrays -> NodeIdx -> Int -> IO Float
- readTagEnum :: Enum e => NodeArenaArrays -> NodeIdx -> Int -> IO e
- writeTagEnum :: Enum e => NodeArenaArrays -> NodeIdx -> Int -> e -> IO ()
- readTree :: NodeArenaArrays -> NodeIdx -> Int -> IO Int
- writeTree :: NodeArenaArrays -> NodeIdx -> Int -> Int -> IO ()
- addNode :: NodeArena -> NodeType -> Int -> Direction -> Sizing -> Sizing -> Padding -> Float -> Float -> Float -> Float -> Float -> Float -> AlignX -> AlignY -> IO NodeIdx
- addNodeFromLayout :: NodeArena -> NodeType -> Int -> Layout -> IO NodeIdx
- rootAttachParent :: NodeArena -> Int -> IO Int
- setNodeText :: NodeArena -> NodeIdx -> Text -> IO ()
- getParent :: NodeArena -> NodeIdx -> IO NodeIdx
- getFirstChild :: NodeArena -> NodeIdx -> IO NodeIdx
- getNextSibling :: NodeArena -> NodeIdx -> IO NodeIdx
- getChildCount :: NodeArena -> NodeIdx -> IO Int
- getNodeType :: NodeArena -> NodeIdx -> IO NodeType
- getDirection :: NodeArena -> NodeIdx -> IO DirTag
- getGridCols :: NodeArena -> NodeIdx -> IO Int
- getGridMinColW :: NodeArena -> NodeIdx -> IO Float
- getScrollContentW :: NodeArena -> NodeIdx -> IO Float
- setScrollContentW :: NodeArena -> NodeIdx -> Float -> IO ()
- getWidthSizing :: NodeArena -> NodeIdx -> IO (SizingTag, Float)
- getHeightSizing :: NodeArena -> NodeIdx -> IO (SizingTag, Float)
- getPadding :: NodeArena -> NodeIdx -> IO Padding
- getGap :: NodeArena -> NodeIdx -> IO Float
- getMinMax :: NodeArena -> NodeIdx -> IO (Float, Float, Float, Float)
- parentIsRow :: NodeArena -> NodeIdx -> IO Bool
- getAlignX :: NodeArena -> NodeIdx -> IO AlignX
- getAlignY :: NodeArena -> NodeIdx -> IO AlignY
- getRect :: NodeArena -> NodeIdx -> IO (Float, Float, Float, Float)
- setRect :: NodeArena -> NodeIdx -> Float -> Float -> Float -> Float -> IO ()
- getLayoutRect :: NodeArena -> NodeIdx -> IO (Float, Float, Float, Float)
- getClipRect :: NodeArena -> NodeIdx -> IO (Maybe Rect)
- setClipRect :: NodeArena -> NodeIdx -> Rect -> IO ()
- snapshotLayoutRects :: NodeArena -> IO ()
- getText :: NodeArena -> NodeIdx -> IO Text
- getOptions :: NodeArena -> NodeIdx -> IO [Text]
- setOptions :: NodeArena -> NodeIdx -> [Text] -> IO ()
- getWidgetId :: NodeArena -> NodeIdx -> IO WidgetId
- setWidgetId :: NodeArena -> NodeIdx -> WidgetId -> IO ()
- lookupNodeByWidgetId :: NodeArena -> WidgetId -> IO (Maybe NodeIdx)
- lookupNodeByKey :: NodeArena -> Int -> IO (Maybe NodeIdx)
- getStyleIdx :: NodeArena -> NodeIdx -> IO Int
- setStyleIdx :: NodeArena -> NodeIdx -> Int -> IO ()
- getNodeValue :: NodeArena -> NodeIdx -> IO Float
- setNodeValue :: NodeArena -> NodeIdx -> Float -> IO ()
- getNodeFontSize :: NodeArena -> NodeIdx -> IO Float
- getNodeFontColor :: NodeArena -> NodeIdx -> IO (Maybe Color)
- getNodeScope :: NodeArena -> NodeIdx -> IO Int
- getArenaScope :: NodeArena -> IO Int
- setArenaScope :: NodeArena -> Int -> IO ()
- getScopeSignature :: NodeArena -> IO Word64
- ensureScratchCapacity :: NodeArena -> Int -> IO FlexScratch
- data AxisSnapshot = AxisSnapshot {
- asIdx :: !(MutablePrimArray RealWorld Int)
- asOut :: !(MutablePrimArray RealWorld Float)
- ensureAxisSnapshot :: NodeArena -> Int -> Int -> IO AxisSnapshot
- memoizeWidth :: NodeArena -> IORef WidthMemo -> NodeIdx -> Float -> IO (Float, Float) -> IO (Float, Float)
- forNodes_ :: NodeArena -> (NodeIdx -> IO ()) -> IO ()
- forChildNodes_ :: NodeArena -> NodeIdx -> (NodeIdx -> IO ()) -> IO ()
- foldFlowChildrenM :: NodeArena -> NodeIdx -> (acc -> NodeIdx -> IO acc) -> acc -> IO acc
- findNodeRevM :: NodeArena -> (NodeIdx -> IO Bool) -> IO (Maybe NodeIdx)
- foldNodeRevM :: NodeArena -> (a -> NodeIdx -> IO a) -> a -> IO a
- findNodeM :: NodeArena -> (NodeIdx -> IO Bool) -> IO (Maybe NodeIdx)
- foldNodesM :: NodeArena -> (a -> NodeIdx -> IO a) -> a -> IO a
- findChildM :: NodeArena -> NodeIdx -> (NodeIdx -> IO Bool) -> IO (Maybe NodeIdx)
- data LayoutCache = LayoutCache {}
- newLayoutCache :: Int -> IO LayoutCache
- captureLayoutCache :: NodeArena -> LayoutCache -> IO LayoutCache
- layoutCacheEligible :: NodeArena -> IO Bool
- layoutInputsMatch :: NodeArena -> LayoutCache -> IO Bool
- restoreLayoutCache :: NodeArena -> LayoutCache -> IO ()
Documentation
Constructors
Instances
| Eq NodeType Source # | |
| Bounded NodeType Source # | |
| Enum NodeType Source # | |
Defined in NanoUI.Layout.Arena | |
| Show NodeType Source # | |
data NodeArenaArrays Source #
Node columns. Each array holds one row of *Stride slots per node; the
column constants below name the slots.
Constructors
| NodeArenaArrays | |
Fields
| |
isWidgetNode :: NodeType -> Bool Source #
hasCenteredLabel :: NodeType -> Bool Source #
Widgets that paint one line of label text vertically centered in their box
(computeWidgetLabel), which is also their baseline.
isContainerNode :: NodeType -> Bool Source #
isScrollNode :: NodeType -> Bool Source #
isFloatingNode :: NodeType -> Bool Source #
Constructors
| SizingFixed | |
| SizingFit | |
| SizingGrow | |
| SizingShrink | |
| SizingPercent |
Instances
| Eq SizingTag Source # | |
| Bounded SizingTag Source # | |
| Enum SizingTag Source # | |
Defined in NanoUI.Layout.Arena Methods succ :: SizingTag -> SizingTag # pred :: SizingTag -> SizingTag # fromEnum :: SizingTag -> Int # enumFrom :: SizingTag -> [SizingTag] # enumFromThen :: SizingTag -> SizingTag -> [SizingTag] # enumFromTo :: SizingTag -> SizingTag -> [SizingTag] # enumFromThenTo :: SizingTag -> SizingTag -> SizingTag -> [SizingTag] # | |
| Show SizingTag Source # | |
Constructors
| NodeArena | |
Fields
| |
data FlexScratch Source #
Flex solver scratch: child node indices, their measured widths and heights, and the distributed output sizes.
Constructors
| FlexScratch | |
Fields
| |
resetNodeArena :: NodeArena -> IO () Source #
topModalNode :: NodeArena -> IO (Maybe NodeIdx) Source #
The topmost (last added) modal node, if any.
arenaArrays :: NodeArena -> IO NodeArenaArrays Source #
withArenaArraysSnap :: NodeArena -> IO a -> IO a Source #
Pin arena column arrays for a layout pass so field reads skip naArrays IORef.
Geometry columns: solved rect, the position snapshot taken by
snapshotLayoutRects, and the clip rect.
Geometry columns: solved rect, the position snapshot taken by
snapshotLayoutRects, and the clip rect.
Geometry columns: solved rect, the position snapshot taken by
snapshotLayoutRects, and the clip rect.
Geometry columns: solved rect, the position snapshot taken by
snapshotLayoutRects, and the clip rect.
Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).
Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).
Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).
Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).
Style columns: sizing values, padding, gap, min/max, grow, and per-node values that are not layout inputs (scroll extent, node value, font size).
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).
treeStyleIdx :: Int Source #
treeGridCols :: Int Source #
readTagEnum :: Enum e => NodeArenaArrays -> NodeIdx -> Int -> IO e Source #
writeTagEnum :: Enum e => NodeArenaArrays -> NodeIdx -> Int -> e -> IO () Source #
addNode :: NodeArena -> NodeType -> Int -> Direction -> Sizing -> Sizing -> Padding -> Float -> Float -> Float -> Float -> Float -> Float -> AlignX -> AlignY -> IO NodeIdx Source #
snapshotLayoutRects :: NodeArena -> IO () Source #
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.
Constructors
| AxisSnapshot | |
Fields
| |
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.
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.
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 | |
newLayoutCache :: Int -> IO LayoutCache Source #
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.