diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2014-03-25 23:34:08 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-03-27 10:58:22 -0700 |
commit | ac23d7397f9303c2cff6479458342fe47498ac1b (patch) | |
tree | fb0a79bca20ced37e0ec6927ab35b329141e5270 /qt-ui/profile/ruleritem.cpp | |
parent | 69b000dcfff1fc51b1ee8a2d6b86eb9116205b03 (diff) | |
download | subsurface-ac23d7397f9303c2cff6479458342fe47498ac1b.tar.gz |
Ruler: fix bad scaling for the text background
The ruler text's white background scales badly. This patch
adds the ItemIgnoresTransformations for the textItemBack
object and matches the dimensions and position of the
textItem object in front of it.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/ruleritem.cpp')
-rw-r--r-- | qt-ui/profile/ruleritem.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index 5d2b5277b..768d912e9 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -77,6 +77,7 @@ RulerItem2::RulerItem2() : source(new RulerNodeItem2()), textItem->setFlag(QGraphicsItem::ItemIgnoresTransformations); textItemBack->setBrush(QColor(0xff, 0xff, 0xff, 190)); textItemBack->setPen(QColor(Qt::white)); + textItemBack->setFlag(QGraphicsItem::ItemIgnoresTransformations); setPen(QPen(QColor(Qt::black), 0.0)); } @@ -117,13 +118,13 @@ void RulerItem2::recalculate() } // always show the text bellow the lowest of the start and end points qreal tgtY = (startPoint.y() >= endPoint.y()) ? startPoint.y() : endPoint.y(); - textItem->setPos(tgtX - 1, tgtY + 4); + // this isn't exactly optimal, since we want to scale the 1.0, 4.0 distances as well + textItem->setPos(tgtX - 1.0, tgtY + 4.0); // setup the text background textItemBack->setVisible(startPoint.x() != endPoint.x()); - QPointF wh = mapFromScene(view->mapToScene(QPoint(textItem->boundingRect().width(), - textItem->boundingRect().height()))); - textItemBack->setRect(tgtX - 2, tgtY + 3, wh.x() + 2, wh.y() + 3); + textItemBack->setPos(textItem->x(), textItem->y()); + textItemBack->setRect(0, 0, textItem->boundingRect().width(), textItem->boundingRect().height()); } RulerNodeItem2 *RulerItem2::sourceNode() const |