Merge luaML.love

This commit is contained in:
Kartik K. Agaram 2023-10-21 10:01:52 -07:00
commit 88609d69c0
7 changed files with 18 additions and 18 deletions

6
0019-B
View File

@ -1,4 +1,4 @@
B = function(preserve_screen_top_of_cursor_node)
B = function()
-- recompute various aspects based on the current viewport settings
love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font so update it
for _,obj in ipairs(Surface) do
@ -17,10 +17,10 @@ B = function(preserve_screen_top_of_cursor_node)
obj.zdata = love.math.newBezierCurve(zdata):render()
elseif obj.type == 'text' then
if obj.w then
update_editor_box(obj, preserve_screen_top_of_cursor_node)
update_editor_box(obj)
else
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
end
end
end
end
end

View File

@ -1,4 +1,4 @@
compute_layout = function(node, x,y, nodes_to_render, preserve_screen_top_of_cursor_node)
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
@ -24,7 +24,7 @@ compute_layout = function(node, x,y, nodes_to_render, preserve_screen_top_of_cur
if node.editor == nil then
initialize_editor(node)
else
update_editor_box(node, preserve_screen_top_of_cursor_node)
update_editor_box(node)
end
node.h = box_height(node)
table.insert(nodes_to_render, node)

View File

@ -5,6 +5,6 @@ on.text_input = function(t)
if not eq(Cursor_node.editor.screen_top1, old_top) then
Viewport.y = Cursor_node.y + y_of_schema1(Cursor_node.editor, Cursor_node.editor.screen_top1)
end
A(--[[preserve screen_top of cursor node]] true)
A()
end
end
end

View File

@ -19,7 +19,7 @@ on.keychord_press = function(chord, key)
if not eq(Cursor_node.editor.screen_top1, old_top) then
Viewport.y = Cursor_node.y + y_of_schema1(Cursor_node.editor, Cursor_node.editor.screen_top1)
end
A(--[[preserve screen_top of cursor node]] true)
A()
else
if chord == 'up' then
Viewport.y = Viewport.y - scale(20)
@ -53,4 +53,4 @@ on.keychord_press = function(chord, key)
B()
end
end
end
end

6
0028-A
View File

@ -1,10 +1,10 @@
A = function(preserve_screen_top_of_cursor_node)
A = function()
love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font
-- translate Nodes to Surface
while #Surface > 0 do table.remove(Surface) end
for key,node in pairs(Nodes) do
node.id = key
compute_layout(node, node.x,node.y, Surface, preserve_screen_top_of_cursor_node)
compute_layout(node, node.x,node.y, Surface)
end
-- draw edges after all nodes have been initialized
for key,node in pairs(Nodes) do
@ -13,6 +13,6 @@ A = function(preserve_screen_top_of_cursor_node)
end
end
-- continue the pipeline
B(preserve_screen_top_of_cursor_node)
B()
-- TODO: ugly that we're manipulating editor objects twice
end

View File

@ -1,8 +1,8 @@
update_editor_box = function(node, preserve_screen_top_of_cursor_node)
update_editor_box = function(node)
if node.editor == nil then return end
-- Compute screen_top1 in viewport coordinates because the editor's font takes scaling into account.
if vy(node.y) > 0 then
if not preserve_screen_top_of_cursor_node or node ~= Cursor_node then
if node ~= Cursor_node then
node.editor.screen_top1.line = 1
node.editor.screen_top1.pos = 1
end

View File

@ -1,4 +1,4 @@
A1 = function(id, preserve_screen_top_of_cursor_node)
A1 = function(id)
-- like A, but translate a single node in Nodes to Surface
-- this only works because Nodes is a flat array; we don't support row/col types here yet
-- delete previously added shapes for this node:
@ -10,7 +10,7 @@ A1 = function(id, preserve_screen_top_of_cursor_node)
end
-- translate Nodes to Surface
local node = Nodes[id]
compute_layout(node, node.x,node.y, Surface, preserve_screen_top_of_cursor_node)
compute_layout(node, node.x,node.y, Surface)
for _,d in ipairs(node.outgoing_edges) do
compute_layout_for_edge(id, d)
end
@ -18,5 +18,5 @@ A1 = function(id, preserve_screen_top_of_cursor_node)
compute_layout_for_edge(s, id)
end
-- continue the pipeline
B(preserve_screen_top_of_cursor_node)
end
B()
end