GGUI::GGSnapshot class

A document as other threads see it. See the file description.

Public types

class Walker
Every node in pre-order, which is also draw order: for (const SnapshotNode& node : snapshot.Walk()).
struct 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.

Public static variables

static uint32_t NoEntry constexpr
no table entry
static uint32_t NoSlot constexpr
no row
static GGRect Everything constexpr
A rect that clips nothing: the clip of a scroll space's direct content.
static uint32_t MaxDeltas constexpr
Recent changes: Deltas[0] is the change from the previous snapshot, Deltas[1] the one before, and so on.

Public functions

auto At(uint32_t slot) const -> const SnapshotNode*
Row at a slot (NodeHandle::Index), or null.
auto Find(NodeHandle node) const -> const SnapshotNode*
The node's row, or null if it isn't in this snapshot.
auto Root() const -> const SnapshotNode*
The root's row; null if nothing is published.
auto Parent(const SnapshotNode& node) const -> const SnapshotNode*
The parent's row; null for the root.
auto FirstChild(const SnapshotNode& node) const -> const SnapshotNode*
The first child's row; null if none.
auto NextSibling(const SnapshotNode& node) const -> const SnapshotNode*
The next sibling's row; null for the last.
auto NodeCount() const -> uint32_t
How many nodes it has.
auto Walk() const -> Walker
Every node in pre-order.
auto ImageOf(const SnapshotNode& node) const -> const SnapshotImage*
Null unless the node is an image or viewport.
auto DrawingOf(const SnapshotNode& node) const -> std::span<const UIPrimitive>
A canvas's drawing, in its own units; empty for anything else.
auto SpansOf(const SnapshotNode& node) const -> std::span<const SnapshotSpan>
Rich text's spans, by TextRequest::Spans index; empty for other text.
auto NameOf(const SnapshotNode& node) const -> std::string_view
The node's accessible name; empty if none.
auto DescriptionOf(const SnapshotNode& node) const -> std::string_view
The node's accessible description; empty if none.
auto PrimitivesOf(NodeHandle node) const -> std::vector<UIPrimitive>
The node's primitives; empty if it draws nothing. For tools and tests.
auto RunOf(NodeHandle node) const -> const SnapshotRun*
Null if the node wasn't visited when this snapshot was painted (nothing in its subtree shows).
auto Drawn() const -> std::vector<UIPrimitive>
Everything drawn, back to front, as one list: node primitives in order, then the overlay.
auto ViewOf(uint32_t space) const -> View
The view for content inside the space at space (a SnapshotNode::Space; none means no offset and no clip). Walks up the spaces, of which there are few.
auto OwnView(const SnapshotNode& node) const -> View
The view node itself is drawn in: its space's, turned by its own transform if it has one.
auto ScrolledBy(uint32_t slot) const -> SnapshotSpace
Scroll offset of the box at slot; zero if it isn't a scroll space.
auto Placed(const SnapshotNode& node) const -> GGRect
On-screen rect: Bounds minus the offset of every enclosing scroll space.
auto Placed(const SnapshotMark& mark) const -> GGRect
On-screen rect of a mark, positioned like its widget's content.
auto Showing(const SnapshotNode& node) const -> GGRect
The visible part of the node on screen; empty if none.
auto InView(const SnapshotNode& node) const -> bool
True if anything in the node's subtree is visible and not scrolled out of view.
auto HitTest(float x, float y, uint8_t require = 0) const -> NodeHandle
Topmost visible node at a document-space point, or a null handle.
auto Bytes() const -> size_t
Memory held, counting shared rows as its own.

Public variables

SnapshotRows Rows
a row per node, at its slot
uint32_t RootSlot
the root's slot
uint32_t Count
node count
uint32_t Focusable
focusable node count
uint32_t RowsWritten
rows that differ from the previous snapshot
SnapshotSpaces Spaces
Scroll offset per scroll space, by slot. Shared with the previous snapshot like the rows. bScrolled: at least one offset changed.
bool bScrolled
see Spaces
SnapshotRuns Runs
Primitive range per node, by slot. A node with nothing visible has none (RunShown).
std::vector<uint32_t> Repainted
Slots to repaint regardless of their rows: something changed that a row doesn't capture (e.g. text of the same size).
std::vector<uint32_t> Touched
Slots whose rows changed in a way that may be visible. What painting visits when nothing else changed. May contain duplicates.
std::vector<PaintStyle> Looks
Interpolated styles of nodes mid-transition (SnapshotNode::Look).
std::vector<SnapshotScroll> Scrolls
Every scrolling box and every widget that draws its own scroll bar, unordered.
std::vector<SnapshotMark> Marks
Selection and caret of the focused text widget, back to front.
SnapshotPrimitives Primitives
Draw data (see Paint.h).
SnapshotOrder Order
see Primitives
uint32_t PrimitiveEnd
see Primitives
std::vector<UIPrimitive> Overlay
see Primitives
std::vector<UIClip> Clips
see Primitives
PaintStats Painted
PaintDelta Deltas
see the description above
uint32_t DeltaCount
std::vector<GGRect> Layers
Rects of popups drawn as layers over the document (nested ones included). They block the pointer.
std::vector<SnapshotEmbed> Embeds
Areas something else draws and takes the pointer in (ui.Embed): the visible part of each.
bool bCapture
a menu or Popup is open: all pointer and key input is the UI's
uint32_t PopupCount
open popups, tooltips included
std::vector<SnapshotToolMark> ToolMarks
tool overlays (UIContext::SetDebugOverlays), drawn over everything
bool bFlashRepaints
a tool asked for repainted nodes to be tinted
GGRect Highlight
tool outline of the inspected node (if bHighlight)
bool bHighlight
Highlight is drawn.
bool bPickMode
a tool is picking: the pointer over this document belongs to the tool (PointerRouter)
NodeHandle Focused
null = none
bool bKeyboardFocus
focus came from the keyboard: keys belong to the UI (KeyRouter)
bool bHasFocusable
there is something Tab could reach
bool bTextFocus
a text widget has focus: every key belongs to the UI
bool bTextEntry
the platform should deliver text input
GGRect TextCaret
caret rect, for the IME window (if bTextFocus)
uint64_t Sequence
publish counter; increases with each snapshot
uint64_t Document
owning document; sequence numbers are only comparable within one document
float Width
the document's surface, UI units
float Height
the document's surface, UI units
float Scale
physical pixels per UI unit

Function documentation

std::vector<UIPrimitive> GGUI::GGSnapshot::Drawn() const

Everything drawn, back to front, as one list: node primitives in order, then the overlay.

For tools, tests, and the reference rasterizer. The per-frame path uses Order and copies nothing.

NodeHandle GGUI::GGSnapshot::HitTest(float x, float y, uint8_t require = 0) const

Topmost visible node at a document-space point, or a null handle.

require filters to nodes with all of those flags (SnapBlocks: what the pointer is over; SnapClickable: what a click would reach). Descends only through nodes whose Reach contains the point.

Variable documentation

static uint32_t GGUI::GGSnapshot::MaxDeltas constexpr

Recent changes: Deltas[0] is the change from the previous snapshot, Deltas[1] the one before, and so on.

A consumer holding an older copy of the primitives catches up by applying every delta back to the one it has.

SnapshotPrimitives GGUI::GGSnapshot::Primitives

Draw data (see Paint.h).

Each node owns a stable range of Primitives slots (Runs), so a changed node rewrites its own slots and nothing moves. Order lists the slots back to front; reserved-but-unused slots hold a primitive that draws nothing. PrimitiveEnd is one past the last slot in use. Overlay is drawn over all nodes (scroll bars, caret, popups) and belongs to no node. Clips is the table primitives index; a clipping node keeps its entry while it clips.

PaintStats GGUI::GGSnapshot::Painted

what painting this snapshot did

uint32_t GGUI::GGSnapshot::DeltaCount

how many of Deltas are filled