aboutsummaryrefslogtreecommitdiffhomepage
path: root/qt
diff options
context:
space:
mode:
Diffstat (limited to 'qt')
-rw-r--r--qt/ScintillaEditBase/PlatQt.cpp20
-rw-r--r--qt/ScintillaEditBase/PlatQt.h6
2 files changed, 26 insertions, 0 deletions
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp
index 26890e4b7..1f4c3fb05 100644
--- a/qt/ScintillaEditBase/PlatQt.cpp
+++ b/qt/ScintillaEditBase/PlatQt.cpp
@@ -349,6 +349,26 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc,
GetPainter()->drawRoundedRect(rect, radius, radius);
}
+void SurfaceImpl::GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) {
+ QRectF rect = QRectFFromPRect(rc);
+ QLinearGradient linearGradient;
+ switch (options) {
+ case GradientOptions::leftToRight:
+ linearGradient = QLinearGradient(rc.left, rc.top, rc.right, rc.top);
+ break;
+ case GradientOptions::topToBottom:
+ default:
+ linearGradient = QLinearGradient(rc.left, rc.top, rc.left, rc.bottom);
+ break;
+ }
+ linearGradient.setSpread(QGradient::RepeatSpread);
+ for (const ColourStop &stop : stops) {
+ linearGradient.setColorAt(stop.position, QColorFromColourAlpha(stop.colour));
+ }
+ QBrush brush = QBrush(linearGradient);
+ GetPainter()->fillRect(rect, brush);
+}
+
static std::vector<unsigned char> ImageByteSwapped(int width, int height, const unsigned char *pixelsImage)
{
// Input is RGBA, but Format_ARGB32 is BGRA, so swap the red bytes and blue bytes
diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h
index ed51cf598..345538bb0 100644
--- a/qt/ScintillaEditBase/PlatQt.h
+++ b/qt/ScintillaEditBase/PlatQt.h
@@ -32,6 +32,11 @@ inline QColor QColorFromCA(ColourDesired ca)
return QColor(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
}
+inline QColor QColorFromColourAlpha(ColourAlpha ca)
+{
+ return QColor(ca.GetRed(), ca.GetGreen(), ca.GetBlue(), ca.GetAlpha());
+}
+
inline QRect QRectFromPRect(PRectangle pr)
{
return QRect(pr.left, pr.top, pr.Width(), pr.Height());
@@ -92,6 +97,7 @@ public:
ColourDesired back) override;
void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill,
int alphaFill, ColourDesired outline, int alphaOutline, int flags) override;
+ void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) override;
void DrawRGBAImage(PRectangle rc, int width, int height,
const unsigned char *pixelsImage) override;
void Ellipse(PRectangle rc, ColourDesired fore,