TinyMaterialDesign
Loading...
Searching...
No Matches
Public Member Functions | List of all members
GridLayout Class Reference

Computes wrapped grid cell positions for a row of equal-size cards. More...

#include <GridLayout.h>

Public Member Functions

 GridLayout (Bounds container, int32_t cellWidth, int32_t cellHeight, int32_t spacing=8)
 
Bounds cellRect (int index) const
 Bounds for the index-th cell (0-based, row-major).
 
int columns () const
 
int32_t totalHeight (int count) const
 Total height needed to lay out count items.
 

Detailed Description

Computes wrapped grid cell positions for a row of equal-size cards.

Not a widget - TinyMaterialDesign deliberately has no auto-layout container (widgets always get an explicit Bounds), so this is a small calculator you use before constructing/positioning widgets, the same way Dialog::actionRect()/Drawer::itemRect() suggest single-widget spots:

GridLayout grid(Bounds(16, 56, 308, 400), 90, 110); for (size_t i = 0; i < cards.size(); ++i) cards[i].bounds = grid.cellRect(i);

As many columns as fit container's width are used; further items wrap to additional rows. Rows are not clipped to the container's height - use totalHeight() to size a scroll area or decide how many items actually fit.

Constructor & Destructor Documentation

◆ GridLayout()

GridLayout ( Bounds  container,
int32_t  cellWidth,
int32_t  cellHeight,
int32_t  spacing = 8 
)
inline

Member Function Documentation

◆ cellRect()

Bounds cellRect ( int  index) const
inline

Bounds for the index-th cell (0-based, row-major).

◆ columns()

int columns ( ) const
inline

◆ totalHeight()

int32_t totalHeight ( int  count) const
inline

Total height needed to lay out count items.


The documentation for this class was generated from the following file: