Sunday, September 25, 2005

CLIM-like features in Factor UI

(First, I have to say that Blogger.com's user interface is much nicer than JRoller. It supports WYSIWYG editing of weblog posts and makes great use of AJAX for a snappier user interface.)

While my understanding of CLIM is incomplete, the most striking aspect is how central input/output streams are. CLIM extends output streams to support marked up text and graphics. To output a set of widgets with a vertical layout, you write them to an extended output stream, with a line break between each widget; horizontal layout is the same except with no intermediate line breaks. The extended output stream is connected to a pane which displays the output. Live presentations may be written to the output stream; they may be clicked and used as input to commands. CLIM supports a notion of extended input streams, which support input of presentations, together with completion.

The Factor UI already supports a pane gadget, with extended stream output protocol, and (currently) only plain text input. Today, I spent some time cleaning up the pane gadget to be more general purpose, and changed the stack display widget in the listener to use a pane instead of constructing a vertical layout by hand.

I implemented an outliner gadget that uses CLIM concepts; it is similar to "Tree" gadgets in other GUI toolkits, but there is a fundamental difference. The outliner gadget is given a quotation; when the outliner is expanded, the quotation is run inside a dynamic scope whose standard output is bound to a new pane. The quotation can then write attributed text and live gadgets to the stream; some of those gadgets might themselves be outliners. This results in much simpler code than a typical "tree view"/"tree model" separation. Of course there is a limitation in that it is not easy to remove individual tree nodes; instead, you must regenerate the outliner view. However I don't expect this to be a problem.

This screenshot shows the outliner in action, with a simple word browser. I know it is ugly; I will be working on appearance later:



The code is trivial:

: word. ( word -- )
dup
swap [ literalize , \ see , ] [ ] make outliner. ;

: vocab. ( vocab -- )
dup


Here is another one. This time its a messier hack and I won't show the source; I still have to think about a few things and integrate it in a clean manner. This shows expandable slots in an outlining inspector.



The new outliner allows a very powerful class of UI tools to be developed; however the tools will continue to work on the command line, albeit with reduced functionality.

No comments: