mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: set alignment and scale of DiveTextItem at construction
Alignment and scale of DiveTextItems are never changed. Therefore, pass them at construction time. This makes things much easier if we want to cache the rendered text [currently the text is rerendered at every paint() event]. This also removes the "parent=0" default parameter of the constructor, because inadvertently leaving out the last argument led to a subtle bug. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5540471ce4
commit
2ebe6e3684
7 changed files with 39 additions and 57 deletions
|
@ -8,12 +8,12 @@
|
|||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
DiveTextItem::DiveTextItem(double dpr, QGraphicsItem *parent) : QGraphicsItemGroup(parent),
|
||||
internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter),
|
||||
DiveTextItem::DiveTextItem(double dpr, double scale, int alignFlags, QGraphicsItem *parent) : QGraphicsItemGroup(parent),
|
||||
internalAlignFlags(alignFlags),
|
||||
textBackgroundItem(new QGraphicsPathItem(this)),
|
||||
textItem(new QGraphicsPathItem(this)),
|
||||
dpr(dpr),
|
||||
scale(1.0)
|
||||
scale(scale)
|
||||
{
|
||||
setFlag(ItemIgnoresTransformations);
|
||||
textBackgroundItem->setBrush(QBrush(getColor(TEXT_BACKGROUND)));
|
||||
|
@ -27,25 +27,11 @@ void DiveTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||
QGraphicsItemGroup::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
void DiveTextItem::setAlignment(int alignFlags)
|
||||
{
|
||||
if (alignFlags != internalAlignFlags) {
|
||||
internalAlignFlags = alignFlags;
|
||||
}
|
||||
}
|
||||
|
||||
void DiveTextItem::setBrush(const QBrush &b)
|
||||
{
|
||||
textItem->setBrush(b);
|
||||
}
|
||||
|
||||
void DiveTextItem::setScale(double newscale)
|
||||
{
|
||||
if (scale != newscale) {
|
||||
scale = newscale;
|
||||
}
|
||||
}
|
||||
|
||||
void DiveTextItem::setText(const QString &t)
|
||||
{
|
||||
if (internalText != t) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue