##// END OF EJS Templates
correct interpolation for baranimation
sauimone -
r1879:e322c54e4b32
parent child
Show More
@@ -45,10 +45,22 QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qr
45 Q_ASSERT(startVector.count() == endVector.count());
45 Q_ASSERT(startVector.count() == endVector.count());
46
46
47 for(int i = 0; i < startVector.count(); i++) {
47 for(int i = 0; i < startVector.count(); i++) {
48 qreal w = endVector[i].width();
48 QRectF start = startVector[i].normalized();
49 qreal h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress);
49 QRectF end = endVector[i].normalized();
50 qreal x = endVector[i].topLeft().x();
50
51 qreal y = endVector[i].topLeft().y() + endVector[i].height() - h;
51 qreal x = end.left();
52 qreal y;
53 qreal w = end.width();
54 qreal h;
55
56 if (endVector[i].height() < 0) {
57 // Negative bar
58 y = end.top();
59 h = start.height() + ((end.height() - start.height()) * progress);
60 } else {
61 h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress);
62 y = endVector[i].top() + endVector[i].height() - h;
63 }
52
64
53 QRectF value(x,y,w,h);
65 QRectF value(x,y,w,h);
54 result << value.normalized();
66 result << value.normalized();
@@ -46,10 +46,22 QVariant HorizontalBarAnimation::interpolated(const QVariant &from, const QVaria
46 Q_ASSERT(startVector.count() == endVector.count());
46 Q_ASSERT(startVector.count() == endVector.count());
47
47
48 for(int i = 0; i < startVector.count(); i++) {
48 for(int i = 0; i < startVector.count(); i++) {
49 qreal h = endVector[i].height();
49 QRectF start = startVector[i].normalized();
50 qreal w = startVector[i].width() + ((endVector[i].width() - startVector[i].width()) * progress);
50 QRectF end = endVector[i].normalized();
51 qreal x = endVector[i].left();
51
52 qreal y = endVector[i].top();
52 qreal x;
53 qreal y = end.top();
54 qreal w;
55 qreal h = end.height();
56
57 if (endVector[i].width() < 0) {
58 // Negative bar
59 w = start.width() + ((end.width() - start.width()) * progress);
60 x = endVector[i].right() - endVector[i].width() - w;
61 } else {
62 w = startVector[i].width() + ((endVector[i].width() - startVector[i].width()) * progress);
63 x = end.left();
64 }
53
65
54 QRectF value(x,y,w,h);
66 QRectF value(x,y,w,h);
55 result << value.normalized();
67 result << value.normalized();
General Comments 0
You need to be logged in to leave comments. Login now