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
|
@ -198,18 +198,17 @@ void DiveCartesianAxis::updateTicks(int animSpeed, color_index_t color)
|
|||
} else {
|
||||
childPos = begin - i * stepSize;
|
||||
}
|
||||
DiveTextItem *label = new DiveTextItem(dpr, this);
|
||||
int alignFlags = orientation == RightToLeft || orientation == LeftToRight ? Qt::AlignBottom | Qt::AlignHCenter :
|
||||
Qt::AlignVCenter | Qt::AlignLeft;
|
||||
DiveTextItem *label = new DiveTextItem(dpr, labelScale, alignFlags, this);
|
||||
label->setText(textForValue(currValueText));
|
||||
label->setBrush(colorForValue(currValueText));
|
||||
label->setScale(labelScale);
|
||||
label->setZValue(1);
|
||||
labels.push_back(label);
|
||||
if (orientation == RightToLeft || orientation == LeftToRight) {
|
||||
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
||||
label->setPos(scene.sceneRect().width() + 10, m.y1() + tick_size); // position it outside of the scene;
|
||||
Animations::moveTo(label, animSpeed,childPos , m.y1() + tick_size);
|
||||
} else {
|
||||
label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
||||
label->setPos(m.x1() - tick_size, scene.sceneRect().height() + 10);
|
||||
Animations::moveTo(label, animSpeed, m.x1() - tick_size, childPos);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue