Merge luaML.love

This commit is contained in:
Kartik K. Agaram 2024-07-25 22:23:03 -07:00
commit 3120786070
4 changed files with 11 additions and 14 deletions

7
0019-B
View File

@ -1,6 +1,5 @@
B = function()
B = function(font)
-- recompute various aspects based on the current viewport settings
local font = nil -- ensure a single font object over the whole surface
for _,obj in ipairs(Surface) do
if obj.type == 'line' then
obj.zdata = {}
@ -17,8 +16,8 @@ B = function()
obj.zdata = love.math.newBezierCurve(zdata):render()
elseif obj.type == 'text' then
if obj.w then
update_editor_box(obj, font or obj.editor.font)
if obj.editor and obj.editor.font then font = obj.editor.font end
update_editor_box(obj, font)
if font == nil and obj.editor then font = obj.editor.font end
else
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
end

View File

@ -101,4 +101,4 @@ compute_layout = function(node, x,y, nodes_to_render, font)
end
end
return x+node.w,y+node.h
end
end

9
0028-A
View File

@ -1,6 +1,7 @@
A = function()
-- load Nodes to Surface
love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font
render_nodes_to_surface()
B()
end
local font = love.graphics.newFont(scale(20))
love.graphics.setFont(font) -- editor objects implicitly depend on current font
render_nodes_to_surface(font)
B(font)
end

View File

@ -1,4 +1,4 @@
render_nodes_to_surface = function()
render_nodes_to_surface = function(font)
-- design constraints:
-- trees only, no graphs or DAGs
-- parents above children
@ -9,9 +9,6 @@ render_nodes_to_surface = function()
-- siblings always occupy the same row
-- cousins/aunts/nephews never overlap columns
Surface = {}
-- we're going to be computing box heights
local font = love.graphics.newFont(scale(20))
love.graphics.setFont(font)
-- compute number of tracks needed
for _,x in pairs(Nodes) do
if x.ntracks == nil then
@ -21,4 +18,4 @@ render_nodes_to_surface = function()
-- prepare the tracks
-- each track is 600px + 20px of gutter between nodes
render_node_and_descendants(Root.id, --[[y]] 0, --[[xlo]] 0, --[[xhi]] 620 * Root.ntracks, --[[grandparent surface node]] nil, font)
end
end