Draw box with element info.
(self, e, px, py, pw, ph)
| 651 | e._restoreScale(self) |
| 652 | |
| 653 | def drawInfoBox(self, e, px, py, pw, ph): |
| 654 | """Draw box with element info.""" |
| 655 | style = dict(font=self.css('viewInfoFont'), |
| 656 | fontSize=self.css('viewInfoFontSize'), |
| 657 | leading=self.css('viewInfoLeading'), |
| 658 | textFill=color(0.1)) |
| 659 | bs = self.context.newString(str(e), style=style) |
| 660 | tw, th = bs.textSize |
| 661 | |
| 662 | # Padding in box and shadow offset. |
| 663 | Pd = 4 |
| 664 | |
| 665 | # Make info box outdent the element. Keeping shadow on the |
| 666 | # element top left corner. |
| 667 | tpx = px - Pd/2 |
| 668 | tpy = py + e.h - th - Pd |
| 669 | |
| 670 | # Tiny shadow |
| 671 | self.context.fill(color(0.3, 0.3, 0.3, 0.5)) |
| 672 | self.context.stroke(noColor) |
| 673 | self.context.rect(tpx+Pd/2, tpy, tw+2*Pd, th+1.5*Pd) |
| 674 | # Frame |
| 675 | self.context.fill(self.css('viewInfoFill')) |
| 676 | self.context.stroke(color(0.3), w=pt(0.25)) |
| 677 | self.context.rect(tpx, tpy, tw+2.5*Pd, th+1.5*Pd) |
| 678 | self.context.text(bs, (tpx+Pd, tpy+th)) |
| 679 | |
| 680 | def drawDimensions(self, px, py, pw, ph): |
| 681 | """Draws width and height measures.""" |