Merge branch 'layout' of https://github.com/qeffects/helium into layout

This commit is contained in:
Elmārs Āboliņš 2021-07-01 20:30:12 +03:00
commit b6945fbe7f

View File

@ -1,4 +1,4 @@
local path = string.sub(..., 1, string.len(...) - string.len(".shell.button")) local path = string.sub(..., 1, string.len(...) - string.len(".shell.checkbox"))
local state = require(path.. ".hooks.state") local state = require(path.. ".hooks.state")
local input = require(path.. ".core.input") local input = require(path.. ".core.input")
@ -21,22 +21,23 @@ local input = require(path.. ".core.input")
return function(onClick, onRelease, onEnter, onExit, startOn, x, y, w, h) return function(onClick, onRelease, onEnter, onExit, startOn, x, y, w, h)
local checkbox = state { local checkbox = state {
down = false, down = false,
toggled = not not startOn, toggled = false,
over = false, over = false,
} }
checkbox.toggled = startOn
input('clicked', function(x, y, w, h) input('clicked', function(x, y, w, h)
checkbox.down = true
if onClick then if onClick then
onClick(x, y, w, h) onClick(x, y, w, h)
end end
checkbox.down = true
return function(x, y, w, h) return function(x, y, w, h)
if onRelease then
onRelease(x, y, w, h)
end
checkbox.toggled = not checkbox.toggled checkbox.toggled = not checkbox.toggled
checkbox.down = false checkbox.down = false
if onRelease then
onRelease(checkbox.toggled, y, w, h)
end
end end
end) end)