GGUI/Public/Layout.h file

Layout: a flex-style box model.

Each node has a size rule per axis (fit content, fixed, share of leftover space, percent of parent). Containers place children in a row, a column, or stacked, with padding, gap, and alignment.

Widths are resolved before heights, because wrapped text's height depends on its width:

1. Measure widths    bottom-up
2. Arrange widths    top-down
3. Measure heights   bottom-up, at the final widths
4. Arrange heights   top-down

Rects are snapped to the physical pixel grid when read.

Layout is incremental. A node whose wanted size didn't change doesn't dirty its parent, and a fixed-size container never propagates a child's change upward.

The solver is a template instantiated for float (presentation) and for fixed-point (bit-identical results on every machine).

Namespaces

namespace GGUI

Classes

struct GGUI::GGRect
A node's rect in document space, in UI units, pixel-snapped.
struct GGUI::TextSpan
Part of a paragraph styled apart from the rest, or an inline box: what rich text is made of.
struct GGUI::TextRequest
Text to measure: what it says and how it is set.
struct GGUI::TextMetrics
How big measured text is.
struct GGUI::TextMeasurer
Text measurement backend. MeasureFixedMetric is used until one is set.
struct GGUI::LayoutStats
What one UpdateLayout call did.