|
From: Bryan O. <br...@bi...> - 2004-09-27 18:02:09
|
Joe English wrote:
> Did some more work on this over the weekend. I'm pretty happy
> with the current data model; the primitives provided seem just
> about right.
This is a nice step in the right direction. I like the ability to
detatch items and move them about without having to destroy and recreate
them.
Do you have a sample implementation built on top of some other widget?
If not, I might see how easy (or not) it would be to combin snit and
tktreectrl to mock this sucker up.
I think the "column" subcommand should be "columnconfigure" since it is
conceptually similar to entryconfigure or itemconfigure subcommands in
other widgets.
It would be nice to specify where the image is to appear in a column
heading. Sometimes it makes sense to put it on the left (think of an
icon that represents the type of data), sometimes on the right (think of
a up/down triangle to represent sorting).
I'd like an option to specify whether a column is to be of fixed width
or not (assuming that columns can be interactively resized). This
wouldn't be a showstopper, but would lead to a more polished UI.
Here are suggestions for the obvious virtual events:
<<TreeviewSelect>> - when an item is selected
<<TreeviewOpen>> - when an item is opened
<<TreeviewClose>> - when an item is closed
The open and close events create an interesting problem, which is how to
present to the procedure being called which item was just opened. Since
the event mechanism doesn't provide a way to attach metadata we need to
come up with a way to query which item was just opened (.treeview cget
-lastopen?).
That, or we take this as an opportunity to modify "event generate" to
accept a "-metadata" option, eg:
event generate .tree <<TreeviewOpen>> -metadata $item
...
bind .tree <<TreeviewOpen>> {openHandler %M}
proc openHandler {metadata} {
puts "hey, item $metadata was opened!"
}
In lieu of all that, the treeview widget could have options to specify
procs to call when something happens (eg: .treeview configure
-opencommand whatever -closecommand whatever...). I prefer virtual
events if we can solve the metadata problem.
The main need for this is to be able to build a tree dynamically. For
example, there's no need to create children for a directory unless the
user opens that directory. The way to do that is to have a proc called
whenever an item is opened for the first time.
|