| 63 | } |
| 64 | |
| 65 | void ScrollText::paintEvent(QPaintEvent*) |
| 66 | { |
| 67 | QPainter p(this); |
| 68 | |
| 69 | if (scrollEnabled) |
| 70 | { |
| 71 | buffer.fill(qRgba(0, 0, 0, 0)); |
| 72 | QPainter pb(&buffer); |
| 73 | pb.setPen(p.pen()); |
| 74 | pb.setFont(p.font()); |
| 75 | |
| 76 | int x = qMin(-scrollPos, 0) + leftMargin; |
| 77 | |
| 78 | while (x < width()) |
| 79 | { |
| 80 | pb.drawStaticText(QPointF(x, (height() - wholeTextSize.height()) / 2), staticText); |
| 81 | x += wholeTextSize.width(); |
| 82 | } |
| 83 | |
| 84 | // Apply Alpha Channel |
| 85 | pb.setCompositionMode(QPainter::CompositionMode_DestinationIn); |
| 86 | pb.setClipRect(width() - 15, 0, 15, height()); |
| 87 | pb.drawImage(0, 0, alphaChannel); |
| 88 | pb.setClipRect(0, 0, 15, height()); |
| 89 | |
| 90 | // initial situation: don't apply alpha channel in the left half of the image at all; apply it more and more until scrollPos gets positive |
| 91 | if (scrollPos < 0) |
| 92 | { |
| 93 | pb.setOpacity((qreal) (qMax(-8, scrollPos) + 8) / 8.0); |
| 94 | } |
| 95 | |
| 96 | pb.drawImage(0, 0, alphaChannel); |
| 97 | |
| 98 | // pb.end(); |
| 99 | p.drawImage(0, 0, buffer); |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | p.drawStaticText(QPointF(leftMargin, (height() - wholeTextSize.height()) / 2), staticText); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | void ScrollText::resizeEvent(QResizeEvent*) |
| 108 | { |