mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Remove the plotText function, standardize with the TextItem.
Removed the plotText function and replaced it with the DiveTextItem class - this way there's just one way to add text on screen, and it also makes it easy to fix positioning of stuff there. Which is what I'll try to fix on the next commit. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6a58712270
commit
72b5bbce6e
3 changed files with 67 additions and 53 deletions
|
|
@ -220,32 +220,5 @@ void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte
|
|||
|
||||
QGraphicsItemGroup *plotText(text_render_options_t* tro, const QPointF& pos, const QString& text, QGraphicsItem *parent)
|
||||
{
|
||||
QFont fnt(qApp->font());
|
||||
QFontMetrics fm(fnt);
|
||||
|
||||
/*
|
||||
if (printMode)
|
||||
fnt.setPixelSize(tro->size);
|
||||
*/
|
||||
|
||||
QGraphicsItemGroup *group = new QGraphicsItemGroup(parent);
|
||||
QPainterPath textPath;
|
||||
/* addText() uses bottom-left text baseline and the -3 offset is probably slightly off
|
||||
* for different font sizes. */
|
||||
textPath.addText(0, fm.height() - 3, fnt, text);
|
||||
QPainterPathStroker stroker;
|
||||
stroker.setWidth(3);
|
||||
QGraphicsPathItem *strokedItem = new QGraphicsPathItem(stroker.createStroke(textPath), group);
|
||||
strokedItem->setBrush(QBrush(getColor(TEXT_BACKGROUND)));
|
||||
strokedItem->setPen(Qt::NoPen);
|
||||
|
||||
QGraphicsPathItem *textItem = new QGraphicsPathItem(textPath, group);
|
||||
textItem->setBrush(QBrush(getColor(tro->color)));
|
||||
textItem->setPen(Qt::NoPen);
|
||||
|
||||
group->setPos(pos);
|
||||
//group->setPos(pos.x() + dx, pos.y() + dy);
|
||||
// if (!printMode)
|
||||
group->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||
return group;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue