Trees

Layout

The layout at a node is invoked by the following command which causes a layout of all nodes in the subtree rooted at node.

.pad tree layout $root

The tree maintains a notion of focus. By default, no nodes have focus, and all nodes are the same size. However, making a node get focus will increase it's size (by an amount specified by setfocusmag). Executing the following code will warp the tree layout as shown:

.pad tree setfocus $child1 1.0
.pad tree layout $root


Normally, when invoking the layout command on a tree, the tree will animate without changing the view. The -view option in the layout command is used to animate the view while a layout is taking place. Because the user may want to animate the view to a position based on the future position of a node, the getlayoutbbox provides the bounding box of a node at the end of the current animation. These commands must be used in a specific order, so that the information referenced by both the layout code and the user is valid.

To animate the view of a layout to center child1, use the following commands.

.pad tree computelayout $root
set bb [.pad tree getlayoutbbox $child1]
set x [lindex $bb 0] 
set y [lindex $bb 0] 
set z [lindex [.pad getview] 2] 
.pad tree animatelayout $root -view "$x $y $z"


Pad++ Programmer's Guide - 10 JUN 1996

Generated with Harlequin WebMaker

Web Accessibility