From 424dbadc85bd8321b4b31426a362dfd68b06b4f8 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 14 May 2022 23:32:58 -0700 Subject: slightly less strange now that we have the same two ways to move points as any other operation 1. hover over point, hit C-v 2. press mouse on point, hit v --- main.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 9f4ef2e..624ed68 100644 --- a/main.lua +++ b/main.lua @@ -129,6 +129,10 @@ function love.update(dt) if y >= drawing.y and y < drawing.y + pixels(drawing.h) and x >= 16 and x < 16+drawingw then if drawing.pending.mode == 'freehand' then table.insert(drawing.pending.points, {x=coord(love.mouse.getX()-16), y=coord(love.mouse.getY()-drawing.y)}) + elseif drawing.pending.mode == 'move' then + local mx,my = coord(x-16), coord(y-drawing.y) + drawing.pending.target_point.x = mx + drawing.pending.target_point.y = my end end end @@ -145,16 +149,16 @@ function love.update(dt) end function love.mousepressed(x,y, button) - if current_mode == 'move' then - current_mode = previous_mode - previous_mode = nil - return - end propagate_to_button_handlers(x,y, button) propagate_to_drawings(x,y, button) end function love.mousereleased(x,y, button) + if current_mode == 'move' then + current_mode = previous_mode + previous_mode = nil + return + end if lines.current then if lines.current.pending then if lines.current.pending.mode == 'freehand' then @@ -542,7 +546,15 @@ function keychord_pressed(chord) if drawing then previous_mode = current_mode current_mode = 'move' - drawing.pending = {target_point=p} + drawing.pending = {mode=current_mode, target_point=p} + lines.current = drawing + end + elseif love.mouse.isDown('1') and chord == 'v' then + local drawing,p = select_point_at_mouse() + if drawing then + previous_mode = current_mode + current_mode = 'move' + drawing.pending = {mode=current_mode, target_point=p} lines.current = drawing end end -- cgit 1.4.1-2-gfad0