Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:14

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QABSTRACTANIMATION_H
0005 #define QABSTRACTANIMATION_H
0006 
0007 #include <QtCore/qobject.h>
0008 
0009 QT_REQUIRE_CONFIG(animation);
0010 
0011 QT_BEGIN_NAMESPACE
0012 
0013 class QAnimationGroup;
0014 class QSequentialAnimationGroup;
0015 class QAnimationDriver;
0016 class QUnifiedTimer;
0017 
0018 class QAbstractAnimationPrivate;
0019 class Q_CORE_EXPORT QAbstractAnimation : public QObject
0020 {
0021     Q_OBJECT
0022 
0023     Q_PROPERTY(State state READ state NOTIFY stateChanged BINDABLE bindableState)
0024     Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount BINDABLE bindableLoopCount)
0025     Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime BINDABLE bindableCurrentTime)
0026     Q_PROPERTY(int currentLoop READ currentLoop NOTIFY currentLoopChanged
0027                BINDABLE bindableCurrentLoop)
0028     Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged
0029                BINDABLE bindableDirection)
0030     Q_PROPERTY(int duration READ duration)
0031 
0032 public:
0033     enum Direction {
0034         Forward,
0035         Backward
0036     };
0037     Q_ENUM(Direction)
0038 
0039     enum State {
0040         Stopped,
0041         Paused,
0042         Running
0043     };
0044     Q_ENUM(State)
0045 
0046     enum DeletionPolicy {
0047         KeepWhenStopped = 0,
0048         DeleteWhenStopped
0049     };
0050 
0051     QAbstractAnimation(QObject *parent = nullptr);
0052     virtual ~QAbstractAnimation();
0053 
0054     State state() const;
0055     QBindable<QAbstractAnimation::State> bindableState() const;
0056 
0057     QAnimationGroup *group() const;
0058 
0059     Direction direction() const;
0060     void setDirection(Direction direction);
0061     QBindable<Direction> bindableDirection();
0062 
0063     int currentTime() const;
0064     QBindable<int> bindableCurrentTime();
0065 
0066     int currentLoopTime() const;
0067 
0068     int loopCount() const;
0069     void setLoopCount(int loopCount);
0070     QBindable<int> bindableLoopCount();
0071 
0072     int currentLoop() const;
0073     QBindable<int> bindableCurrentLoop() const;
0074 
0075     virtual int duration() const = 0;
0076     int totalDuration() const;
0077 
0078 Q_SIGNALS:
0079     void finished();
0080     void stateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
0081     void currentLoopChanged(int currentLoop);
0082     void directionChanged(QAbstractAnimation::Direction);
0083 
0084 public Q_SLOTS:
0085     void start(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped);
0086     void pause();
0087     void resume();
0088     void setPaused(bool);
0089     void stop();
0090     void setCurrentTime(int msecs);
0091 
0092 protected:
0093     QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = nullptr);
0094     bool event(QEvent *event) override;
0095 
0096     virtual void updateCurrentTime(int currentTime) = 0;
0097     virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
0098     virtual void updateDirection(QAbstractAnimation::Direction direction);
0099 
0100 private:
0101     Q_DISABLE_COPY(QAbstractAnimation)
0102     Q_DECLARE_PRIVATE(QAbstractAnimation)
0103 };
0104 
0105 class QAnimationDriverPrivate;
0106 class Q_CORE_EXPORT QAnimationDriver : public QObject
0107 {
0108     Q_OBJECT
0109     Q_DECLARE_PRIVATE(QAnimationDriver)
0110 
0111 public:
0112     QAnimationDriver(QObject *parent = nullptr);
0113     ~QAnimationDriver();
0114 
0115     virtual void advance();
0116 
0117     void install();
0118     void uninstall();
0119 
0120     bool isRunning() const;
0121 
0122     virtual qint64 elapsed() const;
0123 
0124 Q_SIGNALS:
0125     void started();
0126     void stopped();
0127 
0128 protected:
0129     void advanceAnimation();
0130     virtual void start();
0131     virtual void stop();
0132 
0133     QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = nullptr);
0134 
0135 private:
0136     friend class QUnifiedTimer;
0137 
0138 };
0139 
0140 QT_END_NAMESPACE
0141 
0142 #endif // QABSTRACTANIMATION_H