diff --git a/slider.lua b/slider.lua index d540348..e14dc96 100644 --- a/slider.lua +++ b/slider.lua @@ -18,7 +18,7 @@ return function(core, info, ...) if core:isActive(opt.id) then -- mouse update local mx,my = core:getMousePosition() - if opt.vertical then + if opt.id.vertical then fraction = math.min(1, math.max(0, (y+h - my) / h)) else fraction = math.min(1, math.max(0, (mx - x) / w)) @@ -30,8 +30,8 @@ return function(core, info, ...) end -- keyboard update - local key_up = opt.vertical and 'up' or 'right' - local key_down = opt.vertical and 'down' or 'left' + local key_up = opt.id.vertical and 'up' or 'right' + local key_down = opt.id.vertical and 'down' or 'left' if core:getPressedKey() == key_up then info.value = math.min(info.max, info.value + info.step) value_changed = true diff --git a/theme.lua b/theme.lua index 7981c21..22f3ac9 100644 --- a/theme.lua +++ b/theme.lua @@ -83,7 +83,7 @@ end function theme.Slider(fraction, opt, x,y,w,h) local xb, yb, wb, hb -- size of the progress bar local r = math.min(w,h) / 2.1 - if opt.vertical then + if opt.id.vertical == true then x, w = x + w*.25, w*.5 xb, yb, wb, hb = x, y+h*(1-fraction), w, h*fraction else @@ -97,7 +97,7 @@ function theme.Slider(fraction, opt, x,y,w,h) if opt.state ~= nil and opt.state ~= "normal" then love.graphics.setColor((opt.color and opt.color.active or {}).fg or theme.color.active.fg) - if opt.vertical then + if opt.id.vertical then love.graphics.circle('fill', x+wb/2, yb, r) else love.graphics.circle('fill', x+wb, yb+hb/2, r)