mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
39 lines
828 B
Lua
39 lines
828 B
Lua
|
local example = {}
|
||
|
example.title = "Grid"
|
||
|
example.category = "Object Demonstrations"
|
||
|
|
||
|
function example.func(loveframes, centerarea)
|
||
|
|
||
|
local frame = loveframes.Create("frame")
|
||
|
frame:SetName("Grid")
|
||
|
frame:CenterWithinArea(unpack(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(centerarea))
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
return example
|