Instead of a tree of items, we now have a flat list. Each item knows its depth. This structure is closer to what luaML's compute_layout needs.
For any future hierarchical functionality, each item still knows its parent and replies as ids inside the metadata field.
Next step: redo A for this app. compute_layout should stay fairly timeless across forks of luaML.
Pace layers for apps built on the box model: A B … F (I think of on.draw as F)
A runs least frequently, F runs on every frame.
In this app, the plan is:
Anything that changes the height of any box needs to rerun A. Anything that moves the viewport reruns B.
FHHATD2K3LNFNJ4YKTCHAWKBNB5VSASQR4T6TQ5PK4O433P4FOEQC
initialize_item = function(top, left, right, filename)
local font = love.graphics.getFont()
local result = edit.initialize_state(top, left, right, font:getHeight(), font:getHeight()*font:getLineHeight())
result.id = filename
result.filename = full_path(filename)
result.editable = false
result.replies = {}
initialize_item = function(filename, depth)
local result = {filename=full_path(filename)}
local item = initialize_item(0, left, left+40*em_width, filename)
local replies = load_metadata(filename).replies
for i,reply_id in ipairs(replies) do
local reply = load_subtree(reply_id, left+2*em_width, em_width)
table.insert(item.replies, reply)
local item = initialize_item(filename)
table.insert(out, item)
for i,reply_id in ipairs(item.metadata.replies) do
local reply = load_subtree(reply_id, out, depth+1)
local font = love.graphics.getFont()
local em_width = font:getWidth('m')
Global_state.root = load_subtree(filename, Margin_left, em_width)
Global_state.root.top = Menu_bar_height + Margin_top
-- HERE: Cursor_node needs to be set at the Surface level of abstraction
--Cursor_node = Global_state.root
love.window.setTitle('pothi.love - '..Global_state.root.id)
Global_state.items = {}
load_subtree(filename, Global_state.items)
love.window.setTitle('pothi.love - '..filename)