* fix div-by-zero

* based frame count on the animation duration

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=863639
This commit is contained in:
Aaron J. Seigo 2008-09-22 18:34:58 +00:00
parent 56a9ad52ce
commit a680170b8f

View File

@ -282,13 +282,14 @@ int Animator::animateItem(QGraphicsItem* item, Animation animation)
return -1; return -1;
} }
int duration = d->driver->animationDuration(animation);
AnimationState* state = new AnimationState; AnimationState* state = new AnimationState;
state->id = ++d->animId; state->id = ++d->animId;
state->item = item; state->item = item;
state->animation = animation; state->animation = animation;
state->curve = d->driver->animationCurve(animation); state->curve = d->driver->animationCurve(animation);
//TODO: variance in times based on the value of animation state->frames = qMax(1.0, frames * (duration / 1000.0));
state->frames = frames / 3;
state->currentFrame = 0; state->currentFrame = 0;
state->interval = d->driver->animationDuration(animation) / qreal(state->frames); state->interval = d->driver->animationDuration(animation) / 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));
@ -337,7 +338,7 @@ int Animator::moveItem(QGraphicsItem* item, Movement movement, const QPoint &des
state->curve = d->driver->movementAnimationCurve(movement); state->curve = d->driver->movementAnimationCurve(movement);
//TODO: variance in times based on the value of animation //TODO: variance in times based on the value of animation
int duration = d->driver->movementAnimationDuration(movement); int duration = d->driver->movementAnimationDuration(movement);
state->frames = (duration / 1000.0) * frames; state->frames = qMax(1.0, frames * (duration / 1000.0));
state->currentFrame = 0; state->currentFrame = 0;
state->interval = duration / qreal(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));
@ -441,14 +442,16 @@ void Animator::stopItemMovement(int id)
int Animator::animateElement(QGraphicsItem *item, Animation animation) int Animator::animateElement(QGraphicsItem *item, Animation animation)
{ {
//kDebug() << "startElementAnimation(AnimId " << animation << ")"; //kDebug() << "startElementAnimation(AnimId " << animation << ")";
int frames = d->driver->elementAnimationFps(animation);
int duration = d->driver->animationDuration(animation);
ElementAnimationState *state = new ElementAnimationState; ElementAnimationState *state = new ElementAnimationState;
state->item = item; state->item = item;
state->curve = d->driver->elementAnimationCurve(animation); state->curve = d->driver->elementAnimationCurve(animation);
state->animation = animation; state->animation = animation;
//TODO: variance in times based on the value of animation state->frames = qMax(1.0, frames * (duration / 1000.0));
state->frames = d->driver->elementAnimationFps(animation) / 5;
state->currentFrame = 0; state->currentFrame = 0;
state->interval = d->driver->elementAnimationDuration(animation) / qreal(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->currentInterval = state->interval; state->currentInterval = state->interval;
state->id = ++d->animId; state->id = ++d->animId;