diff options
author | sauimone <samu.uimonen@digia.com> | 2012-08-28 16:37:12 +0300 |
---|---|---|
committer | sauimone <samu.uimonen@digia.com> | 2012-08-28 16:37:34 +0300 |
commit | e322c54e4b32b5c4387b43ba4666252204753cd8 (patch) | |
tree | 1253bca770c2a6b598cdc1ab813f317111c36edd /src | |
parent | feba2e518e2c666c33d4162d024ce9cacd53e61c (diff) |
correct interpolation for baranimation
Diffstat (limited to 'src')
-rw-r--r-- | src/animations/baranimation.cpp | 20 | ||||
-rw-r--r-- | src/animations/horizontalbaranimation.cpp | 20 |
2 files changed, 32 insertions, 8 deletions
diff --git a/src/animations/baranimation.cpp b/src/animations/baranimation.cpp index a16a26d8..8dc40565 100644 --- a/src/animations/baranimation.cpp +++ b/src/animations/baranimation.cpp @@ -45,10 +45,22 @@ QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qr Q_ASSERT(startVector.count() == endVector.count()); for(int i = 0; i < startVector.count(); i++) { - qreal w = endVector[i].width(); - qreal h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress); - qreal x = endVector[i].topLeft().x(); - qreal y = endVector[i].topLeft().y() + endVector[i].height() - h; + QRectF start = startVector[i].normalized(); + QRectF end = endVector[i].normalized(); + + qreal x = end.left(); + qreal y; + qreal w = end.width(); + qreal h; + + if (endVector[i].height() < 0) { + // Negative bar + y = end.top(); + h = start.height() + ((end.height() - start.height()) * progress); + } else { + h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress); + y = endVector[i].top() + endVector[i].height() - h; + } QRectF value(x,y,w,h); result << value.normalized(); diff --git a/src/animations/horizontalbaranimation.cpp b/src/animations/horizontalbaranimation.cpp index eda9e052..d03802a8 100644 --- a/src/animations/horizontalbaranimation.cpp +++ b/src/animations/horizontalbaranimation.cpp @@ -46,10 +46,22 @@ QVariant HorizontalBarAnimation::interpolated(const QVariant &from, const QVaria Q_ASSERT(startVector.count() == endVector.count()); for(int i = 0; i < startVector.count(); i++) { - qreal h = endVector[i].height(); - qreal w = startVector[i].width() + ((endVector[i].width() - startVector[i].width()) * progress); - qreal x = endVector[i].left(); - qreal y = endVector[i].top(); + QRectF start = startVector[i].normalized(); + QRectF end = endVector[i].normalized(); + + qreal x; + qreal y = end.top(); + qreal w; + qreal h = end.height(); + + if (endVector[i].width() < 0) { + // Negative bar + w = start.width() + ((end.width() - start.width()) * progress); + x = endVector[i].right() - endVector[i].width() - w; + } else { + w = startVector[i].width() + ((endVector[i].width() - startVector[i].width()) * progress); + x = end.left(); + } QRectF value(x,y,w,h); result << value.normalized(); |