A.3 Layout

Layout operates in a context, which is the siblings of the bind:layout element.

Every sibling element with graphical content (anything visual) with the same bind:group is part of the layout.

Any relationships between the elements (parent-child, and so on) are visible as lines drawn between the visual elements.

Because layout operates on siblings it is common to place the layout command within a group:

<g>
  <bind:layout name="tree"/>
  <rect bind:container="true" width="1" 
    height="1" stroke="blue" fill="none"/>
  <rect width="50" height="25"/>
  <circle r="25" stroke="blue" fill="none" />
</g>

The bind:layout operates against the second rectangle and the circle. The first rectangle has bind:container=true specified. When a rectangle is tagged with bind:container, it is excluded from the layout. After layout is completed the bound of the laid-out graphics is computed, and the container rectangle is stretched to fit around them. This provides a convenient way of wrapping automatically laid-out graphics.

It’s frequent to want only the wrapping behavior and no other layout. Just specify name="wrap" in your bind:layout command if you want this. We often want to apply automatic layout to only those elements that have been automatically generated by a variant of the bind:template element.

You can place the bind:layout element inside a bind:template (or bind:children) element, as follows:

<g>
  <bind:children graphic="Nodes__Classic#node" depth="2">
    <bind:layout name="ortho"/>
  </bind:children>
  <rect bind:container="true" width="1" height="1" 
    stroke="blue" fill="none"/>
  <circle r="25" stroke="blue" fill="none" />
</g>

The rect and circle elements are not automatically laid out. Only visual elements generated by the bind:children command are.

Bind layout attributes: