summaryrefslogtreecommitdiff
path: root/src/plugins/texteditor/textmark.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2017-07-25 11:54:44 +0200
committerEike Ziller <eike.ziller@qt.io>2017-07-25 11:54:44 +0200
commitefa5a7b6d76c85423e45b85e3db97186dc2d1923 (patch)
tree096f1a42d2b5943c742e1302489d548edfb026a4 /src/plugins/texteditor/textmark.cpp
parentc8962c34baae380f7db9840da419998007411226 (diff)
parent41127e0f4769bd32f3f5d88c2064ba61f222e195 (diff)
downloadqt-creator-efa5a7b6d76c85423e45b85e3db97186dc2d1923.tar.gz
Merge remote-tracking branch 'origin/4.4'
Conflicts: qtcreator.pri Change-Id: If5f4a9821a23ac0df81eb84b3980f9cf7ecd70ba
Diffstat (limited to 'src/plugins/texteditor/textmark.cpp')
-rw-r--r--src/plugins/texteditor/textmark.cpp67
1 files changed, 44 insertions, 23 deletions
diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp
index b2859642c6..d4f9db7c50 100644
--- a/src/plugins/texteditor/textmark.cpp
+++ b/src/plugins/texteditor/textmark.cpp
@@ -121,43 +121,58 @@ void TextMark::paintIcon(QPainter *painter, const QRect &rect) const
m_icon.paint(painter, rect, Qt::AlignCenter);
}
-void TextMark::paintAnnotation(QPainter *painter, QRectF *annotationRect) const
+void TextMark::paintAnnotation(QPainter &painter, QRectF *annotationRect,
+ const qreal fadeInOffset, const qreal fadeOutOffset) const
{
QString text = lineAnnotation();
if (text.isEmpty())
return;
- const AnnotationRects &rects = annotationRects(*annotationRect, painter->fontMetrics());
-
- const QColor markColor = m_hasColor ? Utils::creatorTheme()->color(m_color).toHsl()
- : painter->pen().color();
- const AnnotationColors &colors =
- AnnotationColors::getAnnotationColors(markColor, painter->background().color());
-
- painter->save();
- painter->setPen(colors.rectColor);
- painter->setBrush(colors.rectColor);
- painter->drawRect(rects.annotationRect);
- painter->setPen(colors.textColor);
- paintIcon(painter, rects.iconRect.toAlignedRect());
- painter->drawText(rects.textRect, Qt::AlignLeft, rects.text);
- painter->restore();
- *annotationRect = rects.annotationRect;
+ const AnnotationRects &rects = annotationRects(*annotationRect, painter.fontMetrics(),
+ fadeInOffset, fadeOutOffset);
+ const QColor &markColor = m_hasColor ? Utils::creatorTheme()->color(m_color).toHsl()
+ : painter.pen().color();
+ const AnnotationColors &colors = AnnotationColors::getAnnotationColors(
+ markColor, painter.background().color());
+
+ painter.save();
+ QLinearGradient grad(rects.fadeInRect.topLeft(), rects.fadeInRect.topRight());
+ grad.setColorAt(0.0, Qt::transparent);
+ grad.setColorAt(1.0, colors.rectColor);
+ painter.fillRect(rects.fadeInRect, grad);
+ painter.fillRect(rects.annotationRect, colors.rectColor);
+ painter.setPen(colors.textColor);
+ paintIcon(&painter, rects.iconRect.toAlignedRect());
+ painter.drawText(rects.textRect, Qt::AlignLeft, rects.text);
+ if (rects.fadeOutRect.isValid()) {
+ grad = QLinearGradient(rects.fadeOutRect.topLeft(), rects.fadeOutRect.topRight());
+ grad.setColorAt(0.0, colors.rectColor);
+ grad.setColorAt(1.0, Qt::transparent);
+ painter.fillRect(rects.fadeOutRect, grad);
+ }
+ painter.restore();
+ annotationRect->setRight(rects.fadeOutRect.right());
}
TextMark::AnnotationRects TextMark::annotationRects(const QRectF &boundingRect,
- const QFontMetrics &fm) const
+ const QFontMetrics &fm,
+ const qreal fadeInOffset,
+ const qreal fadeOutOffset) const
{
AnnotationRects rects;
- rects.annotationRect = boundingRect;
rects.text = lineAnnotation();
+ if (rects.text.isEmpty())
+ return rects;
+ rects.fadeInRect = boundingRect;
+ rects.fadeInRect.setWidth(fadeInOffset);
+ rects.annotationRect = boundingRect;
+ rects.annotationRect.setLeft(rects.fadeInRect.right());
const bool drawIcon = !m_icon.isNull();
constexpr qreal margin = 1;
- rects.iconRect = QRectF(boundingRect.left() + margin, boundingRect.top() + margin, 0, 0);
- if (drawIcon) {
- rects.iconRect.setHeight(boundingRect.height() - 2 * margin);
+ rects.iconRect = QRectF(rects.annotationRect.left(), boundingRect.top(),
+ 0, boundingRect.height());
+ if (drawIcon)
rects.iconRect.setWidth(rects.iconRect.height() * m_widthFactor);
- }
rects.textRect = QRectF(rects.iconRect.right() + margin, boundingRect.top(),
qreal(fm.width(rects.text)), boundingRect.height());
rects.annotationRect.setRight(rects.textRect.right() + margin);
@@ -165,6 +180,12 @@ TextMark::AnnotationRects TextMark::annotationRects(const QRectF &boundingRect,
rects.textRect.setRight(boundingRect.right() - margin);
rects.text = fm.elidedText(rects.text, Qt::ElideRight, int(rects.textRect.width()));
rects.annotationRect.setRight(boundingRect.right());
+ rects.fadeOutRect = QRectF(rects.annotationRect.topRight(),
+ rects.annotationRect.bottomRight());
+ } else {
+ rects.fadeOutRect = boundingRect;
+ rects.fadeOutRect.setLeft(rects.annotationRect.right());
+ rects.fadeOutRect.setWidth(fadeOutOffset);
}
return rects;
}