From 5db47041156b975b99ca9284479f306a3063c3da Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 8 Jul 2020 20:30:07 +1000 Subject: Fix translucent rectangle drawing on Qt. --- doc/ScintillaHistory.html | 6 ++++++ qt/ScintillaEditBase/PlatQt.cpp | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index ec85a8a00..1b8522a2a 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -602,6 +602,12 @@ when Lua script calls os.execute or io.popen.
  • + Fix translucent rectangle drawing on Qt. When drawing a translucent selection, there were edge + artifacts as the calls used were drawing outlines over fill areas. Make bottom and right borders on + INDIC_ROUNDBOX be same intensity as top and left. + Replaced some deprecated Qt calls with currently supported calls. +
  • +
  • Fix printing on Windows to use correct text size. Bug #2185.
  • diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index 8f572981c..d9838841c 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -353,18 +353,34 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int alphaOutline, int /*flags*/) { - QColor qOutline = QColorFromCA(outline); - qOutline.setAlpha(alphaOutline); - GetPainter()->setPen(QPen(qOutline)); - - QColor qFill = QColorFromCA(fill); - qFill.setAlpha(alphaFill); - GetPainter()->setBrush(QBrush(qFill)); - - // A radius of 1 shows no curve so add 1 - qreal radius = cornerSize+1; - QRectF rect(rc.left, rc.top, rc.Width() - 1, rc.Height() - 1); - GetPainter()->drawRoundedRect(rect, radius, radius); + const QColor qFill = QColorFromColourAlpha(ColourAlpha(fill, alphaFill)); + const QBrush brushFill(qFill); + GetPainter()->setBrush(brushFill); + + if ((fill == outline) && (alphaFill == alphaOutline)) { + painter->setPen(Qt::NoPen); + const QRectF rect = QRectFFromPRect(rc); + if (cornerSize > 0.0f) { + // A radius of 1 shows no curve so add 1 + qreal radius = cornerSize+1; + GetPainter()->drawRoundedRect(rect, radius, radius); + } else { + GetPainter()->fillRect(rect, brushFill); + } + } else { + const QColor qOutline = QColorFromColourAlpha(ColourAlpha(outline, alphaOutline)); + const QPen penOutline(qOutline); + GetPainter()->setPen(penOutline); + + const QRectF rect(rc.left, rc.top, rc.Width() - 1.5, rc.Height() - 1.5); + if (cornerSize > 0.0f) { + // A radius of 1 shows no curve so add 1 + qreal radius = cornerSize+1; + GetPainter()->drawRoundedRect(rect, radius, radius); + } else { + GetPainter()->drawRect(rect); + } + } } void SurfaceImpl::GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions options) { -- cgit v1.2.3