about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-07-12 16:20:25 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-07-12 16:20:25 -0700
commitd7ee9a75e43be4120c2a7f10ec0fd766ff268a1b (patch)
tree36ca527644dee73936039fe64db3f7682e5c2aa6
parent3874f325f8e1c71c067ed4dd3e9caa6fc3a254fc (diff)
downloadtext.love-d7ee9a75e43be4120c2a7f10ec0fd766ff268a1b.tar.gz
add state arg to Drawing.mouse_pressed
-rw-r--r--drawing.lua30
-rw-r--r--edit.lua2
2 files changed, 16 insertions, 16 deletions
diff --git a/drawing.lua b/drawing.lua
index 33bfd26..25c14d2 100644
--- a/drawing.lua
+++ b/drawing.lua
@@ -207,24 +207,24 @@ function Drawing.in_drawing(drawing, x,y)
   return y >= drawing.y and y < drawing.y + Drawing.pixels(drawing.h) and x >= Editor_state.margin_left and x < App.screen.width-Editor_state.margin_right
 end
 
-function Drawing.mouse_pressed(drawing, x,y, button)
-  if Editor_state.current_drawing_mode == 'freehand' then
-    drawing.pending = {mode=Editor_state.current_drawing_mode, points={{x=Drawing.coord(x-Editor_state.margin_left), y=Drawing.coord(y-drawing.y)}}}
-  elseif Editor_state.current_drawing_mode == 'line' or Editor_state.current_drawing_mode == 'manhattan' then
-    local j = Drawing.insert_point(drawing.points, Drawing.coord(x-Editor_state.margin_left), Drawing.coord(y-drawing.y))
-    drawing.pending = {mode=Editor_state.current_drawing_mode, p1=j}
-  elseif Editor_state.current_drawing_mode == 'polygon' or Editor_state.current_drawing_mode == 'rectangle' or Editor_state.current_drawing_mode == 'square' then
-    local j = Drawing.insert_point(drawing.points, Drawing.coord(x-Editor_state.margin_left), Drawing.coord(y-drawing.y))
-    drawing.pending = {mode=Editor_state.current_drawing_mode, vertices={j}}
-  elseif Editor_state.current_drawing_mode == 'circle' then
-    local j = Drawing.insert_point(drawing.points, Drawing.coord(x-Editor_state.margin_left), Drawing.coord(y-drawing.y))
-    drawing.pending = {mode=Editor_state.current_drawing_mode, center=j}
-  elseif Editor_state.current_drawing_mode == 'move' then
+function Drawing.mouse_pressed(State, drawing, x,y, button)
+  if State.current_drawing_mode == 'freehand' then
+    drawing.pending = {mode=State.current_drawing_mode, points={{x=Drawing.coord(x-State.margin_left), y=Drawing.coord(y-drawing.y)}}}
+  elseif State.current_drawing_mode == 'line' or State.current_drawing_mode == 'manhattan' then
+    local j = Drawing.insert_point(drawing.points, Drawing.coord(x-State.margin_left), Drawing.coord(y-drawing.y))
+    drawing.pending = {mode=State.current_drawing_mode, p1=j}
+  elseif State.current_drawing_mode == 'polygon' or State.current_drawing_mode == 'rectangle' or State.current_drawing_mode == 'square' then
+    local j = Drawing.insert_point(drawing.points, Drawing.coord(x-State.margin_left), Drawing.coord(y-drawing.y))
+    drawing.pending = {mode=State.current_drawing_mode, vertices={j}}
+  elseif State.current_drawing_mode == 'circle' then
+    local j = Drawing.insert_point(drawing.points, Drawing.coord(x-State.margin_left), Drawing.coord(y-drawing.y))
+    drawing.pending = {mode=State.current_drawing_mode, center=j}
+  elseif State.current_drawing_mode == 'move' then
     -- all the action is in mouse_released
-  elseif Editor_state.current_drawing_mode == 'name' then
+  elseif State.current_drawing_mode == 'name' then
     -- nothing
   else
-    print(Editor_state.current_drawing_mode)
+    print(State.current_drawing_mode)
     assert(false)
   end
 end
diff --git a/edit.lua b/edit.lua
index f3e1f26..d70bfca 100644
--- a/edit.lua
+++ b/edit.lua
@@ -228,7 +228,7 @@ function edit.mouse_pressed(State, x,y, mouse_button)
         State.lines.current_drawing_index = line_index
         State.lines.current_drawing = line
         Drawing.before = snapshot(line_index)
-        Drawing.mouse_pressed(line, x,y, mouse_button)
+        Drawing.mouse_pressed(State, line, x,y, mouse_button)
         break
       end
     end