Fixed vertical slider bug
Vertical sliders have to be accessed within the opt.id table, not just opt. Made modifications to slider.lua and theme.lua.
This commit is contained in:
parent
1767782603
commit
5244ac8dcf
2 changed files with 5 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue