fix up the rest of the math here, now anims are appropriately smooth according to the AnimationDriver settings

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=862832
This commit is contained in:
Aaron J. Seigo 2008-09-20 01:02:20 +00:00
parent ae3986568f
commit 88ac98fdb0

View File

@ -290,8 +290,8 @@ int Animator::animateItem(QGraphicsItem* item, Animation animation)
//TODO: variance in times based on the value of animation //TODO: variance in times based on the value of animation
state->frames = frames / 3; state->frames = frames / 3;
state->currentFrame = 0; state->currentFrame = 0;
state->interval = d->driver->animationDuration(animation) / state->frames; state->interval = d->driver->animationDuration(animation) / qreal(state->frames);
state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE; state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT));
state->currentInterval = state->interval; state->currentInterval = state->interval;
state->qobj = dynamic_cast<QObject*>(item); state->qobj = dynamic_cast<QObject*>(item);
@ -339,7 +339,7 @@ int Animator::moveItem(QGraphicsItem* item, Movement movement, const QPoint &des
int duration = d->driver->movementAnimationDuration(movement); int duration = d->driver->movementAnimationDuration(movement);
state->frames = (duration / 1000.0) * frames; state->frames = (duration / 1000.0) * frames;
state->currentFrame = 0; state->currentFrame = 0;
state->interval = duration / state->frames; state->interval = duration / qreal(state->frames);
state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT)); state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT));
// state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE; // state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE;
// kDebug() << "interval of" << state->interval << state->frames << duration << frames; // kDebug() << "interval of" << state->interval << state->frames << duration << frames;
@ -375,8 +375,7 @@ int Animator::customAnimation(int frames, int duration, Animator::CurveShape cur
state->currentFrame = 0; state->currentFrame = 0;
state->curve = curve; state->curve = curve;
state->interval = duration / qreal(state->frames); state->interval = duration / qreal(state->frames);
state->interval = qMax( 1, state->interval ); state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT));
state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE;
state->currentInterval = state->interval; state->currentInterval = state->interval;
state->receiver = receiver; state->receiver = receiver;
state->slot = qstrdup(slot); state->slot = qstrdup(slot);
@ -449,8 +448,8 @@ int Animator::animateElement(QGraphicsItem *item, Animation animation)
//TODO: variance in times based on the value of animation //TODO: variance in times based on the value of animation
state->frames = d->driver->elementAnimationFps(animation) / 5; state->frames = d->driver->elementAnimationFps(animation) / 5;
state->currentFrame = 0; state->currentFrame = 0;
state->interval = d->driver->elementAnimationDuration(animation) / state->frames; state->interval = d->driver->elementAnimationDuration(animation) / qreal(state->frames);
state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE; state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT));
state->currentInterval = state->interval; state->currentInterval = state->interval;
state->id = ++d->animId; state->id = ++d->animId;
state->qobj = dynamic_cast<QObject*>(item); state->qobj = dynamic_cast<QObject*>(item);