animation in blockview 2

git-svn-id: svn://db.shs.com.ru/libs@317 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
2017-11-15 16:17:21 +00:00
parent ed362a6b55
commit d962dcb0f2
4 changed files with 37 additions and 16 deletions

View File

@@ -21,7 +21,7 @@ BlockItemPin::BlockItemPin(Qt::Alignment a, int bus_type_, const QString & text_
anim_accept.setTargetObject(this);
anim_accept.setPropertyName("pinSize");
anim_accept.setEasingCurve(QEasingCurve::InOutQuad);
anim_accept.setDuration(200);
anim_accept.setDuration(150);
connect(&anim_accept, SIGNAL(finished()), this, SLOT(animationAccept()));
setState(Disconnected);
setAlignment(a);
@@ -33,14 +33,20 @@ BlockItemPin::BlockItemPin(Qt::Alignment a, int bus_type_, const QString & text_
}
void BlockItemPin::animAccept() {
if (!((BlockView *)scene()->views().back())->isBlockAnimationEnabled() && anim_accept.state() != QAbstractAnimation::Running) return;
anim_accept.setStartValue(pinSize());
anim_accept.setEndValue(10.);
anim_accept.start();
}
void BlockItemPin::setState(State s) {
State os = state_;
state_ = s;
setBrush(br[int(state_)]);
if (s == Accept && os != Accept && anim_accept.state() != QAbstractAnimation::Running && ((BlockView *)scene()->views().back())->isBlockAnimationEnabled()) {
anim_accept.setStartValue(pinSize());
anim_accept.setEndValue(10.);
anim_accept.start();
if (s == Accept && os != Accept) {
animAccept();
}
update();
}
@@ -93,10 +99,10 @@ void BlockItemPin::_init(bool affect_parent) {
text_item.setPos(0, -tbr.height() / 2.);
text_item.setTransformOriginPoint(0, tbr.height() / 2.);
switch (align) {
case Qt::AlignBottom: ell_item.setStartAngle(16*0); text_item.setRotation(-90.); text_item.moveBy(0, -r * 1.5); break;
case Qt::AlignRight: ell_item.setStartAngle(16*90); text_item.setRotation(0.); text_item.moveBy(-tbr.width() - r * 1.5, 0); break;
case Qt::AlignTop: ell_item.setStartAngle(16*180); text_item.setRotation(-90.); text_item.moveBy(0, tbr.width() + r * 1.5); break;
case Qt::AlignLeft: ell_item.setStartAngle(16*270); text_item.setRotation(0.); text_item.moveBy(r * 1.5, 0); break;
case Qt::AlignBottom: ell_item.setStartAngle(16*0); text_item.setRotation(-90.); text_item.moveBy(0, -r * 1.5); break;
case Qt::AlignRight: ell_item.setStartAngle(16*90); text_item.setRotation(0.); text_item.moveBy(-tbr.width() - r * 1.5, 0); break;
case Qt::AlignTop: ell_item.setStartAngle(16*180); text_item.setRotation(-90.); text_item.moveBy(0, tbr.width() + r * 1.5); break;
case Qt::AlignLeft: ell_item.setStartAngle(16*270); text_item.setRotation(0.); text_item.moveBy(r * 1.5, 0); break;
default: break;
}
if (affect_parent && parent_)