From 0ca9ea353c91b9715e1dc9e8533560f94f261e23 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 20 Oct 2020 10:16:33 +0200 Subject: Editor: Do not use disabled code color for right margin highlight Fixes: QTCREATORBUG-17174 Change-Id: I68729d5a44b23fe46b810054a1dc472ffd63e272 Reviewed-by: Christian Stenger --- src/plugins/texteditor/texteditor.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index ec634b0e85..6bd05f9b2c 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -4175,6 +4175,13 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data, q->viewport()->update(updateRect); } +QColor blendRightMarginColor(const FontSettings &settings, bool areaColor) +{ + const QColor baseColor = settings.toTextCharFormat(C_TEXT).background().color(); + const QColor col = (baseColor.value() > 128) ? Qt::black : Qt::white; + return blendColors(baseColor, col, areaColor ? 16 : 32); +} + void TextEditorWidgetPrivate::paintRightMarginArea(PaintEventData &data, QPainter &painter) const { if (m_visibleWrapColumn <= 0) @@ -4189,7 +4196,7 @@ void TextEditorWidgetPrivate::paintRightMarginArea(PaintEventData &data, QPainte data.eventRect.top(), data.viewportRect.width() - data.rightMargin, data.eventRect.height()); - painter.fillRect(behindMargin, data.ifdefedOutFormat.background()); + painter.fillRect(behindMargin, blendRightMarginColor(m_document->fontSettings(), true)); } } @@ -4199,11 +4206,8 @@ void TextEditorWidgetPrivate::paintRightMarginLine(const PaintEventData &data, if (m_visibleWrapColumn <= 0 || data.rightMargin >= data.viewportRect.width()) return; - const QBrush background = data.ifdefedOutFormat.background(); - const QColor baseColor = m_document->fontSettings().toTextCharFormat(C_TEXT).background().color(); - const QColor col = (baseColor.value() > 128) ? Qt::black : Qt::white; const QPen pen = painter.pen(); - painter.setPen(blendColors(background.isOpaque() ? background.color() : baseColor, col, 32)); + painter.setPen(blendRightMarginColor(m_document->fontSettings(), false)); painter.drawLine(QPointF(data.rightMargin, data.eventRect.top()), QPointF(data.rightMargin, data.eventRect.bottom())); painter.setPen(pen); -- cgit v1.2.3