When designing templates and pages, this will draw a filled rectangle on the element bounding box (if self.css('missingElementFill' is defined) and a cross, indicating that this element has missing content (as in unused image frames). Only draw if the list self.showGr
(self, e, origin)
| 559 | self.context.text(bs, (px - w/2, py + S*1.5)) |
| 560 | |
| 561 | def drawMissingElementRect(self, e, origin): |
| 562 | """When designing templates and pages, this will draw a filled |
| 563 | rectangle on the element bounding box (if self.css('missingElementFill' |
| 564 | is defined) and a cross, indicating that this element has missing |
| 565 | content (as in unused image frames). Only draw if the list |
| 566 | self.showGrid contains proper types of grid names. |
| 567 | |
| 568 | >>> from pagebot import getContext |
| 569 | >>> context = getContext() |
| 570 | >>> from pagebot.elements.element import Element |
| 571 | >>> from pagebot.style import getRootStyle |
| 572 | >>> from pagebot.elements.views.pageview import PageView |
| 573 | >>> style = getRootStyle() # Get default values |
| 574 | >>> e = Element(style=style) # Works on generic elements as well as pages. |
| 575 | >>> view = PageView(context=context, style=style) |
| 576 | >>> view.showMissingElement = True |
| 577 | >>> view.drawMissingElementRect(e, (0, 0)) |
| 578 | """ |
| 579 | if (self.showMissingElement and e.isPage) or e.showMissingElement: |
| 580 | context = self.context |
| 581 | |
| 582 | p = pointOffset(e.origin, origin) |
| 583 | p = self._applyScale(e, p) |
| 584 | px, py, _ = e._applyAlignment(p) # Ignore z-axis for now. |
| 585 | |
| 586 | context.save() |
| 587 | context.setShadow(self.shadow) |
| 588 | |
| 589 | sMissingElementFill = self.css('viewMissingElementFill', noColor) |
| 590 | if sMissingElementFill is not noColor: |
| 591 | context.fill(sMissingElementFill) |
| 592 | context.stroke(noColor) |
| 593 | context.rect(px, py, self.w, self.h) |
| 594 | # Draw crossed rectangle. |
| 595 | context.fill(noColor) |
| 596 | context.stroke(blackColor, pt(0.5)) |
| 597 | context.rect(px, py, self.w, self.h) |
| 598 | context.newPath() |
| 599 | context.moveTo((px, py)) |
| 600 | context.lineTo((px + self.w, py + self.h)) |
| 601 | context.moveTo((px + self.w, py)) |
| 602 | context.lineTo((px, py + self.h)) |
| 603 | context.drawPath() |
| 604 | context.restore() |
| 605 | e._restoreScale(self) |
| 606 | |
| 607 | # G R I D |
| 608 |
nothing calls this directly
no test coverage detected