diff options
author | Leandro Melo <leandro.melo@nokia.com> | 2010-11-12 11:31:12 +0100 |
---|---|---|
committer | Leandro Melo <leandro.melo@nokia.com> | 2010-11-12 14:06:45 +0100 |
commit | 5723a73ba58e3f825f5f6a3d5b8e74ce0d1e3e95 (patch) | |
tree | 1c34b2eaada11c6d9a350731a7562cb2bcf9f10f /src/plugins/texteditor/basetexteditor.cpp | |
parent | 2a038e30f75c3df41871ecaae34696b311d4eca6 (diff) | |
download | qt-creator-5723a73ba58e3f825f5f6a3d5b8e74ce0d1e3e95.tar.gz |
Editors: Make block highlights go beyond the margin
Block highlights should still be visible even outside the margin (when
margins are displayed naturally), since it acts only as indicator of
the character limit.
Apparently this had already been noticed before and recently there was
a merge request (no. 204) with an attempt to fix it. However, the
implementation was not handling it in a nice form. This is a small
patch that solves the issue and keeps the editor beautiful. (Check
the merge request for more details.)
Reviewed-by: Thorbjorn Lindeijer
Diffstat (limited to 'src/plugins/texteditor/basetexteditor.cpp')
-rw-r--r-- | src/plugins/texteditor/basetexteditor.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index a11f0bd5c4..3d3ab57530 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -2866,13 +2866,22 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) int count = d->m_highlightBlocksInfo.count(); if (count) { - QRectF rr = r; - rr.setWidth(viewport()->width()); - if (lineX > 0) - rr.setRight(qMin(lineX, rr.right())); for (int i = 0; i <= depth; ++i) { + const QColor &blendedColor = calcBlendColor(baseColor, i, count); int vi = i > 0 ? d->m_highlightBlocksInfo.visualIndent.at(i-1) : 0; - painter.fillRect(rr.adjusted(vi, 0, -8*i, 0), calcBlendColor(baseColor, i, count)); + QRectF oneRect = r; + oneRect.setWidth(viewport()->width()); + oneRect.adjust(vi, 0, -8*i, 0); + if (oneRect.left() >= oneRect.right()) + continue; + if (lineX > 0 && oneRect.left() < lineX && oneRect.right() > lineX) { + QRectF otherRect = r; + otherRect.setLeft(lineX + 1); + otherRect.setRight(oneRect.right()); + oneRect.setRight(lineX - 1); + painter.fillRect(otherRect, blendedColor); + } + painter.fillRect(oneRect, blendedColor); } } offsetFP.ry() += r.height(); |