Raxol.UI.Layout.Grid (Raxol v2.0.1)
View SourceGrid layout utility functions.
Summary
Functions
Creates grid cell information for a grid layout.
Calculates spacing between grid cells based on gap value.
Calculates the position for a cell in the grid.
Measures the space needed by a grid element.
Creates a new grid layout with the given options.
Processes a grid element, calculating layout for it and its children.
Renders the grid layout.
Functions
Creates grid cell information for a grid layout.
Parameters
grid_attrs- The grid attributesspace- The available space
Returns
A map containing cell dimensions and grid information.
Calculates spacing between grid cells based on gap value.
Returns a map with calculated spacing values.
Calculates the position for a cell in the grid.
Parameters
col- The column index (0-based)row- The row index (0-based)grid_cells- The grid cell information fromcalculate_grid_cells/2space- The base space for the grid
Returns
A space map with x, y, width, and height for the cell.
Measures the space needed by a grid element.
Parameters
grid- The grid element to measureavailable_space- The available space for the grid
Returns
The dimensions of the grid: %{width: w, height: h}
Creates a new grid layout with the given options.
Options
:columns- number of columns:rows- number of rows:gap- gap between cells:children- child elements:width- grid width:height- grid height
Processes a grid element, calculating layout for it and its children.
Parameters
grid- The grid element to processspace- The available space for the gridacc- The accumulator for rendered elements
Returns
A list of positioned elements with absolute coordinates.
Renders the grid layout.
Returns the layout with calculated positions for all children.