Fix painting of search result

Current code was neither updating the search result rect (so the dirty
calculation missed it), nor did it correctly stick to the content rect
and left random blue rects at the edges.
wilder
Martin T. H. Sandsmark 5 years ago committed by Tomaz Canabrava
parent 0a6bcae57c
commit d47baac5a5
  1. 11
      src/terminalDisplay/TerminalDisplay.cpp
  2. 2
      src/terminalDisplay/TerminalDisplay.h
  3. 14
      src/terminalDisplay/TerminalPainter.cpp
  4. 2
      src/terminalDisplay/TerminalPainter.h

@ -726,7 +726,16 @@ void TerminalDisplay::paintEvent(QPaintEvent *pe)
for (const QRect &rect : qAsConst(dirtyImageRegion)) {
Q_EMIT drawContents(_image, paint, rect, false, _imageSize, _bidiEnabled, _lineProperties);
}
Q_EMIT drawCurrentResultRect(paint, _searchResultRect);
if (screenWindow()->currentResultLine() != -1) {
_searchResultRect.setRect(0,
contentRect().top() + (screenWindow()->currentResultLine() - screenWindow()->currentLine()) * _terminalFont->fontHeight(),
columns() * terminalFont()->fontWidth(),
_terminalFont->fontHeight()
);
Q_EMIT drawCurrentResultRect(paint, _searchResultRect);
}
if (_scrollBar->highlightScrolledLines().isEnabled()) {
Q_EMIT highlightScrolledLines(paint, _scrollBar->highlightScrolledLines().isTimerActive(), _scrollBar->highlightScrolledLines().rect());
}

@ -499,7 +499,7 @@ Q_SIGNALS:
int imageSize,
bool bidiEnabled,
QVector<LineProperty> lineProperties);
void drawCurrentResultRect(QPainter &painter, QRect searchResultRect);
void drawCurrentResultRect(QPainter &painter, const QRect &searchResultRect);
void highlightScrolledLines(QPainter &painter, bool isTimerActive, QRect rect);
QRegion highlightScrolledLinesRegion(bool nothingChanged, TerminalScrollBar *scrollBar);

@ -222,20 +222,8 @@ void TerminalPainter::drawContents(Character *image,
}
}
void TerminalPainter::drawCurrentResultRect(QPainter &painter, QRect searchResultRect)
void TerminalPainter::drawCurrentResultRect(QPainter &painter, const QRect &searchResultRect)
{
const auto display = qobject_cast<TerminalDisplay *>(sender());
if (display->screenWindow()->currentResultLine() == -1) {
return;
}
searchResultRect.setRect(0,
display->contentRect().top()
+ (display->screenWindow()->currentResultLine() - display->screenWindow()->currentLine())
* display->terminalFont()->fontHeight(),
display->columns() * display->terminalFont()->fontWidth(),
display->terminalFont()->fontHeight());
painter.fillRect(searchResultRect, QColor(0, 0, 255, 80));
}

@ -57,7 +57,7 @@ public Q_SLOTS:
QVector<LineProperty> lineProperties);
// draw a transparent rectangle over the line of the current match
void drawCurrentResultRect(QPainter &painter, QRect searchResultRect);
void drawCurrentResultRect(QPainter &painter, const QRect &searchResultRect);
// draw a thin highlight on the left of the screen for lines that have been scrolled into view
void highlightScrolledLines(QPainter &painter, bool isTimerActive, QRect rect);

Loading…
Cancel
Save