GGUI::GGLooks class

GGLooks: a per-document cache of resolved styles.

Resolving a style layers every matching rule over the default, so it is done once per class and state and cached until the table changes. Each document owns its cache, so documents updating in parallel never write anything another reads.

Single-threaded. A returned style is valid until the table next changes.

Public functions

void Use(const StyleTable* table)
The table to resolve from. Changing it clears the cache.
auto Table() const -> const StyleTable*
The table it resolves from.
void UseScopes(std::span<const GGStyleScopes*const> sets)
Scopes resolved with the table: a widget library's, the document's own, and those of the documents a popup belongs to. Not owned; null entries are skipped.
auto Revision() -> uint64_t
Changes whenever a look may have: the table's revision, plus one for each time the scopes changed. Only comparable between calls on this cache with the same table.
auto Find(uint64_t classKey, uint8_t state = 0) -> const PaintStyle&
Resolved style for a class key (UIStyle.h: ClassKey) in state (NodeState bits). Elements that resolve identically get the same PaintStyle object.
auto ChangedAt(uint64_t classKey, uint8_t state = 0) -> uint64_t
The table revision at which this class and state's style last actually changed.
auto LayoutChangedAt(uint64_t classKey) -> uint64_t
Same, for layout-affecting properties: spacing and the font text is measured in.
auto Bytes() const -> size_t
Memory held.

Function documentation

uint64_t GGUI::GGLooks::ChangedAt(uint64_t classKey, uint8_t state = 0)

The table revision at which this class and state's style last actually changed.

A table change that doesn't affect it (another class's rule, an unused token) leaves this alone, so anything painted at or after that revision needn't repaint.