about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-14 23:32:58 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-14 23:32:58 -0700
commit424dbadc85bd8321b4b31426a362dfd68b06b4f8 (patch)
tree138bf90070f4679fc80134590f790ebba3065ab2
parent8bef861a66cb5c31964e3578078d4229f1cda785 (diff)
downloadlines.love-424dbadc85bd8321b4b31426a362dfd68b06b4f8.tar.gz
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
-rw-r--r--main.lua24
1 files changed, 18 insertions, 6 deletions
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