Grid Layouts#
Functions#
Classes#
- class eg-overlay-ui.uigrid#
A grid layout container. Grid layout containers arrange their child elements into an aligned grid or table.
Grids must have a known number of columns and rows when they are created. This can not be changed after a grid is created.
Example#local ui = require 'overlay-ui' local uih = require 'ui-helpers' -- a 3x3 grid local grid = ui.grid(3, 3) local a = uih.text('Top Left') local b = uih.text('Top Middle & Right') local c = uih.text('Middle') local d = uih.text_button('Bottom Left & Middle') local e = uih.text_button('Bottom Right') -- arrange elements in this pattern -- -- +-------------+-----------------------+ -- | Top Left | Top Middle & Right | -- +-------------+-----------------------+ -- | Middle | | -- +----------------------+ Bottom Right + -- | Bottom Left & Middle | | -- +----------------------+--------------+ grid:attach(a, 1, 1) -- Top Left grid:attach(b, 1, 2, 1, 2, 'end' , 'start') -- Top Middle & Right grid:attach(c, 2, 1, 1, 2, 'middle', 'start') -- Middle grid:attach(d, 3, 1, 1, 2, 'middle', 'middle') -- Bottom Left & Middle grid:attach(e, 2, 3, 2, 1, 'middle', 'middle') -- Bottom Right
- attach(uielement, row, column[, rowspan, colspan[, horizalign, vertalign]])#
Attach a UI element to this grid at the given
row
andcolumn
. If there was already an element at this location it will be removed first.By default, the element will only occupy one cell. This can be changed by providing a value for
rowspan
andcolspan
. While both are optional, both must be provided if either is to be set.The element will be aligned to the top left of the cell by default. This can also be changed by proving
horizalign
andvertalign
. Like the col/row span arguments, these are both optional but both must be provided if either is to be set.- Parameters:
uielement – A UI element.
row (
integer
) – Row number. This must be between 1 and the number of rows specified ingrid()
.column (
integer
) – Column number. This must be between 1 and the number of columns specified ingrid()
.rowspan (
integer
) – (Optional) The number of rows this element will span. This must be between 1 and the number of remaining rows in the grid. Default:1
colspan (
integer
) – (Optional) The number of columns this element will span. This argument must be present whenrowspan
is. This must be between 1 and the number of remaining columns remaining in the grid. Default:1
horizalign (
string
) – Horizontal alignment.'start'
,'middle'
,'end'
, or'fill'
.vertalign (
string
) – Vertical alignment.'start'
,'middle'
,'end'
, or'fill'
.
Version History
Version
Notes
0.1.0
Added
- rowspacing([row, ]spacing)#
Set the spacing between
row
and the next row tospacing
pixels.If
row
is omitted, all rows will be set to usespacing
Version History
Version
Notes
0.1.0
Added
- colspacing([column, ]spacing)#
Set the spacing between
column
and the next column tospacing
pixels.If
column
is omitted, all columns will usespacing
Version History
Version
Notes
0.1.0
Added
- background([color])#
Set or retrieve background color. If a background color with an alpha value of 0 is specified, no background is drawn.
Version History
Version
Notes
0.1.0
Added
- addeventhandler(func)#
Add an event handler for this UI element. See UI Events.
- Parameters:
func (
function
)- Return type:
- Returns:
A id that can be used with
removeeventhandler()
Version History
Version
Notes
0.1.0
Added