Saturday, June 20, 2009

Sizeable Zones

A dock tree is subdivided into zones, which contain either a docked control or child zones. When the zones shall be resizeable, splitters have to be inserted into the layout. In the EasyDockTree the splitter areas are part of the zones, not controls between zones as in an anchored layout. In the former implementation the splitter was part of the zone header, so that only zones with a child control and according header could have an splitter. A new model should allow for splitters also between zones without headers.

When splitters in a dock tree can reside at the bottom or right of a zone, every zone has an splitter area when its bottom/right is less than the root zone bottom/right. That's easy :-)

But which zone does a splitter area belong to? A zone can have splitter areas at both its bottom and right, at the same time, and at most one of these can belong to the zone splitter itself, the other area(s) belong to the splitters of some parent zone. Also easy: when a zone has an next visible sibling, it also must have an splitter in front of that sibling.

How are these splitters involved in coordinate calculations?

Currently every zone has stored its bottom and right coordinates. Either coordinate has to be decremented by the width of an splitter when a splitter exists in that direction, i.e. when the coordinate is less than the corresponding root zone coordinate. The remaining area can contain child zones, or is subdivided into a client (control) area and a header area, which again is subdivided into button areas and the caption.

When a zone is resized, and it is a leaf zone (contains a control), then the control occupies the zone's client area, otherwise the child zones occupy the full zone extent and the zone has no header.

When a header has to be drawn for a leaf zone, the splitters have to be excluded from the zone rectangle, then the width or height has to be adjusted to the header size.

A hit test can be performed top-down, excluding zones to the top or left of the mouse position, then recursing down into the children of the matching zone. Before the child zones are checked, a hit on the zone splitters has to be detected, so that a splitter of the topmost zone is found immediately. When the right mouse button is pressed on a splitter, the site's splitter control is positioned to the zone's splitter area. Since the splitter areas can overlap at the bottom right of a zone, the zone's orientation has to be checked in order to give precedence to the splitter between the top level siblings. The same considerations apply to the placement of splitters in an anchored tree layout.

Now I'll try to implement this model in the EasyDockTree. Then some thoughts on the handling of invisible controls are required, and about chances for collapsing zones, i.e. hiding a child control while still showing the zone header.

No comments:

Post a Comment