HPacker packs its children horizontally, automatically adjusting their relative positions at draw time. .. code-block:: none +-------------------------------+ | Child 1 Child 2 Child 3 | +-------------------------------+
| 473 | |
| 474 | |
| 475 | class HPacker(PackerBase): |
| 476 | """ |
| 477 | HPacker packs its children horizontally, automatically adjusting their |
| 478 | relative positions at draw time. |
| 479 | |
| 480 | .. code-block:: none |
| 481 | |
| 482 | +-------------------------------+ |
| 483 | | Child 1 Child 2 Child 3 | |
| 484 | +-------------------------------+ |
| 485 | """ |
| 486 | |
| 487 | def _get_bbox_and_child_offsets(self, renderer): |
| 488 | # docstring inherited |
| 489 | dpicor = renderer.points_to_pixels(1.) |
| 490 | pad = self.pad * dpicor |
| 491 | sep = self.sep * dpicor |
| 492 | |
| 493 | bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()] |
| 494 | if not bboxes: |
| 495 | return Bbox.from_bounds(0, 0, 0, 0).padded(pad), [] |
| 496 | |
| 497 | (y0, y1), yoffsets = _get_aligned_offsets( |
| 498 | [bbox.intervaly for bbox in bboxes], self.height, self.align) |
| 499 | width, xoffsets = _get_packed_offsets( |
| 500 | [bbox.width for bbox in bboxes], self.width, sep, self.mode) |
| 501 | |
| 502 | x0 = bboxes[0].x0 |
| 503 | xoffsets -= ([bbox.x0 for bbox in bboxes] - x0) |
| 504 | |
| 505 | return (Bbox.from_bounds(x0, y0, width, y1 - y0).padded(pad), |
| 506 | [*zip(xoffsets, yoffsets)]) |
| 507 | |
| 508 | |
| 509 | class PaddedBox(OffsetBox): |
no outgoing calls
searching dependent graphs…