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>
This commit is contained in:
parent
d64f078173
commit
9692534de6
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user