diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2009-11-24 10:38:57 (GMT) |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2009-11-26 11:22:19 (GMT) |
commit | a78e7a6e7a7d5725467d0538bf8e0ea50c2506cc (patch) | |
tree | a5e3c67440116ccb07e39d550631e758a435d338 /src/gui/widgets | |
parent | f1ae6d0ecba250d83cf7e747868af32ceadc085f (diff) | |
download | Qt-a78e7a6e7a7d5725467d0538bf8e0ea50c2506cc.zip Qt-a78e7a6e7a7d5725467d0538bf8e0ea50c2506cc.tar.gz Qt-a78e7a6e7a7d5725467d0538bf8e0ea50c2506cc.tar.bz2 |
Improved and optimized the WaveUnderline
The WaveUnderline used to be a series of 180 degree arcs, that didn't
always align very well between different text items and that could be
clipped at the bottom since the font height got reduced. Now it uses
quad beziers so that it is more like a sinus curve, and the alignment
and clipping issues have been fixed.
The painting of the WaveUnderline has been optimized using QPixmapCache.
A 100 pixels wide sample of the wave is now cached as a pixmap and
repeated to draw the WaveUnderline. This is an order of magnitude faster
than rasterizing a QPainterPath.
The QPlainTextEdit needs to set the brush origin since it draws the text
items in local widget coordinates, rather than relying on a painter
translation like the QTextEdit.
Done with mae.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qplaintextedit.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index c7759e8..eae8b7d 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -1802,6 +1802,9 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e) QTextBlock block = firstVisibleBlock(); qreal maximumWidth = document()->documentLayout()->documentSize().width(); + // Set a brush origin so that the WaveUnderline knows where the wave started + painter.setBrushOrigin(offset); + // keep right margin clean from full-width selection int maxX = offset.x() + qMax((qreal)viewportRect.width(), maximumWidth) - document()->documentMargin(); |