-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.lua
More file actions
44 lines (34 loc) · 1.09 KB
/
button.lua
File metadata and controls
44 lines (34 loc) · 1.09 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
local widget = require("widget")
local button = {}
button.__index = button
setmetatable(button, widget)
function button.new(app, x, y, label)
local self = {}
setmetatable(self, button)
button.init(self, app, x, y, label)
return self
end
function button.init(self, app, x, y, label)
widget.init(self, app)
self.width = 150
self.height = 30
self.x = x
self.y = y
self.text = label
self.textPos = "center"
end
function button.draw(self)
local color = self:getColor()
love.graphics.setColor(color.fill)
love.graphics.rectangle("fill", self.x, self.y, self.width, self.height, self.radius.x,self.radius.y)
love.graphics.setColor(color.stroke)
love.graphics.rectangle("line", self.x, self.y, self.width, self.height, self.radius.x,self.radius.y)
love.graphics.setColor(color.text)
love.graphics.printf(self.text, self.x,self.y, self.width - self.padding.x * 2, self.textPos, 0, self.height / 30, self.height / 30, self.padding.x *-1, self.padding.y * -1)
end
function button.keyPressed(self, handled, key)
if self.focused then
return true
end
end
return button