From 216fca2d218c3e0dcb5cdb4273cfb609da06cbd2 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 19 Mar 2021 21:03:17 +1100 Subject: Support strokeWidth and float cornerSize in AlphaRectangle. Use FillStroke instead of separate colour and alpha arguments. --- qt/ScintillaEditBase/PlatQt.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'qt/ScintillaEditBase/PlatQt.cpp') diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index 37fc409f7..a8553e658 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -390,6 +390,38 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, } } +void SurfaceImpl::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) +{ + QColor qFill = QColorFromColourAlpha(fillStroke.fill.colour); + QBrush brushFill(qFill); + GetPainter()->setBrush(brushFill); + if (fillStroke.fill.colour == fillStroke.stroke.colour) { + painter->setPen(Qt::NoPen); + 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 { + QColor qOutline = QColorFromColourAlpha(fillStroke.stroke.colour); + QPen penOutline(qOutline); + penOutline.setWidthF(fillStroke.stroke.width); + GetPainter()->setPen(penOutline); + + QRectF rect = QRectFFromPRect(rc.Inset(fillStroke.stroke.width / 2)); + 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) { QRectF rect = QRectFFromPRect(rc); QLinearGradient linearGradient; -- cgit v1.2.3