-
Notifications
You must be signed in to change notification settings - Fork 81
(API) Grid
local frame = loveframes.Create("frame")
frame:SetName("Grid")
frame:CenterWithinArea(unpack(demo.centerarea))
local grid = loveframes.Create("grid", frame)
grid:SetPos(5, 30)
grid:SetRows(5)
grid:SetColumns(5)
grid:SetCellWidth(25)
grid:SetCellHeight(25)
grid:SetCellPadding(5)
grid:SetItemAutoSize(true)
local id = 1
for i=1, 5 do
for n=1, 5 do
local button = loveframes.Create("button")
button:SetSize(15, 15)
button:SetText(id)
grid:AddItem(button, i, n)
id = id + 1
end
end
grid.OnSizeChanged = function(object)
frame:SetSize(object:GetWidth() + 10, object:GetHeight() + 35)
frame:CenterWithinArea(unpack(demo.centerarea))
endThe grid object has no unique event callbacks.
Adds an item to the object
object:AddItem(object[object], row[number], column[number])Gets an item from the object at the specified row and column
Returns 1 value: item [object] or false [boolean] if no item was found
local item = object:GetItem(row[number], column[number])Sets whether or not the object should auto-size its items
object:SetItemAutoSize(autosize[bool])Gets whether or not the object should auto-size its items
Returns 1 value: autosize [boolean]
local autosize = object:GetItemAutoSize()Sets the number of rows the object should have
object:SetRows(rows[number])Gets the number of rows the object has
Returns 1 value: rows [number]
local rows = object:GetRows()Sets the number of columns the object should have
object:SetColumns(columns[number])Gets the number of columns the object has
Returns 1 value: columns [number]
local columns = object:GetColumns()Sets the width of the object's cells
object:SetCellWidth(cellwidth[number])Gets the width of the object's cells
Returns 1 value: cellwidth [number]
local cellwidth = object:GetCellWidth()Sets the height of the object's cells
object:SetCellHeight(cellheight[number])Gets the height of the object's cells
Returns 1 value: cellheight [number]
local cellheight = object:GetCellHeight()Sets the size of the object's cells
object:SetCellSize(cellwidth[number], cellheight[number])Gets the size of the object's cells
Returns 2 value: cellwidth [number], cellheight [number]
local cellwidth, cellheight = object:GetCellSize()Sets the padding of the object's cells
object:SetCellPadding(cellpadding[number])Gets the padding of the object's cells
Returns 1 value: cellpadding [number]
local cellpadding = object:GetCellPadding()