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(),
|
painter.fontMetrics(),
|
||||||
fadeInOffset,
|
fadeInOffset,
|
||||||
fadeOutOffset);
|
fadeOutOffset);
|
||||||
|
if (m_staticAnnotationText.text() != rects.text)
|
||||||
|
m_staticAnnotationText.setText(rects.text);
|
||||||
annotationRect->setRight(rects.fadeOutRect.right());
|
annotationRect->setRight(rects.fadeOutRect.right());
|
||||||
const QRectF eventRectF(eventRect);
|
const QRectF eventRectF(eventRect);
|
||||||
if (!(rects.fadeInRect.intersects(eventRectF) || rects.annotationRect.intersects(eventRectF)
|
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.fillRect(rects.annotationRect, colors.rectColor);
|
||||||
painter.setPen(colors.textColor);
|
painter.setPen(colors.textColor);
|
||||||
paintIcon(&painter, rects.iconRect.toAlignedRect());
|
paintIcon(&painter, rects.iconRect.toAlignedRect());
|
||||||
painter.drawText(rects.textRect, Qt::AlignLeft, rects.text);
|
painter.drawStaticText(rects.textRect.topLeft(), m_staticAnnotationText);
|
||||||
if (rects.fadeOutRect.isValid()) {
|
if (rects.fadeOutRect.isValid()) {
|
||||||
grad = QLinearGradient(rects.fadeOutRect.topLeft() - contentOffset,
|
grad = QLinearGradient(rects.fadeOutRect.topLeft() - contentOffset,
|
||||||
rects.fadeOutRect.topRight() - contentOffset);
|
rects.fadeOutRect.topRight() - contentOffset);
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QStaticText>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -139,6 +140,7 @@ private:
|
|||||||
bool m_visible = false;
|
bool m_visible = false;
|
||||||
TextMarkCategory m_category;
|
TextMarkCategory m_category;
|
||||||
QString m_lineAnnotation;
|
QString m_lineAnnotation;
|
||||||
|
mutable QStaticText m_staticAnnotationText;
|
||||||
QString m_toolTip;
|
QString m_toolTip;
|
||||||
std::function<QString()> m_toolTipProvider;
|
std::function<QString()> m_toolTipProvider;
|
||||||
QString m_defaultToolTip;
|
QString m_defaultToolTip;
|
||||||
|
Reference in New Issue
Block a user