Implemented by widgets that can report how much space their content wants, which is what makes SizeConstraint.Auto size to content. More...
Public Member Functions | |
| Size | Measure (int availableWidth, int availableHeight) |
| The size this widget's content wants, given what is on offer. | |
| Public Member Functions inherited from ConsoleForge.Layout.IWidget | |
| void | Render (IRenderContext ctx) |
| Render this widget into the provided context. | |
Additional Inherited Members | |
| Properties inherited from ConsoleForge.Layout.IWidget | |
| SizeConstraint | Height [get] |
| Height constraint used by the layout engine. | |
| Style | Style [get] |
| Visual style for this widget. Inherits from Theme if unset. | |
| SizeConstraint | Width [get] |
| Width constraint used by the layout engine. | |
Implemented by widgets that can report how much space their content wants, which is what makes SizeConstraint.Auto size to content.
Opting in is what turns Auto from a promise into behaviour. A widget that does not implement this interface keeps the older meaning — Auto resolves as flex weight 1 — so adding this to the framework moved no existing third-party layout.
Measure is called during layout, before any region is assigned, and must be pure: same inputs, same answer, no side effects, no writing to a render context. It is called once per Auto axis per layout pass, and layout runs per frame, so it should stay cheap.
Implementations must not report more than they were offered. Clamping to the available size keeps a container's children from over-subscribing it in the common case, and the available size is the only bound the solver can offer for content that could otherwise grow without limit.
| Size ConsoleForge.Layout.IMeasurable.Measure | ( | int | availableWidth, |
| int | availableHeight ) |
The size this widget's content wants, given what is on offer.
Both components must be within [0, available] — see the remarks on IMeasurable.
| availableWidth | Columns available. |
| availableHeight | Rows available. |