| 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 QQUICKTRANSITION_H |
| 5 | #define QQUICKTRANSITION_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 "qquickstate_p.h" |
| 19 | #include <private/qabstractanimationjob_p.h> |
| 20 | #include <private/qqmlguard_p.h> |
| 21 | #include <qqml.h> |
| 22 | |
| 23 | #include <QtCore/qobject.h> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | class QQuickAbstractAnimation; |
| 28 | class QQuickTransitionPrivate; |
| 29 | class QQuickTransitionManager; |
| 30 | class QQuickTransition; |
| 31 | |
| 32 | class QQuickTransitionInstance : QAnimationJobChangeListener |
| 33 | { |
| 34 | public: |
| 35 | QQuickTransitionInstance(QQuickTransition *transition, QAbstractAnimationJob *anim); |
| 36 | ~QQuickTransitionInstance(); |
| 37 | |
| 38 | void start(); |
| 39 | void stop(); |
| 40 | void complete(); |
| 41 | |
| 42 | bool isRunning() const; |
| 43 | |
| 44 | protected: |
| 45 | void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) override; |
| 46 | |
| 47 | void removeStateChangeListener() |
| 48 | { |
| 49 | m_anim->removeAnimationChangeListener(listener: this, QAbstractAnimationJob::StateChange); |
| 50 | } |
| 51 | |
| 52 | private: |
| 53 | QQmlGuard<QQuickTransition> m_transition; |
| 54 | QAbstractAnimationJob *m_anim; |
| 55 | friend class QQuickTransition; |
| 56 | }; |
| 57 | |
| 58 | class Q_QUICK_EXPORT QQuickTransition : public QObject |
| 59 | { |
| 60 | Q_OBJECT |
| 61 | Q_DECLARE_PRIVATE(QQuickTransition) |
| 62 | |
| 63 | Q_PROPERTY(QString from READ fromState WRITE setFromState NOTIFY fromChanged) |
| 64 | Q_PROPERTY(QString to READ toState WRITE setToState NOTIFY toChanged) |
| 65 | Q_PROPERTY(bool reversible READ reversible WRITE setReversible NOTIFY reversibleChanged) |
| 66 | Q_PROPERTY(bool running READ running NOTIFY runningChanged) |
| 67 | Q_PROPERTY(QQmlListProperty<QQuickAbstractAnimation> animations READ animations) |
| 68 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) |
| 69 | Q_CLASSINFO("DefaultProperty" , "animations" ) |
| 70 | Q_CLASSINFO("DeferredPropertyNames" , "animations" ) |
| 71 | QML_NAMED_ELEMENT(Transition) |
| 72 | QML_ADDED_IN_VERSION(2, 0) |
| 73 | |
| 74 | public: |
| 75 | QQuickTransition(QObject *parent=nullptr); |
| 76 | ~QQuickTransition(); |
| 77 | |
| 78 | QString fromState() const; |
| 79 | void setFromState(const QString &); |
| 80 | |
| 81 | QString toState() const; |
| 82 | void setToState(const QString &); |
| 83 | |
| 84 | bool reversible() const; |
| 85 | void setReversible(bool); |
| 86 | |
| 87 | bool enabled() const; |
| 88 | void setEnabled(bool enabled); |
| 89 | |
| 90 | bool running() const; |
| 91 | |
| 92 | QQmlListProperty<QQuickAbstractAnimation> animations(); |
| 93 | |
| 94 | QQuickTransitionInstance *prepare(QQuickStateOperation::ActionList &actions, |
| 95 | QList<QQmlProperty> &after, |
| 96 | QQuickTransitionManager *end, |
| 97 | QObject *defaultTarget); |
| 98 | |
| 99 | void setReversed(bool r); |
| 100 | |
| 101 | Q_SIGNALS: |
| 102 | void fromChanged(); |
| 103 | void toChanged(); |
| 104 | void reversibleChanged(); |
| 105 | void enabledChanged(); |
| 106 | void runningChanged(); |
| 107 | }; |
| 108 | |
| 109 | QT_END_NAMESPACE |
| 110 | |
| 111 | #endif // QQUICKTRANSITION_H |
| 112 | |