summaryrefslogtreecommitdiffhomepage
path: root/element.lua
blob: f9d1c3d268a95f0a4ff955b98c2cf512fe4cd3dd (plain)
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
-- `Element`
-- Empty element for `Menu` creation. Can be anything.
Element = {
	x = 0,
	y = 0,
	parent
}
function Element:new(parent)
	local o = {}
	setmetatable(o, self)
	self.__index = self
	o.parent = parent
	return o
end
function Element:delete() end -- deletes Element
function Element:getPosition() return self.x, self.y end -- gives x,y of Element
function Element:setPosition(x,y)
	self.x, self.y = x, y
	return self
end
function Element:set(name, func)
	if type(name) == "string" and func ~= nil then
		self[name] = func
	end
	return self
end

-- Menu callbacks
function Element:focus() -- Called when Element gains focus
	return false
end 
function Element:blur() end -- Called when Element loses focus

-- LÖVE2D callbacks
function Element:draw(scale) end
function Element:update(dt) end

-- Controller callbacks
function Element:controlpressed(set, action, key) end
function Element:controlreleased(set, action, key) end

return Element