88 #include <QtCore/qdebug.h> 90 #ifndef QT_NO_ANIMATION 133 if (duration == -1 ||
currentTime < (ret.timeOffset + duration)
140 ret.timeOffset += duration;
146 ret.timeOffset -= duration;
300 if (index < 0 || index >
d->animations.size()) {
301 qWarning(
"QSequentialAnimationGroup::insertPause: index is out of bounds");
323 return d->currentAnimation;
334 for (
int i = 0; i <
d->animations.size(); ++i) {
337 if (currentDuration == -1)
340 ret += currentDuration;
352 if (!
d->currentAnimation)
358 while (newAnimationIndex.
index <
d->actualDuration.size())
359 d->actualDuration.removeLast();
362 if (
d->lastLoop <
d->currentLoop
363 || (
d->lastLoop ==
d->currentLoop &&
d->currentAnimationIndex < newAnimationIndex.
index)) {
365 d->advanceForwards(newAnimationIndex);
366 }
else if (
d->lastLoop >
d->currentLoop
367 || (
d->lastLoop ==
d->currentLoop &&
d->currentAnimationIndex > newAnimationIndex.
index)) {
369 d->rewindForwards(newAnimationIndex);
372 d->setCurrentAnimation(newAnimationIndex.
index);
374 const int newCurrentTime = currentTime - newAnimationIndex.
timeOffset;
376 if (
d->currentAnimation) {
377 d->currentAnimation->setCurrentTime(newCurrentTime);
391 d->lastLoop =
d->currentLoop;
403 if (!
d->currentAnimation)
408 d->currentAnimation->stop();
411 if (oldState ==
d->currentAnimation->state()
413 d->currentAnimation->pause();
419 if (oldState ==
d->currentAnimation->state()
421 d->currentAnimation->start();
436 d->currentAnimation->setDirection(direction);
451 index =
qMin(index, animations.count() - 1);
455 currentAnimationIndex = -1;
462 if (index == currentAnimationIndex && animations.at(index) ==
currentAnimation)
470 currentAnimationIndex =
index;
474 activateCurrentAnimation(intermediate);
502 while (actualDuration.size() < (currentAnimationIndex + 1))
503 actualDuration.append(-1);
514 setCurrentAnimation(currentAnimationIndex + 1);
517 setCurrentAnimation(currentAnimationIndex - 1);
533 setCurrentAnimation(0);
535 if (currentAnimationIndex == index
538 setCurrentAnimation(index);
544 if (index < currentAnimationIndex ||
currentLoop != 0) {
545 qWarning(
"QSequentialGroup::insertAnimation only supports to add animations after the current one.");
566 if (actualDuration.size() >
index)
567 actualDuration.removeAt(index);
570 if (currentIndex == -1) {
575 if (index < animations.count())
576 setCurrentAnimation(index);
578 setCurrentAnimation(index - 1);
580 setCurrentAnimation(-1);
581 }
else if (currentAnimationIndex > index) {
582 currentAnimationIndex--;
587 for (
int i = 0; i < currentAnimationIndex; ++i) {
588 const int current = animationActualTotalDuration(i);
592 if (currentIndex != -1) {
604 #include "moc_qsequentialanimationgroup.cpp" 606 #endif //QT_NO_ANIMATION
void advanceForwards(const AnimationIndex &newAnimationIndex)
This manages advancing the execution of a group running forwards (time has gone forward), which is the same behaviour for rewinding the execution of a group running backwards (time has gone backward).
void animationRemoved(int index, QAbstractAnimation *anim)
This method is called whenever an animation is removed from the group at index index.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
void updateCurrentTime(int)
Reimplemented Function
#define QT_END_NAMESPACE
This macro expands to.
int totalDuration() const
Returns the total and effective duration of the animation, including the loop count.
void insertAnimation(int index, QAbstractAnimation *animation)
Inserts animation into this animation group at index.
State
This enum describes the state of the animation.
The QSequentialAnimationGroup class provides a sequential group of animations.
The QPauseAnimation class provides a pause for QSequentialAnimationGroup.
static QAbstractAnimationPrivate * get(QAbstractAnimation *q)
void start(QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped)
Starts the animation.
int count(const T &t) const
Returns the number of occurrences of value in the list.
The QObject class is the base class of all Qt objects.
int animationActualTotalDuration(int index) const
QAbstractAnimation::Direction direction
void stop()
Stops the animation.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
QAbstractAnimation * currentAnimation
void updateDirection(QAbstractAnimation::Direction direction)
Reimplemented Function
#define QT_BEGIN_NAMESPACE
This macro expands to.
Direction
This enum describes the direction of the animation when in Running state.
void animationInsertedAt(int index)
This method is called whenever an animation is added to the group at index index. ...
void addAnimation(QAbstractAnimation *animation)
Adds animation to this group.
QList< int > actualDuration
const T & at(int i) const
Returns the item at index position i in the list.
void setDirection(Direction direction)
Q_CORE_EXPORT void qWarning(const char *,...)
int duration() const
Reimplemented Function
QList< QAbstractAnimation * > animations
void _q_uncontrolledAnimationFinished()
The QAbstractAnimation class is the base of all animations.
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
Reimplemented Function
bool event(QEvent *event)
Reimplemented Function
bool event(QEvent *event)
Reimplemented Function
virtual void animationRemoved(int, QAbstractAnimation *)
AnimationIndex indexForCurrentTime() const
int currentLoop
the current loop of the animation
void activateCurrentAnimation(bool intermediate=false)
QObject * parent() const
Returns a pointer to the parent object.
T & last()
Returns a reference to the last item in the list.
int currentTime
the current time and progress of the animation
int size() const
Returns the number of items in the list.
virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
This virtual function is called by QAbstractAnimation when the state of the animation is changed from...
void pause()
Pauses the animation.
~QSequentialAnimationGroup()
Destroys the animation group.
QSequentialAnimationGroup(QObject *parent=0)
Constructs a QSequentialAnimationGroup.
void rewindForwards(const AnimationIndex &newAnimationIndex)
This manages rewinding the execution of a group running forwards (time has gone forward), which is the same behaviour for advancing the execution of a group running backwards (time has gone backward).
int currentAnimationIndex
Direction direction() const
QAbstractAnimation * currentAnimation() const
QPauseAnimation * addPause(int msecs)
Adds a pause of msecs to this animation group.
The QAnimationGroup class is an abstract base class for groups of animations.
The QEvent class is the base class of all event classes.
void setCurrentTime(int msecs)
QPauseAnimation * insertPause(int index, int msecs)
Inserts a pause of msecs milliseconds at index in this animation group.
void setCurrentAnimation(int index, bool intermediate=false)