GGUI/Public/Snapshot.h file

GGSnapshot: a UI document as other threads see it.

The UI update is the only writer of a document. The input thread (hit testing) and the render thread read a published snapshot instead. A snapshot is self-contained, so a reader can hold one for as long as it likes while the document moves on.

A snapshot mirrors the document: one row per node at the node's slot, linked to parent, first child, and next sibling. Rows are in chunks aligned with the document's, and consecutive snapshots share every chunk that didn't change. Publishing only writes the nodes that changed.

Positions are in document space (UI units, origin top left), not window space, so one snapshot serves a window, a world panel, or an offscreen target.

Scrolling: a row stores where its node is with nothing scrolled. Each scrolling box's offset is stored separately (Spaces), so scrolling writes one value and no rows. A node's on-screen position is its rect minus the offset of every scrolling box above it: see Placed, Showing, InView. Hit testing and painting apply the offsets as they descend.

Namespaces

namespace GGUI

Classes

struct GGUI::SnapshotNode
One node as a snapshot holds it.
struct GGUI::SnapshotEmbed
A ui.Embed area as shown: on screen, clipped, in UI units.
struct GGUI::SnapshotRun
Where a node's primitives are: a range of GGSnapshot::Primitives slots it owns for as long as it is visible, plus the clips it and its children draw under.
template<typename T, uint32_t PerChunk>
class GGUI::SharedChunks
SharedChunks: an indexed array in ref-counted chunks shared between consecutive snapshots.
struct GGUI::SnapshotSpace
Scroll offset of a scrolling box (SnapSpace), in whole pixels so pixel-snapped content stays snapped.
class GGUI::SnapshotOrder
Draw order: slots of GGSnapshot::Primitives, back to front. Shared between snapshots while the set of visible things and their order doesn't change.
struct GGUI::SnapshotImage
What an image or viewport node shows.
struct GGUI::SnapshotSpan
One span of rich text as drawn: its class (text colour, background), or the image in its box.
struct GGUI::SnapshotScroll
A scrolling box's offset and content size. Scroll bars are drawn from this.
struct GGUI::SnapshotMark
An overlay drawn on a text widget.
struct GGUI::SnapshotToolMark
A debug overlay drawn by a tool: an outline or a tint.
class GGUI::SnapshotRows
A snapshot's node rows. Copying copies every row; the snapshot being written shares with the previous one instead (ShareFrom).
class GGUI::GGSnapshot
A document as other threads see it. See the file description.
class GGUI::GGSnapshot::Walker
Every node in pre-order, which is also draw order: for (const SnapshotNode& node : snapshot.Walk()).
class GGUI::GGSnapshot::Walker::Iterator
A position in the walk.
struct GGUI::GGSnapshot::View
Where rows are drawn: at M * position - (X, Y), M = [A B; C D]. The scrolls, zooms, and group transforms of every enclosing space, composed.
class GGUI::SnapshotRead
A read lock on a snapshot: it can't change or be reused while this exists.
class GGUI::SnapshotChain
SnapshotChain: the latest snapshot, published by one thread and read by others.