On Mon, Oct 20, 2008 at 9:09 AM, Ville M. Vainio <[EMAIL PROTECTED]> wrote:

> There are 2 "catches":
>
> - You need to add a dummy child under the new items that are expanded,
> if they have any, to draw the plus sign to the parent
>
> - You need to redraw the tree when you expand items that haven't been
> expanded before. This should happen on itemExpanded signal, not in
> core (because the tree code can expand the nodes without consuling
> core, e.g. by mouse clicks).

I now have a plan for "the simplest thing that could possibly work".

Continuing the "gui extension pattern", I'll change calls to c.redraw
in Leo's core to c.redrawAfterInsert, c.redrawAfterDelete,
c.redrawAfterMove, etc.  In the base class, these methods will simply
call c.frame.tree.redraw(), so despite appearances there will be no
real change.

But in the qt plugin these methods will attempt optimizations.  For
example, leoQtTree.redrawAfterInsert will simply insert a new node if
no ancestor is a clone.  For descendants of clones, an insertion will
be made for all visible cloned ancestors.

The hardest redraw will happen when a node is expanded.  The tree may
have changed in many ways since the node was previously expanded.
Indeed, it may never have been expanded.  A quick scan will be made to
see the newly exposed tree matches Leo's model. If there is a mismatch
the simplest thing will be to delete all the newly visible child nodes
and recreate them from scratch.  In practice, this should be
relatively fast because only a few (or few dozen) nodes will become
visible.

So this is good: we have a way of hooking optimized methods into Leo's
core safely, and we have a way of dealing with various tree changes in
the most straightforward way possible.  The big question is, however,
how well QTreeWidget will handle rapid-fire tree alterations as nodes
are moved around?  wxTreeCtrl was not up to the job.

These considerations show just how sophisticated Leo's tkinter tree
drawing code is: it can redraw trees quickly without choking the gc.
It does this by managing tkinter widgets by hand--they are never
deleted and are allocated from free lists whenever possible.

Edward

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to