There's one remaining issue: the DOM is changing between mouse press and
mouse release, which is confusing the select handler.
Options:
* some sort of hacky thing to ignore the first mouse release
* put the file picker handlers on mouse release rather than mouse
press
There's some precedent for the latter option even if it might get
confusing in the presence of drag operations. But that seems confusing
either way. Just be consistent.
This will make things more consistent in the long term, but I realize
one major cost: our button abstraction doesn't work well with luaML and
compute_layout. So we need something to replace it.
This required a little more restructuring of Global_state. It's not flat
now, it's hierarchical again, but in a different way.
after commit 3d89b8eb9d:
post
\- reply A
\- reply B
\- reply C
after commit f9f7dab9b7:
post
reply A
reply B
reply C
after this commit:
row
\- col
\- indent 0
\- post
\- col
\- indent 1
\- reply A
\- col
\- indent 2
\- reply B
\- col
\- indent 1
\- reply C
The indents are just invisible rectangles of different widths with 0
height.
One change I had to make was to initialize_editor. Neither luaML and
driver load lines from disk, but that's arguably the common scenario to
support.
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:
* initialize_thread will load items inside Global_state
* A will convert items into a relatively stable box model of rows,
columns and text editors in Surface, using compute_layout as a
helper.
* B will recompute some aspects of Surface as the viewport moves.
Anything that changes the height of any box needs to rerun A. Anything
that moves the viewport reruns B.
A comment is now in a better place.
Inlining an unnecessary function boundary removes ambiguity between the
similar names load_all and load_files_so_far. It also shrinks call
stacks on error.
Returning errors can feel warm and fuzzy, but it does no good if the
caller doesn't actually check the return value.
Scenario:
define a new function B
call it when initializing global variable A
everything works fine
restart
Before this commit you get a weird error because we silently stopped
loading, and now lots of functions are missing.
After this commit you get a better error message.