Abused id parameter to not break compatibility

This commit is contained in:
zorfmorf 2015-02-12 13:51:30 +01:00
parent 67f1d33ac9
commit e6685ed5e7
8 changed files with 11 additions and 14 deletions

View file

@ -69,7 +69,7 @@ return function(w)
-- core.registerDraw(id, drawfunction, drawfunction-arguments...) -- core.registerDraw(id, drawfunction, drawfunction-arguments...)
-- shows widget when core.draw() is called. -- shows widget when core.draw() is called.
core.registerDraw(id, w.draw or core.style.Button, false, core.registerDraw(id, w.draw or core.style.Button,
w.text, pos[1],pos[2], size[1],size[2]) w.text, pos[1],pos[2], size[1],size[2])
return mouse.releasedOn(id) or keyboard.pressedOn(id, 'return') return mouse.releasedOn(id) or keyboard.pressedOn(id, 'return')

View file

@ -60,7 +60,7 @@ return function(w)
w.checked = not w.checked w.checked = not w.checked
end end
core.registerDraw(id, w.draw or core.style.Checkbox, false, core.registerDraw(id, w.draw or core.style.Checkbox,
w.checked, w.text, w.align or 'left', pos[1], pos[2], size[1], size[2]) w.checked, w.text, w.align or 'left', pos[1], pos[2], size[1], size[2])
return w.checked ~= checked return w.checked ~= checked

View file

@ -66,7 +66,7 @@ end
-- Drawing / Frame update -- Drawing / Frame update
-- --
local draw_items = {n = 0} local draw_items = {n = 0}
local function registerDraw(id, f, isGroup, ...) local function registerDraw(id, f, ...)
assert(type(f) == 'function' or (getmetatable(f) or {}).__call, assert(type(f) == 'function' or (getmetatable(f) or {}).__call,
'Drawing function is not a callable type!') 'Drawing function is not a callable type!')
@ -80,7 +80,7 @@ local function registerDraw(id, f, isGroup, ...)
draw_items.n = draw_items.n + 1 draw_items.n = draw_items.n + 1
local targetindex = draw_items.n local targetindex = draw_items.n
if isGroup then targetindex = 1 end if id == "group_draw" then targetindex = 1 end
table.insert(draw_items, targetindex, function() table.insert(draw_items, targetindex, function()
if font then love.graphics.setFont(font) end if font then love.graphics.setFont(font) end

View file

@ -79,10 +79,7 @@ local function push(info)
assert(size, "Size neither specified nor derivable from parent group.") assert(size, "Size neither specified nor derivable from parent group.")
assert(pos, "Position neither specified nor derivable from parent group.") assert(pos, "Position neither specified nor derivable from parent group.")
grow = assert(Grow[grow], "Invalid grow: " .. tostring(grow)) grow = assert(Grow[grow], "Invalid grow: " .. tostring(grow))
local id = info.id
if not id then id = core.generateID() end
current = { current = {
pos = pos, pos = pos,
grow = grow, grow = grow,
@ -92,7 +89,6 @@ local function push(info)
border = info.border, border = info.border,
bkg = info.bkg, bkg = info.bkg,
draw = info.draw, draw = info.draw,
id = id,
upper_left = { math.huge, math.huge}, upper_left = { math.huge, math.huge},
lower_right = {-math.huge, -math.huge}, lower_right = {-math.huge, -math.huge},
} }
@ -154,8 +150,9 @@ local function pop()
} }
advance(current.pos, size) advance(current.pos, size)
-- skip the draw call if we don't need it
if child.bkg or child.border then if child.bkg or child.border then
core.registerDraw(child.id, child.draw or core.style.Group, true, core.registerDraw("group_draw", child.draw or core.style.Group,
child.bkg, child.border, child.upper_left[1], child.upper_left[2], child.lower_right[1] - child.upper_left[1], child.lower_right[2] - child.upper_left[2]) child.bkg, child.border, child.upper_left[1], child.upper_left[2], child.lower_right[1] - child.upper_left[1], child.lower_right[2] - child.upper_left[2])
end end
end end

View file

@ -73,7 +73,7 @@ return function(w)
w.info.cursor = w.info.cursor + 1 w.info.cursor = w.info.cursor + 1
end end
core.registerDraw(id, w.draw or core.style.Input, false, core.registerDraw(id, w.draw or core.style.Input,
w.info.text, w.info.cursor, pos[1],pos[2], size[1],size[2]) w.info.text, w.info.cursor, pos[1],pos[2], size[1],size[2])
return mouse.releasedOn(id) or keyboard.pressedOn(id, 'return') return mouse.releasedOn(id) or keyboard.pressedOn(id, 'return')

View file

@ -53,7 +53,7 @@ return function(w)
keyboard.clearFocus() keyboard.clearFocus()
end end
core.registerDraw(id, w.draw or core.style.Label, false, core.registerDraw(id, w.draw or core.style.Label,
w.text, w.align, pos[1],pos[2], size[1],size[2]) w.text, w.align, pos[1],pos[2], size[1],size[2])
return mouse.releasedOn(id) return mouse.releasedOn(id)

View file

@ -72,7 +72,7 @@ return function(w)
end end
end end
core.registerDraw(id, w.draw or core.style.Slider, false, core.registerDraw(id, w.draw or core.style.Slider,
fraction, w.vertical, pos[1],pos[2], size[1],size[2]) fraction, w.vertical, pos[1],pos[2], size[1],size[2])
return changed return changed

View file

@ -92,7 +92,7 @@ return function(w)
end end
end end
core.registerDraw(id, w.draw or core.style.Slider2D, false, core.registerDraw(id, w.draw or core.style.Slider2D,
fraction, pos[1],pos[2], size[1],size[2]) fraction, pos[1],pos[2], size[1],size[2])
return changed return changed