summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-06-28 16:36:16 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-29 04:24:06 +0800
commit44c33742c26dcf9387b5c837c161e33ddc5eb060 (patch)
treea8931e9a472edef4dd651ea936e52d94d5761076 /qt-ui
parent48cf2fd6bc512892de01bbb4261efbc0ce54560d (diff)
downloadsubsurface-44c33742c26dcf9387b5c837c161e33ddc5eb060.tar.gz
Profile: add white outline to all text
Goal: no blending between profile text and graph lines Qt doesn't seem to provide an easy-to-go solution in terms of styling the z-order of the pen and brush layers of a QAbstractGraphicsShapeItem (or alternatively pen offset), which is needed if for example one likes the pen not to cover the text fill. Calling QGraphicsSimpleTextItem->setPen() on small text can cover bigger portions of the text, as the pen ends on top of the fill and given the pen stroke path ends up scaling exactly at the fill path border but not on the outside, for example. Since we don't get quick control over that (and to avoid the issue in a naive way), we set the text as bold and the white outline lands over the "bold-ed" area of glyphs. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profilegraphics.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index cb69bc1ba..f04d2d1fc 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -1135,16 +1135,20 @@ void ProfileGraphicsView::plot_depth_profile()
QGraphicsSimpleTextItem *ProfileGraphicsView::plot_text(text_render_options_t *tro,const QPointF& pos, const QString& text, QGraphicsItem *parent)
{
- QFontMetrics fm(font());
+ QFont fnt(font());
+ fnt.setBold(true);
+ QFontMetrics fm(fnt);
double dx = tro->hpos * (fm.width(text));
double dy = tro->vpos * (fm.height());
QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(text, parent);
+ item->setFont(fnt);
QPointF point(SCALEGC(pos.x(), pos.y())); // This is neded because of the SCALE macro.
item->setPos(point.x() + dx, point.y() + dy);
item->setBrush(QBrush(profile_color[tro->color].first()));
+ item->setPen(QPen(profile_color[TEXT_BACKGROUND].first()));
item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
if (!parent)