Raxol.UI.Layout.Grid (Raxol v0.4.0)

View Source

Handles layout calculations for grid UI elements.

This module is responsible for:

  • Grid-based layout calculations
  • Cell sizing and positioning
  • Column and row spanning elements
  • Grid-specific spacing and constraints

Summary

Functions

Creates grid cell information for a grid layout.

Calculates the position for a cell in the grid.

Measures the space needed by a grid element.

Processes a grid element, calculating layout for it and its children.

Functions

calculate_grid_cells(grid_attrs, space)

Creates grid cell information for a grid layout.

Parameters

  • grid_attrs - The grid attributes
  • space - The available space

Returns

A map containing cell dimensions and grid information.

cell_position(col, row, grid_cells, space)

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 from calculate_grid_cells/2
  • space - The base space for the grid

Returns

A space map with x, y, width, and height for the cell.

measure_grid(map, available_space)

Measures the space needed by a grid element.

Parameters

  • grid - The grid element to measure
  • available_space - The available space for the grid

Returns

The dimensions of the grid: %{width: w, height: h}

process(arg1, space, acc)

Processes a grid element, calculating layout for it and its children.

Parameters

  • grid - The grid element to process
  • space - The available space for the grid
  • acc - The accumulator for rendered elements

Returns

A list of positioned elements with absolute coordinates.