| 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 QSEQUENTIALANIMATIONGROUP_P_H |
| 5 | #define QSEQUENTIALANIMATIONGROUP_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 "qsequentialanimationgroup.h" |
| 19 | #include "private/qanimationgroup_p.h" |
| 20 | #include "private/qproperty_p.h" |
| 21 | |
| 22 | QT_REQUIRE_CONFIG(animation); |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | class QSequentialAnimationGroupPrivate : public QAnimationGroupPrivate |
| 27 | { |
| 28 | Q_DECLARE_PUBLIC(QSequentialAnimationGroup) |
| 29 | public: |
| 30 | QSequentialAnimationGroupPrivate() : currentAnimationIndex(-1), lastLoop(0) { } |
| 31 | |
| 32 | struct AnimationIndex |
| 33 | { |
| 34 | AnimationIndex() : index(0), timeOffset(0) {} |
| 35 | // index points to the animation at timeOffset, skipping 0 duration animations. |
| 36 | // Note that the index semantic is slightly different depending on the direction. |
| 37 | int index; // the index of the animation in timeOffset |
| 38 | int timeOffset; // time offset when the animation at index starts. |
| 39 | }; |
| 40 | |
| 41 | int animationActualTotalDuration(int index) const; |
| 42 | AnimationIndex indexForCurrentTime() const; |
| 43 | |
| 44 | void setCurrentAnimation(int index, bool intermediate = false); |
| 45 | void activateCurrentAnimation(bool intermediate = false); |
| 46 | |
| 47 | void animationInsertedAt(qsizetype index) override; |
| 48 | void animationRemoved(qsizetype index, QAbstractAnimation *anim) override; |
| 49 | |
| 50 | bool atEnd() const; |
| 51 | |
| 52 | Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QSequentialAnimationGroupPrivate, QAbstractAnimation *, |
| 53 | currentAnimation, |
| 54 | nullptr // initial value |
| 55 | ) |
| 56 | int currentAnimationIndex; |
| 57 | |
| 58 | // this is the actual duration of uncontrolled animations |
| 59 | // it helps seeking and even going forward |
| 60 | QList<int> actualDuration; |
| 61 | |
| 62 | void restart(); |
| 63 | int lastLoop; |
| 64 | |
| 65 | // handle time changes |
| 66 | void rewindForwards(const AnimationIndex &newAnimationIndex); |
| 67 | void advanceForwards(const AnimationIndex &newAnimationIndex); |
| 68 | |
| 69 | // private slot |
| 70 | void _q_uncontrolledAnimationFinished(); |
| 71 | }; |
| 72 | |
| 73 | QT_END_NAMESPACE |
| 74 | |
| 75 | #endif //QSEQUENTIALANIMATIONGROUP_P_H |
| 76 |
