stop putting button state in a global

[?]
Aug 23, 2022, 5:59 PM
PP2IIHL6EK4HBFFSYAQNV35BKIK6D4EL2JQOY7NZVJX2DXCLSMGAC

Dependencies

  • [2] 6D5MOJS4 allow buttons to interrupt events
  • [3] BJ46QVIP improve explanation for buttons
  • [4] U76D4P36 fix a typo
  • [5] ZNLTRNNK highlight another global
  • [6] OTIBCAUJ love2d scaffold
  • [7] LNUHQOGH start passing in Editor_state explicitly
  • [8] OAHNWDYG .
  • [9] ILOA5BYF separate data structure for each line's cache data
  • [10] AVTNUQYR basic test-enabled framework
  • [11] XX7G2FFJ intermingle freehand line drawings with text
  • [12] TGHAJBES use line cache for drawings as well
  • [13] BW2IUB3K keep all text cache writes inside text.lua
  • [14] UH4YWHW5 button framework is at the app level
  • [15] WJBZZQE4 fold together two largely similar cases
  • [16] 2L5MEZV3 experiment: new edit namespace
  • [*] 4KC7I3E2 make colors easier to edit

Change contents

  • edit in main.lua at line 136
    [4.1373][4.47:70]()
    Button_handlers = {}
  • edit in edit.lua at line 131
    [4.2727]
    [18.999]
    State.button_handlers = {}
  • replacement in edit.lua at line 155
    [4.269][4.269:330]()
    button('draw', {x=4,y=y+4, w=12,h=12, color={1,1,0},
    [4.269]
    [4.330]
    button(State, 'draw', {x=4,y=y+4, w=12,h=12, color={1,1,0},
  • replacement in edit.lua at line 212
    [4.4647][2.114:172]()
    if propagate_to_button_handlers(x,y, mouse_button) then
    [4.4647]
    [2.172]
    if propagate_to_button_handlers(State, x,y, mouse_button) then
  • edit in button.lua at line 5
    [3.203][4.141:142](),[4.141][4.141:142](),[4.142][4.35:56]()
    Button_handlers = {}
  • replacement in button.lua at line 7
    [4.2124][4.2124:2154]()
    function button(name, params)
    [4.2124]
    [4.2154]
    function button(State, name, params)
    if State.button_handlers == nil then
    State.button_handlers = {}
    end
  • replacement in button.lua at line 14
    [4.2365][4.57:97]()
    table.insert(Button_handlers, params)
    [4.2365]
    [4.2405]
    table.insert(State.button_handlers, params)
  • replacement in button.lua at line 18
    [4.2443][4.143:201](),[4.201][4.98:139]()
    function propagate_to_button_handlers(x, y, mouse_button)
    for _,ev in ipairs(Button_handlers) do
    [4.2443]
    [4.2535]
    function propagate_to_button_handlers(State, x, y, mouse_button)
    if State.button_handlers == nil then
    return
    end
    for _,ev in ipairs(State.button_handlers) do