Commit ae68aa56 authored by David Schulz's avatar David Schulz

TextEditor: Update position of annotations outside event rectangle

Change-Id: Ie7d3db989b48a605fad4642c339940d67e505e1e
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 13717262
......@@ -397,7 +397,7 @@ public:
bool expanded,
bool active,
bool hovered) const;
void drawLineAnnotation(QPainter &painter, const QTextBlock &block, qreal start, const QRect &eventRect);
void updateLineAnnotation(QPainter &painter, const QTextBlock &block, qreal start, const QRect &eventRect);
void toggleBlockVisible(const QTextBlock &block);
QRect foldBox();
......@@ -3866,9 +3866,11 @@ QRectF TextEditorWidgetPrivate::getLastLineLineRect(const QTextBlock &block)
return line.naturalTextRect().translated(contentOffset.x(), top).adjusted(0, 0, -1, -1);
}
void TextEditorWidgetPrivate::drawLineAnnotation(
void TextEditorWidgetPrivate::updateLineAnnotation(
QPainter &painter, const QTextBlock &block, qreal rightMargin, const QRect &eventRect)
{
m_annotationRects.remove(block.blockNumber());
if (!m_displaySettings.m_displayAnnotations)
return;
......@@ -3912,9 +3914,9 @@ void TextEditorWidgetPrivate::drawLineAnnotation(
boundingRect = QRectF(x, lineRect.top(), q->viewport()->width() - x, lineRect.height());
if (boundingRect.isEmpty())
break;
if (eventRect.intersects(boundingRect.toRect()))
mark->paintAnnotation(painter, &boundingRect, offset, itemOffset / 2, q->contentOffset());
// paint annotation
mark->paintAnnotation(painter, &boundingRect, offset, itemOffset / 2, q->contentOffset());
x = boundingRect.right();
offset = itemOffset / 2;
m_annotationRects[block.blockNumber()].append({boundingRect, mark});
......@@ -4426,10 +4428,8 @@ void TextEditorWidget::paintEvent(QPaintEvent *e)
|| d->m_blockSelection.positionColumn == d->m_blockSelection.anchorColumn)
&& blockSelectionCursorRect.isValid())
painter.fillRect(blockSelectionCursorRect, palette().text());
d->m_annotationRects.remove(block.blockNumber());
d->drawLineAnnotation(painter, block, lineX < viewportRect.width() ? lineX : 0, er);
}
d->updateLineAnnotation(painter, block, lineX < viewportRect.width() ? lineX : 0, er);
offset.ry() += r.height();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment