up and down arrow working at all 3 zoom levels

I don't know why I have such an almighty struggle with this stuff.
This commit is contained in:
Kartik K. Agaram 2023-10-27 17:13:28 -07:00
parent d1c65b90a3
commit 27733025a2
2 changed files with 9 additions and 2 deletions

View File

@ -3,6 +3,7 @@ on.draw = function()
love.graphics.line(50, 0, 50, App.screen.height)
for i=0,100 do
love.graphics.print(tostring(i), 30, i*100)
love.graphics.line(25, i*100, 75, i*100)
end
local vy0 = vy(0)
love.graphics.line(100, vy0, 100, App.screen.height)

View File

@ -1,10 +1,15 @@
function pan_viewport_to_contain_cursor(node)
print('viewport', Viewport.y)
local safety_margin = 2*node.editor.line_height
cursor1 = {39, 1}
print('safety margin', safety_margin, 'dvpx')
print('node', node.y)
local cursor_sy = node.y + y_of_schema1(node.editor, node.editor.cursor1)
print('node', node.y, node.y/Viewport.zoom)
--? 0 608 vs 38*20 = 760
local cursor_sy = node.y + y_of_schema1(node.editor, node.editor.cursor1)/Viewport.zoom
--? 608 0 775 968.75 968.75 928.75
print(cursor_sy, Viewport.y, App.screen.height, App.screen.height/Viewport.zoom, Viewport.y + App.screen.height/Viewport.zoom, Viewport.y + App.screen.height/Viewport.zoom - safety_margin)
if cursor_sy > Viewport.y + App.screen.height/Viewport.zoom - safety_margin then
print('cursor below viewport')
local cursor_y = y_of_schema1(node.editor, node.editor.cursor1)
print('cursor', cursor_y, 'dvpx')
if Viewport.y < node.y then
@ -31,6 +36,7 @@ function pan_viewport_to_contain_cursor(node)
end
end
elseif cursor_sy < Viewport.y + safety_margin then
print('cursor above viewport')
local cursor_y = y_of_schema1(node.editor, node.editor.cursor1)
print('cursor', cursor_y, 'dvpx')
if Viewport.y < node.y then