Add support for per-tree offset in layoutBoxes function

The old signature is retained for backward compatibility, assuming
an offset of 0.