diff --git a/0006-on.mouse_press b/0006-on.mouse_press index 901f8e1..071e9df 100644 --- a/0006-on.mouse_press +++ b/0006-on.mouse_press @@ -1,6 +1,16 @@ on.mouse_press = function(x,y, mouse_button) if Global_state.thread == nil then - -- do nothing; everything happens on release + -- we're rendering the file picker + -- check for any button clicks + for _,button in ipairs(Global_state.file_picker) do + -- do nothing; everything happens on release + -- (to avoid changing the surface between press and release) + if in_rect(button, x,y) then + return + end + end + -- no button clicked; pan surface + Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom} return end if Cursor_node then diff --git a/0017-on.mouse_release b/0017-on.mouse_release index 2fe114c..52d3377 100644 --- a/0017-on.mouse_release +++ b/0017-on.mouse_release @@ -1,21 +1,22 @@ on.mouse_release = function(x,y, mouse_button) if Global_state.thread == nil then - -- we're rendering the file picker + -- file picker + -- check for any button clicks -- compute_layout reuses nodes and so it fills in x,y for us for _,button in ipairs(Global_state.file_picker) do if in_rect(button, x,y) then open_thread(button.data[1].data) A() - break + return end end - return end - if Pan then + -- HACK: shared by file picker and thread view Pan = nil A() elseif Cursor_node then + -- thread view Cursor_node.show_cursor = true edit.mouse_release(Cursor_node.editor, x,y, mouse_button) end diff --git a/0018-on.update b/0018-on.update index 7a74690..615c059 100644 --- a/0018-on.update +++ b/0018-on.update @@ -1,13 +1,10 @@ on.update = function(dt) if Pan then set_mouse_cursor('hand') - else - set_mouse_cursor('arrow') - end - if Pan then Viewport.x = Pan.x - App.mouse_x()/Viewport.zoom Viewport.y = Pan.y - App.mouse_y()/Viewport.zoom B() - return + else + set_mouse_cursor('arrow') end end \ No newline at end of file diff --git a/0114-draw_file_picker b/0114-draw_file_picker deleted file mode 100644 index 5637aa6..0000000 --- a/0114-draw_file_picker +++ /dev/null @@ -1,25 +0,0 @@ -draw_file_picker = function() - local font = love.graphics.getFont() - local y, x = Margin_top, Margin_left - for _,f in ipairs(Files) do - local w = font:getWidth(f) - if x + w > App.screen.width then - y = y + font:getHeight()*font:getLineHeight() + 10 - x = Margin_left - end - button(Global_state, f, { - x=x-5, y=y-2, w=w+10, h=font:getHeight()*font:getLineHeight()+4, - color={0.7,0.7,1.0}, - icon=function(p) - App.color{r=0.4,g=0.4,b=0.7} - love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 5,5) - App.color{r=0,g=0,b=0} - love.graphics.print(f, x,y) - end, - onpress1 = function() - open_thread(f) - end, - }) - x = x + App.width(f) + 15 - end -end \ No newline at end of file