From 0125a8f6795add229573ec97faf3eb83e84c4dea Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Fri, 18 Sep 2009 19:17:31 -0400 Subject: [PATCH] Using private class data members to keep track animation parameters. --- kineticview.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/kineticview.cpp b/kineticview.cpp index f13a35a..67e6045 100644 --- a/kineticview.cpp +++ b/kineticview.cpp @@ -191,6 +191,14 @@ void KineticView::setWidget(QGraphicsWidget *item) void KineticView::overshoot() { qDebug() << "animation is over..."; + /* Detect if bouncer */ + if (d->cposition > 0) { + qDebug() << "UP"; + + } else if ((d->cposition - d->overshoot) > d->minimalPos) { + qDebug() << "DOWN"; + } + } void KineticView::setVerticalScrollValue(int value) @@ -201,13 +209,13 @@ void KineticView::setVerticalScrollValue(int value) int KineticView::thresholdPosition(int value) { - int minimalPos = -d->widget->size().height() + d->scrollingWidget->size().height(); - minimalPos = qMin( 0, minimalPos); - int maximumPos = value; + d->minimalPos = -d->widget->size().height() + d->scrollingWidget->size().height(); + d->minimalPos = qMin(0, d->minimalPos); + d->maximumPos = value; - int cposition = qBound( minimalPos, maximumPos, 0); + d->cposition = qBound(d->minimalPos, d->maximumPos, 0); - return cposition; + return d->cposition; } void KineticView::resetAnimation(int duration) @@ -216,11 +224,12 @@ void KineticView::resetAnimation(int duration) scrollAnimation->stop(); QRectF tmpGeometry = d->widget->geometry(); scrollAnimation->setStartValue(tmpGeometry); - int position = thresholdPosition(tmpGeometry.y() - d->kinMovement()*6); - tmpGeometry.setY(position); + d->cposition = thresholdPosition(tmpGeometry.y() - d->kinMovement()*6); + tmpGeometry.setY(d->cposition); scrollAnimation->setEndValue(tmpGeometry); scrollAnimation->setDuration(duration); scrollAnimation->start(); + } -- 2.11.4.GIT