forked from qt-creator/qt-creator
Editor: avoid relayouting of annotation text for each paint event
Change-Id: Icabf033a43922bb9ebafd1a7973dcac851e9369e Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -138,6 +138,8 @@ void TextMark::paintAnnotation(QPainter &painter,
|
||||
painter.fontMetrics(),
|
||||
fadeInOffset,
|
||||
fadeOutOffset);
|
||||
if (m_staticAnnotationText.text() != rects.text)
|
||||
m_staticAnnotationText.setText(rects.text);
|
||||
annotationRect->setRight(rects.fadeOutRect.right());
|
||||
const QRectF eventRectF(eventRect);
|
||||
if (!(rects.fadeInRect.intersects(eventRectF) || rects.annotationRect.intersects(eventRectF)
|
||||
@@ -161,7 +163,7 @@ void TextMark::paintAnnotation(QPainter &painter,
|
||||
painter.fillRect(rects.annotationRect, colors.rectColor);
|
||||
painter.setPen(colors.textColor);
|
||||
paintIcon(&painter, rects.iconRect.toAlignedRect());
|
||||
painter.drawText(rects.textRect, Qt::AlignLeft, rects.text);
|
||||
painter.drawStaticText(rects.textRect.topLeft(), m_staticAnnotationText);
|
||||
if (rects.fadeOutRect.isValid()) {
|
||||
grad = QLinearGradient(rects.fadeOutRect.topLeft() - contentOffset,
|
||||
rects.fadeOutRect.topRight() - contentOffset);
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QIcon>
|
||||
#include <QStaticText>
|
||||
#include <QVector>
|
||||
|
||||
#include <optional>
|
||||
@@ -139,6 +140,7 @@ private:
|
||||
bool m_visible = false;
|
||||
TextMarkCategory m_category;
|
||||
QString m_lineAnnotation;
|
||||
mutable QStaticText m_staticAnnotationText;
|
||||
QString m_toolTip;
|
||||
std::function<QString()> m_toolTipProvider;
|
||||
QString m_defaultToolTip;
|
||||
|
Reference in New Issue
Block a user