|
TinyMaterialDesign
|
Computes wrapping rects for items of varying width (chip/tag rows). More...
#include <FlowLayout.h>
Public Member Functions | |
| FlowLayout (Bounds container, int32_t spacing=8) | |
| Bounds | next (int32_t width, int32_t height) |
| void | reset () |
| Restarts packing from the container's top-left corner. | |
| int32_t | totalHeight () const |
| Total height consumed by items placed since the last reset(). | |
Computes wrapping rects for items of varying width (chip/tag rows).
Not a widget - see GridLayout.h for the rationale. Unlike GridLayout (uniform cells), each item reports its own width; items are packed left-to-right and wrap to a new row once they would overflow the container's width:
FlowLayout flow(Bounds(16, 56, 308, 200)); int32_t widths[] = {60, 90, 70, 100, 50}; for (int i = 0; i < 5; ++i) chips[i].bounds = flow.next(widths[i], chipHeight);
Calls to next() must be made in order (0, 1, 2, ...) since each call advances internal cursor state. Use totalHeight() after a full pass, or reset() to run the same set of widths again once you know it.
|
inlineexplicit |
|
inline |
Bounds for the next item of the given width/height, wrapping to a new row if it doesn't fit in the remaining width of the current row.
|
inline |
Restarts packing from the container's top-left corner.
|
inline |
Total height consumed by items placed since the last reset().