diff options
author | Dmitry Shachnev <mitya57@gmail.com> | 2016-02-08 10:43:21 +0300 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2016-03-16 23:34:02 +0000 |
commit | 9692534de65df78489c356ecc4f1d4161b8615e2 (patch) | |
tree | 6413a1b79336397106746962344a50d27ee0ab12 /src/gui/text/qtextlayout.cpp | |
parent | d64f0781738519add9e3c3eb7a92c7dae5f8470c (diff) |
QTextCursor: Use RasterOp_NotDestination composition mode for drawing the cursor
This has several advantages over the current “fill the rectangle with the
default text color” approach:
- When the background color for some block of text is black, the cursor will be
white and visible.
- It is possible to set the cursor width to width of a character (for example
for monospace edits), and the characters will be visible when the cursor is
displayed.
Change-Id: I2e6303166d5d63c8dd11ec4fcf3d734cdf440e7e
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 5778e1818b..e2939785b2 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1326,7 +1326,11 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition && (p->transform().type() > QTransform::TxTranslate); if (toggleAntialiasing) p->setRenderHint(QPainter::Antialiasing); + QPainter::CompositionMode origCompositionMode = p->compositionMode(); + if (p->paintEngine()->hasFeature(QPaintEngine::RasterOpModes)) + p->setCompositionMode(QPainter::RasterOp_NotDestination); p->fillRect(QRectF(x, y, qreal(width), (base + descent).toReal()), p->pen().brush()); + p->setCompositionMode(origCompositionMode); if (toggleAntialiasing) p->setRenderHint(QPainter::Antialiasing, false); if (d->layoutData->hasBidi) { |