Add widget state setter, fi-lo drawing order.
This commit is contained in:
parent
6cb5596437
commit
c0943eae16
2 changed files with 20 additions and 1 deletions
18
core.lua
18
core.lua
|
@ -36,6 +36,10 @@ function suit.getOptionsAndSize(opt, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- gui state
|
-- gui state
|
||||||
|
function suit:setHovered(id)
|
||||||
|
return self.hovered ~= id
|
||||||
|
end
|
||||||
|
|
||||||
function suit:anyHovered()
|
function suit:anyHovered()
|
||||||
return self.hovered ~= nil
|
return self.hovered ~= nil
|
||||||
end
|
end
|
||||||
|
@ -48,6 +52,10 @@ function suit:wasHovered(id)
|
||||||
return id == self.hovered_last
|
return id == self.hovered_last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function suit:setActive(id)
|
||||||
|
return self.active ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
function suit:anyActive()
|
function suit:anyActive()
|
||||||
return self.active ~= nil
|
return self.active ~= nil
|
||||||
end
|
end
|
||||||
|
@ -56,6 +64,14 @@ function suit:isActive(id)
|
||||||
return id == self.active
|
return id == self.active
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function suit:setHit(id)
|
||||||
|
self.hit = id
|
||||||
|
-- simulate mouse release on button -- see suit:mouseReleasedOn()
|
||||||
|
self.mouse_button_down = false
|
||||||
|
self.active = id
|
||||||
|
self.hovered = id
|
||||||
|
end
|
||||||
|
|
||||||
function suit:anyHit()
|
function suit:anyHit()
|
||||||
return self.hit ~= nil
|
return self.hit ~= nil
|
||||||
end
|
end
|
||||||
|
@ -182,7 +198,7 @@ end
|
||||||
function suit:draw()
|
function suit:draw()
|
||||||
self:exitFrame()
|
self:exitFrame()
|
||||||
love.graphics.push('all')
|
love.graphics.push('all')
|
||||||
for i = 1,self.draw_queue.n do
|
for i = self.draw_queue.n,1,-1 do
|
||||||
self.draw_queue[i]()
|
self.draw_queue[i]()
|
||||||
end
|
end
|
||||||
love.graphics.pop()
|
love.graphics.pop()
|
||||||
|
|
3
init.lua
3
init.lua
|
@ -11,11 +11,14 @@ return setmetatable({
|
||||||
getOptionsAndSize = suit.getOptionsAndSize,
|
getOptionsAndSize = suit.getOptionsAndSize,
|
||||||
|
|
||||||
-- core functions
|
-- core functions
|
||||||
|
setHovered = function(...) return instance:setHovered(...) end,
|
||||||
anyHovered = function(...) return instance:anyHovered(...) end,
|
anyHovered = function(...) return instance:anyHovered(...) end,
|
||||||
isHovered = function(...) return instance:isHovered(...) end,
|
isHovered = function(...) return instance:isHovered(...) end,
|
||||||
wasHovered = function(...) return instance:wasHovered(...) end,
|
wasHovered = function(...) return instance:wasHovered(...) end,
|
||||||
anyActive = function(...) return instance:anyActive(...) end,
|
anyActive = function(...) return instance:anyActive(...) end,
|
||||||
|
setActive = function(...) return instance:setActive(...) end,
|
||||||
isActive = function(...) return instance:isActive(...) end,
|
isActive = function(...) return instance:isActive(...) end,
|
||||||
|
setHit = function(...) return instance:setHit(...) end,
|
||||||
anyHit = function(...) return instance:anyHit(...) end,
|
anyHit = function(...) return instance:anyHit(...) end,
|
||||||
isHit = function(...) return instance:isHit(...) end,
|
isHit = function(...) return instance:isHit(...) end,
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue