1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSEQUENTIALANIMATIONGROUPJOB_P_H
5#define QSEQUENTIALANIMATIONGROUPJOB_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qanimationgroupjob_p.h>
19
20QT_REQUIRE_CONFIG(qml_animation);
21
22QT_BEGIN_NAMESPACE
23
24class QPauseAnimationJob;
25class Q_QML_PRIVATE_EXPORT QSequentialAnimationGroupJob : public QAnimationGroupJob
26{
27 Q_DISABLE_COPY(QSequentialAnimationGroupJob)
28public:
29 QSequentialAnimationGroupJob();
30 ~QSequentialAnimationGroupJob();
31
32 int duration() const override;
33
34 QAbstractAnimationJob *currentAnimation() const { return m_currentAnimation; }
35 void clear() override;
36
37protected:
38 void updateCurrentTime(int) override;
39 void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
40 void updateDirection(QAbstractAnimationJob::Direction direction) override;
41 void uncontrolledAnimationFinished(QAbstractAnimationJob *animation) override;
42 void debugAnimation(QDebug d) const override;
43
44private:
45 struct AnimationIndex
46 {
47 AnimationIndex() {}
48 // AnimationIndex points to the animation at timeOffset, skipping 0 duration animations.
49 // Note that the index semantic is slightly different depending on the direction.
50 bool afterCurrent = false; //whether animation is before or after m_currentAnimation //TODO: make enum Before/After/Same
51 int timeOffset = 0; // time offset when the animation at index starts.
52 const QAbstractAnimationJob *animation = nullptr; //points to the animation at timeOffset
53 };
54
55 int animationActualTotalDuration(const QAbstractAnimationJob *anim) const;
56 AnimationIndex indexForCurrentTime() const;
57
58 void setCurrentAnimation(const QAbstractAnimationJob *anim, bool intermediate = false);
59 void activateCurrentAnimation(bool intermediate = false);
60
61 void animationInserted(QAbstractAnimationJob *anim) override;
62 void animationRemoved(QAbstractAnimationJob *anim, QAbstractAnimationJob *, QAbstractAnimationJob *) override;
63
64 bool atEnd() const;
65
66 void restart();
67
68 // handle time changes
69 void rewindForwards(const AnimationIndex &newAnimationIndex);
70 void advanceForwards(const AnimationIndex &newAnimationIndex);
71
72 //state
73 QAbstractAnimationJob *m_currentAnimation = nullptr;
74 int m_previousLoop = 0;
75};
76
77QT_END_NAMESPACE
78
79#endif //QSEQUENTIALANIMATIONGROUPJOB_P_H
80

source code of qtdeclarative/src/qml/animations/qsequentialanimationgroupjob_p.h