better slider highlight detection

This commit is contained in:
jill 2021-09-18 02:38:07 +03:00
parent a629964d63
commit d2f00ea0fd

View file

@ -77,8 +77,11 @@ function love.draw()
love.graphics.translate(sx, sy) love.graphics.translate(sx, sy)
love.graphics.rotate((mixpoint - oldmixpoint) * 4 + mixpointspin * math.pi * 2) love.graphics.rotate((mixpoint - oldmixpoint) * 4 + mixpointspin * math.pi * 2)
local hovering = mx > sx - ssize/2 and mx < sx + ssize/2 and my > sy - ssize/2 and my < sy + ssize/2 and dropdown.openDropdown == 0
local dragging = mx > x and mx < x + w and my > y and my < y + h and love.mouse.isDown(1) and dropdown.openDropdown == 0
love.graphics.setColor(0, 0, 0, 1) love.graphics.setColor(0, 0, 0, 1)
if mx > sx - ssize/2 and mx < sx + ssize/2 and my > sy - ssize/2 and my < sy + ssize/2 and dropdown.openDropdown == 0 then if hovering or dragging then
love.graphics.setColor(0.2, 0.2, 0.3, 1) love.graphics.setColor(0.2, 0.2, 0.3, 1)
end end
love.graphics.rectangle('fill', -ssize/2, -ssize/2, ssize, ssize) love.graphics.rectangle('fill', -ssize/2, -ssize/2, ssize, ssize)
@ -92,7 +95,7 @@ function love.draw()
love.graphics.pop() love.graphics.pop()
if mx > x and mx < x + w and my > y and my < y + h and love.mouse.isDown(1) and dropdown.openDropdown == 0 then if dragging then
mixpoint = (mx - x) / w mixpoint = (mx - x) / w
graph.touchtimer = 1 graph.touchtimer = 1
dropdown.createDropdowns() dropdown.createDropdowns()