Next: Change-space Notification Protocol, Previous: Space composition, Up: Layout protocol
When allocate-space
is called on a pane P, it must
compare the space-requirement of the children of P to the
available space, in order to distribute it in the most preferable way.
In order to avoid a second recursive invokation of
compose-space
at this point, we store the result of the
previous call to compose-space
in each pane.
To handle this situtation and also explicitly given size options, we use
an :around method on compose-space
. The
:around method will call the primary method only if necessary
(i.e., (eq (slot-value pane 'space-requirement) nil)
), and store
the result of the call to the primary method in the
space-requirement
slot.
We then compute the space requirement of the pane as follows:
(setf (space-requirement-width ...) (or explicit-width (space-requirement-width request)) ... (space-requirement-max-width ...) (or explicit-max-width explicit-width (space-requirement-max-width request)) ...)
When the call to the primary method is not necessary we simply return the stored value.
The spacer-pane
is an exception to the rule indicated above. The
explicit size you can give for this pane should represent the margin
size. So its primary method should only call compose on the child. And
the around method will compute the explicit sizes for it from the space
requirement of the child and for the values given for the surrounding
space.