Merge 5531c5d636
into 44be6169e3
This commit is contained in:
commit
ca61865a93
8 changed files with 18 additions and 11 deletions
|
@ -31,7 +31,7 @@ local keyboard = require(BASE .. 'keyboard')
|
|||
|
||||
-- the widget
|
||||
-- {text = text, pos = {x, y}, size={w, h}, widgetHit=widgetHit, draw=draw}
|
||||
return function(w)
|
||||
local function button(w)
|
||||
assert(type(w) == "table" and w.text, "Invalid argument")
|
||||
|
||||
-- if tight fit requested, compute the size according to text size
|
||||
|
@ -74,4 +74,4 @@ return function(w)
|
|||
|
||||
return mouse.releasedOn(id) or keyboard.pressedOn(id, 'return')
|
||||
end
|
||||
|
||||
return button
|
||||
|
|
|
@ -30,7 +30,7 @@ local mouse = require(BASE .. 'mouse')
|
|||
local keyboard = require(BASE .. 'keyboard')
|
||||
|
||||
-- {checked = status, text = "", algin = "left", pos = {x, y}, size={w, h}, widgetHit=widgetHit, draw=draw}
|
||||
return function(w)
|
||||
local function checkbox(w)
|
||||
assert(type(w) == "table")
|
||||
w.text = w.text or ""
|
||||
|
||||
|
@ -65,4 +65,4 @@ return function(w)
|
|||
|
||||
return w.checked ~= checked
|
||||
end
|
||||
|
||||
return checkbox
|
||||
|
|
6
init.lua
6
init.lua
|
@ -24,8 +24,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
]]--
|
||||
|
||||
local BASE = (...) .. '.'
|
||||
assert(not BASE:match('%.init%.$'), "Invalid require path `"..(...).."' (drop the `.init').")
|
||||
local BASE = (... or ''):gsub('%.init$', '')
|
||||
|
||||
assert(not BASE:match('%.init$'), "Invalid require path `"..(... or '').."' (drop the `.init').")
|
||||
BASE = BASE.."."
|
||||
|
||||
return {
|
||||
core = require(BASE .. 'core'),
|
||||
|
|
|
@ -32,7 +32,7 @@ local keyboard = require(BASE .. 'keyboard')
|
|||
local utf8 = require(BASE .. 'utf8')
|
||||
|
||||
-- {info = {text = "", cursor = text:len()}, pos = {x, y}, size={w, h}, widgetHit=widgetHit, draw=draw}
|
||||
return function(w)
|
||||
local function input(w)
|
||||
assert(type(w) == "table" and type(w.info) == "table", "Invalid argument")
|
||||
w.info.text = w.info.text or ""
|
||||
w.info.cursor = math.min(w.info.cursor or w.info.text:len(), w.info.text:len())
|
||||
|
@ -78,3 +78,4 @@ return function(w)
|
|||
|
||||
return mouse.releasedOn(id) or keyboard.pressedOn(id, 'return')
|
||||
end
|
||||
return input
|
||||
|
|
|
@ -31,7 +31,7 @@ local mouse = require(BASE .. 'mouse')
|
|||
local keyboard = require(BASE .. 'keyboard')
|
||||
|
||||
-- {text = text, align = align, pos = {x, y}, size={w, h}, widgetHit=widgetHit, draw=draw}
|
||||
return function(w)
|
||||
local function label(w)
|
||||
assert(type(w) == "table" and w.text, "Invalid argument")
|
||||
w.align = w.align or 'left'
|
||||
|
||||
|
@ -58,4 +58,4 @@ return function(w)
|
|||
|
||||
return mouse.releasedOn(id)
|
||||
end
|
||||
|
||||
return label
|
||||
|
|
|
@ -24,6 +24,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
]]--
|
||||
|
||||
local love = require("love")
|
||||
|
||||
local _M -- holds the module. needed to make widgetHit overridable
|
||||
|
||||
local x,y = 0,0
|
||||
|
|
|
@ -31,7 +31,7 @@ local mouse = require(BASE .. 'mouse')
|
|||
local keyboard = require(BASE .. 'keyboard')
|
||||
|
||||
-- {info = {value = v, min = 0, max = 1, step = (max-min)/20}, vertical = boolean, pos = {x, y}, size={w, h}, widgetHit=widgetHit, draw=draw}
|
||||
return function(w)
|
||||
local function slider(w)
|
||||
assert(type(w) == 'table' and type(w.info) == "table" and w.info.value, "Invalid argument.")
|
||||
w.info.min = w.info.min or 0
|
||||
w.info.max = w.info.max or math.max(w.info.value, 1)
|
||||
|
@ -77,3 +77,4 @@ return function(w)
|
|||
|
||||
return changed
|
||||
end
|
||||
return slider
|
||||
|
|
|
@ -31,7 +31,7 @@ local mouse = require(BASE .. 'mouse')
|
|||
local keyboard = require(BASE .. 'keyboard')
|
||||
|
||||
-- {info = {value = {x,y}, min = {0,0}, max = {1,1}, step = (max-min)/20}, pos = {x, y}, size={w, h}, widgetHit=widgetHit, draw=draw}
|
||||
return function(w)
|
||||
local function slider2d(w)
|
||||
assert(type(w) == 'table' and type(w.info) == "table" and w.info.value, "Invalid argument.")
|
||||
w.info.min = {
|
||||
w.info.min and w.info.min[1] or 0,
|
||||
|
@ -97,3 +97,4 @@ return function(w)
|
|||
|
||||
return changed
|
||||
end
|
||||
return slider2d
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue