-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.lua
More file actions
71 lines (60 loc) · 1.74 KB
/
application.lua
File metadata and controls
71 lines (60 loc) · 1.74 KB
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
local application = {}
application.__index = application
function application.new()
local self = {widgets = {}}
self.color = {text={1,1,1,1}, fill= {0.8,0.8,0.8,1}, stroke = {1,1,1,1}},
setmetatable(self, application)
love.keyboard.setTextInput( true )
love.keyboard.setKeyRepeat( true )
return self
end
function application.draw(self)
local width, height = love.graphics.getDimensions( )
love.graphics.setColor(self.color.fill)
love.graphics.rectangle("fill", 0, 0, width, height, 0,0)
for k,v in pairs(self.widgets) do
v:draw()
end
for k,v in pairs(self.widgets) do
v:drawAfter()
end
end
function application.addWidget(self, widget)
table.insert(self.widgets, widget)
end
function application.update(self, dt)
for k,v in pairs(self.widgets) do
v:update(dt)
end
end
function application.mouseReleased(self, x, y, button, isTouch)
local handled = false
for k,v in pairs(self.widgets) do
handled = v:mouseReleased(handled, x, y, button, isTouch) or handled
end
end
function application.mousePressed(self, x, y, button, isTouch)
local handled = false
for k,v in pairs(self.widgets) do
handled = v:mousePressed(handled, x, y, button, isTouch) or handled
end
end
function application.wheelMoved(self, x, y)
local handled = false
for k,v in pairs(self.widgets) do
handled = v:wheelMoved(handled, x, y) or handled
end
end
function application.keyPressed(self, key, code, isRepeat)
local handled = false
for k,v in pairs(self.widgets) do
handled = v:keyPressed(handled, key, code, isRepeat) or handled
end
end
function application.textInput(self, key)
local handled = false
for k,v in pairs(self.widgets) do
handled = v:textInput(handled, key) or handled
end
end
return application