From d2f00ea0fd16ee2f375706d903db5994bc78d7ed Mon Sep 17 00:00:00 2001 From: jill Date: Sat, 18 Sep 2021 02:38:07 +0300 Subject: [PATCH] better slider highlight detection --- main.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.lua b/main.lua index 9449a50..91f74e7 100644 --- a/main.lua +++ b/main.lua @@ -77,8 +77,11 @@ function love.draw() love.graphics.translate(sx, sy) 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) - 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) end love.graphics.rectangle('fill', -ssize/2, -ssize/2, ssize, ssize) @@ -92,7 +95,7 @@ function love.draw() 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 graph.touchtimer = 1 dropdown.createDropdowns()