delegate update events to drawings

[?]
May 18, 2022, 6:16 AM
RT6EV6OPUYCXYZOX2PHFXJ7KT77KHNEVINEGQXIQLHQVKPGTN6VQC

Dependencies

  • [2] 6DE7RBZ6 move mouse_released events to Drawing
  • [3] 3RGHOJ25 DRY some code
  • [4] WDWXNW7V slightly strange way to move points
  • [5] POT3XFCT rename
  • [6] JVRL5TWL store device-independent coordinates inside drawings
  • [7] MNWHXPBL more lightweight; select just the stroke at the mouse
  • [8] JCSLDGAH beginnings of support for multiple shapes
  • [9] MGOQ5XAV start uppercasing globals
  • [10] OTIBCAUJ love2d scaffold
  • [11] KVHUFUFV reorg
  • [12] VHQCNMAR several more modules
  • [13] NCRKBTHC position cursor more precisely
  • [14] AVQ5MC5D finish uppercasing all globals
  • [15] KCIM5UTV revert: back to freehand
  • [16] G77XIN7M selecting a stroke
  • [17] QU7NHFOV show cursor
  • [18] L5USRTY2 inline
  • [19] IYW7X3WL left/right cursor movement, deleting characters
  • [20] XX7G2FFJ intermingle freehand line drawings with text
  • [21] IZZVOCLB confirm that we have access to all of the love API
  • [22] EFMLTMZG bugfix: restrict strokes to the drawing they started in
  • [*] BLWAYPKV extract a module

Change contents

  • replacement in main.lua at line 129
    [4.446][3.3:165](),[3.165][4.76:109](),[4.446][4.76:109](),[4.109][3.166:599](),[3.599][4.1659:1677](),[4.1659][4.1659:1677](),[4.1677][4.501:546](),[4.546][3.600:646](),[3.646][4.657:725](),[4.657][4.657:725](),[4.725][4.298:390](),[4.298][4.298:390](),[4.390][4.1677:1683](),[4.1677][4.1677:1683]()
    if Lines.current == nil then return end
    local drawing = Lines.current
    assert(drawing.mode == 'drawing')
    local x, y = love.mouse.getX(), love.mouse.getY()
    if love.mouse.isDown('1') then
    if Drawing.in_drawing(drawing, x,y) then
    if drawing.pending.mode == 'freehand' then
    table.insert(drawing.pending.points, {x=Drawing.coord(love.mouse.getX()-16), y=Drawing.coord(love.mouse.getY()-drawing.y)})
    elseif drawing.pending.mode == 'move' then
    local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y)
    drawing.pending.target_point.x = mx
    drawing.pending.target_point.y = my
    end
    end
    elseif Current_drawing_mode == 'move' then
    if Drawing.in_drawing(drawing, x, y) then
    local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y)
    drawing.pending.target_point.x = mx
    drawing.pending.target_point.y = my
    end
    end
    [4.446]
    [4.3]
    Drawing.update(dt)
  • edit in drawing.lua at line 72
    [2.54]
    [2.54]
    -- a couple of operations on drawings need to constantly check the state of the mouse
    function Drawing.update()
    if Lines.current == nil then return end
    local drawing = Lines.current
    assert(drawing.mode == 'drawing')
    local x, y = love.mouse.getX(), love.mouse.getY()
    if love.mouse.isDown('1') then
    if Drawing.in_drawing(drawing, x,y) then
    if drawing.pending.mode == 'freehand' then
    table.insert(drawing.pending.points, {x=Drawing.coord(love.mouse.getX()-16), y=Drawing.coord(love.mouse.getY()-drawing.y)})
    elseif drawing.pending.mode == 'move' then
    local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y)
    drawing.pending.target_point.x = mx
    drawing.pending.target_point.y = my
    end
    end
    elseif Current_drawing_mode == 'move' then
    if Drawing.in_drawing(drawing, x, y) then
    local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y)
    drawing.pending.target_point.x = mx
    drawing.pending.target_point.y = my
    end
    end
    end