Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::LayoutSnapshot Class Reference

Owning immutable identities and local sizes from one completed layout pass. Copies share immutable value storage, without widgets, tree owners or borrowed text. Captured values remain readable after tree invalidation, removal or destruction. Concurrent const reads are safe; assignment requires caller synchronization. More...

#include <layout_snapshot.hpp>

Public Member Functions

std::expected< CellSize, TreeError > viewport (Node< Widget > node) const noexcept
 Read a captured local extent without consulting the current tree.
std::expected< LayoutGeometrySnapshot, TreeError > geometry (Node< Widget > node) const noexcept
std::expected< std::uint64_t, TreeError > geometryRevision () const noexcept

Static Public Member Functions

static std::expected< LayoutSnapshot, TreeError > capture (WidgetTree &tree, Node< Widget > node)
 Copy every live node in a subtree, including effectively hidden descendants. Call on the tree's UI thread after successful layout, preferably inside its frame. No layout, callbacks, mutation or frame request consumption is performed.
static std::expected< LayoutSnapshot, TreeError > capture (WidgetTree &tree, Node< Widget > node, LayoutSnapshotProfile profile)
 Opt into geometry capture without changing the original overload's allocation path.

Friends

struct detail::LayoutTraversalAccess
struct detail::ScrollSnapshotAccess
struct detail::ScrollSnapshotTestAccess

Detailed Description

Owning immutable identities and local sizes from one completed layout pass. Copies share immutable value storage, without widgets, tree owners or borrowed text. Captured values remain readable after tree invalidation, removal or destruction. Concurrent const reads are safe; assignment requires caller synchronization.

Member Function Documentation

◆ capture() [1/2]

std::expected< LayoutSnapshot, TreeError > portals::LayoutSnapshot::capture ( WidgetTree & tree,
Node< Widget > node )
staticnodiscard

Copy every live node in a subtree, including effectively hidden descendants. Call on the tree's UI thread after successful layout, preferably inside its frame. No layout, callbacks, mutation or frame request consumption is performed.

Parameters
treeLive UI tree borrowed only during this call.
nodeChecked root of the subtree to capture; ancestor visibility is respected.
Returns
Owning snapshot, a tree access error, NO_MEMORY, or INVALID_GEOMETRY when an effectively visible node has no valid arranged geometry. Hidden nodes need no valid geometry and receive zero size; disabled nodes retain their arranged size.

◆ capture() [2/2]

std::expected< LayoutSnapshot, TreeError > portals::LayoutSnapshot::capture ( WidgetTree & tree,
Node< Widget > node,
LayoutSnapshotProfile profile )
staticnodiscard

Opt into geometry capture without changing the original overload's allocation path.

Parameters
treeUI tree after successful complete layout, inside its frame.
nodeRoot identity; ancestor visibility is respected.
profileDIMENSIONS delegates the old overload; GEOMETRY owns optional parallel storage.
Returns
Owning snapshot or original tree/allocation/geometry/clip error; unknown profile is INVALID_ARGUMENT. Extra O(nodes) work/storage applies only to GEOMETRY. Existing pure childClip runs under tree.read; no controller publication, invalidation or user notification occurs.

◆ geometry()

std::expected< LayoutGeometrySnapshot, TreeError > portals::LayoutSnapshot::geometry ( Node< Widget > node) const
nodiscardnoexcept
Parameters
nodeCaptured full session/slot/generation identity.
Returns
Owning geometry, INVALID_ARGUMENT without GEOMETRY, or WRONG_SESSION/STALE_NODE. No live tree is consulted; copies and concurrent const reads are safe.

◆ geometryRevision()

std::expected< std::uint64_t, TreeError > portals::LayoutSnapshot::geometryRevision ( ) const
nodiscardnoexcept
Returns
Nonzero tree revision at capture, or INVALID_ARGUMENT without GEOMETRY profile. A completed-pass identity does not grant permission to read later live geometry.

◆ viewport()

std::expected< CellSize, TreeError > portals::LayoutSnapshot::viewport ( Node< Widget > node) const
nodiscardnoexcept

Read a captured local extent without consulting the current tree.

Parameters
nodeObserver identifying the captured session, slot and generation.
Returns
Captured width/height in cells, zero for an effectively hidden node, WRONG_SESSION for another tree, or STALE_NODE for an empty/absent identity or a moved-from snapshot. Removal after capture does not invalidate captured identities.
Note
No allocation, tree affinity, mutation or exceptions; clipping does not reduce this extent.

The documentation for this class was generated from the following file: