-
Notifications
You must be signed in to change notification settings - Fork 15
(API) Grid
function love.load()
loveframes = require("loveframes")
local grid = loveframes.Create("grid")
grid:SetPos(5, 30)
grid:SetRows(5)
grid:SetColumns(5)
grid:SetCellWidth(25)
grid:SetCellHeight(25)
grid:SetCellPadding(5)
grid:SetItemAutoSize(true)
grid:ColSpanAt(1, 1, 2)
grid:RowSpanAt(1, 1, 2)
local id = 1
local button = loveframes.Create("button")
button:SetSize(15, 15)
button:SetText(id)
grid:AddItem(button, 1, 1, 'center')
id = id + 1
for i=1, 5 do
for n=1, 5 do
if (i > 2 or n > 2) then
local button = loveframes.Create("button")
button:SetSize(15, 15)
button:SetText(id)
grid:AddItem(button, i, n)
end
id = id + 1
end
end
end
function love.update(dt)
loveframes.update(dt)
end
function love.draw()
loveframes.draw()
end
function love.mousepressed(x, y, button)
loveframes.mousepressed(x, y, button)
end
function love.mousereleased(x, y, button)
loveframes.mousereleased(x, y, button)
end
The grid object has no unique event callbacks.
Adds an item to the object
object:AddItem(object[object], row[number], column[number], align['left', 'center', 'right'])
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()
Expands the size of the column at position
object:ColSpanAt(row[number], col[number], size[number])
Expands the size of the row at position
object:RowSpanAt(row[number], col[number], size[number])