diff options
author | David McMackins II <contact@mcmackins.org> | 2017-09-01 07:00:21 -0500 |
---|---|---|
committer | David McMackins II <contact@mcmackins.org> | 2017-09-01 07:00:21 -0500 |
commit | b11650117c6927b4a8a4d80697c7903c3a7341c8 (patch) | |
tree | 629a0fe634af5b6328f9be0809f4e981a679b462 | |
parent | b0a8a67b895e03b095bb897d7b7a89193b130d65 (diff) |
Add Gui class
-rw-r--r-- | gui.lua | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -40,6 +40,57 @@ require 'class' local defaultfont = love.graphics.getFont() +Gui = class() + +function Gui:__init() + self._components = {} + self._active = nil +end + +function Gui:addcomponent(component) + table.insert(self._components, component) +end + +function Gui:mousepressed(x, y, button) + for _,component in ipairs(self._components) do + if component:mousepressed(x, y, button) then + return true + end + end + + return false +end + +function Gui:mousereleased(x, y, button) + for _,component in ipairs(self._components) do + if component:mousereleased(x, y, button) then + return true + end + end + + return false +end + +function Gui:textinput(c) + for _,component in ipairs(self._components) do + if component:textinput(c) then + return true + end + end + + return false +end + +function Gui:keypressed(key, isrepeat) + for _,component in ipairs(self._components) do + if component:keypressed(key, isrepeat) then + return true + end + end + + return false +end + local function normalizedim(d) if type(d) ~= 'function' then return function(self) return d end |