forked from Nlcke/layout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
74 lines (61 loc) · 1.65 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
local examples = Layout.newResources{
path = "|R|examples",
namemod = function(name, path, base, ext, i) return base end
}
local layout
local backbutton = Layout.new{
texture = backbuttonTexture,
ancX = 1, ancY = 0,
relW = 0.1, relH = 0.1,
limW = 1, limH = 1,
anPress = Layout.newAnimation(14, 7, 0.04),
anHover = Layout.newAnimation(14, 7, 0.02),
anAdd = Layout.newAnimation(),
anRemove = Layout.newAnimation(),
onPress = function(self)
for _,child in pairs(stage.__children) do
child:removeFromParent()
end
stage:addChild(layout)
Layout.select(layout)
end
}
backbutton:addEventListener(Event.ENTER_FRAME, function()
if backbutton:getParent() == stage then
stage:addChild(backbutton)
end
end)
local Button = Layout:with{
text = "BUTTON",
textColor = 0xFFFFFF,
bgrA = 1.0,
init = function(self, p)
self.textfield = TextField.new(font, self.text, "Pq|")
self.textfield:setTextColor(self.textColor)
self:addChild(self.textfield)
end,
upd = function(self, p)
if p.text then self.textfield:setText(p.text) end
end,
anPress = Layout.newAnimation(14, 7, 0.04),
anHover = Layout.newAnimation(14, 7, 0.02),
selector = Layout.new{bgrC = 0x0088FF, bgrA = 0.25},
onPress = function(self)
stage:addChild(backbutton)
Layout.select(backbutton)
examples[self.text]()
layout:removeFromParent()
end
}
local database = {}
for i = 1, #examples do database[i] = {text = examples[-i]} end
layout = Layout.new{
template = Button, database = database, scroll = true,
anAdd = Layout.newAnimation(),
anRemove = Layout.newAnimation(),
cellAbsH = 50,
cellBrdW = 5, cellBrdH = 5,
cols = 1,
}
stage:addChild(layout)
Layout.select(layout)