Fix vertical Slider
Slider, when vertical, was drawing the grab box with inverted position. Center "track" had incorrect orientation. Also, slider.lua was passing a bunk table to group.getRect().
This commit is contained in:
parent
43265a44ca
commit
ddd4791e8c
2 changed files with 12 additions and 8 deletions
|
@ -39,7 +39,7 @@ return function(w)
|
||||||
local fraction = (w.info.value - w.info.min) / (w.info.max - w.info.min)
|
local fraction = (w.info.value - w.info.min) / (w.info.max - w.info.min)
|
||||||
|
|
||||||
local id = w.id or core.generateID()
|
local id = w.id or core.generateID()
|
||||||
local pos, size = group.getRect(w.pos, w.info.size)
|
local pos, size = group.getRect(w.pos, w.size)
|
||||||
|
|
||||||
mouse.updateWidget(id, pos, size, w.widgetHit)
|
mouse.updateWidget(id, pos, size, w.widgetHit)
|
||||||
keyboard.makeCyclable(id)
|
keyboard.makeCyclable(id)
|
||||||
|
|
|
@ -82,20 +82,24 @@ end
|
||||||
local function Slider(state, fraction, vertical, x,y,w,h)
|
local function Slider(state, fraction, vertical, x,y,w,h)
|
||||||
local c = color[state]
|
local c = color[state]
|
||||||
|
|
||||||
love.graphics.setLineWidth(2)
|
love.graphics.setLine(2, 'rough')
|
||||||
love.graphics.setColor(c.border)
|
love.graphics.setColor(c.border)
|
||||||
|
if vertical then
|
||||||
|
love.graphics.line(x+w/2-1,y,x+w/2-1,y+h)
|
||||||
|
love.graphics.line(x+w/2+1,y,x+w/2+1,y+h)
|
||||||
|
love.graphics.setColor(c.bg)
|
||||||
|
love.graphics.line(x+w/2,y,x+w/2,y+h)
|
||||||
|
y = math.floor(y + h - h * fraction - 5)
|
||||||
|
h = 10
|
||||||
|
else
|
||||||
love.graphics.line(x,y+h/2-1,x+w,y+h/2-1)
|
love.graphics.line(x,y+h/2-1,x+w,y+h/2-1)
|
||||||
love.graphics.line(x,y+h/2+1,x+w,y+h/2+1)
|
love.graphics.line(x,y+h/2+1,x+w,y+h/2+1)
|
||||||
love.graphics.setColor(c.bg)
|
love.graphics.setColor(c.bg)
|
||||||
love.graphics.line(x,y+h/2,x+w,y+h/2)
|
love.graphics.line(x,y+h/2,x+w,y+h/2)
|
||||||
|
|
||||||
if vertical then
|
|
||||||
y = math.floor(y + h * fraction - 5)
|
|
||||||
h = 10
|
|
||||||
else
|
|
||||||
x = math.floor(x + w * fraction - 5)
|
x = math.floor(x + w * fraction - 5)
|
||||||
w = 10
|
w = 10
|
||||||
end
|
end
|
||||||
|
|
||||||
box(x,y,w,h, c.bg,c.border)
|
box(x,y,w,h, c.bg,c.border)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue