File indexing completed on 2025-01-18 10:07:40
0001
0002
0003
0004 #ifndef QTIMELINE_H
0005 #define QTIMELINE_H
0006
0007 #include <QtCore/qglobal.h>
0008
0009 QT_REQUIRE_CONFIG(easingcurve);
0010
0011 #include <QtCore/qeasingcurve.h>
0012 #include <QtCore/qobject.h>
0013
0014 QT_BEGIN_NAMESPACE
0015
0016
0017 class QTimeLinePrivate;
0018 class Q_CORE_EXPORT QTimeLine : public QObject
0019 {
0020 Q_OBJECT
0021 Q_PROPERTY(int duration READ duration WRITE setDuration BINDABLE bindableDuration)
0022 Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval
0023 BINDABLE bindableUpdateInterval)
0024 Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime BINDABLE bindableCurrentTime)
0025 Q_PROPERTY(Direction direction READ direction WRITE setDirection BINDABLE bindableDirection)
0026 Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount BINDABLE bindableLoopCount)
0027 Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve
0028 BINDABLE bindableEasingCurve)
0029 public:
0030 enum State {
0031 NotRunning,
0032 Paused,
0033 Running
0034 };
0035 enum Direction {
0036 Forward,
0037 Backward
0038 };
0039
0040 explicit QTimeLine(int duration = 1000, QObject *parent = nullptr);
0041 virtual ~QTimeLine();
0042
0043 State state() const;
0044
0045 int loopCount() const;
0046 void setLoopCount(int count);
0047 QBindable<int> bindableLoopCount();
0048
0049 Direction direction() const;
0050 void setDirection(Direction direction);
0051 QBindable<Direction> bindableDirection();
0052
0053 int duration() const;
0054 void setDuration(int duration);
0055 QBindable<int> bindableDuration();
0056
0057 int startFrame() const;
0058 void setStartFrame(int frame);
0059 int endFrame() const;
0060 void setEndFrame(int frame);
0061 void setFrameRange(int startFrame, int endFrame);
0062
0063 int updateInterval() const;
0064 void setUpdateInterval(int interval);
0065 QBindable<int> bindableUpdateInterval();
0066
0067 QEasingCurve easingCurve() const;
0068 void setEasingCurve(const QEasingCurve &curve);
0069 QBindable<QEasingCurve> bindableEasingCurve();
0070
0071 int currentTime() const;
0072 QBindable<int> bindableCurrentTime();
0073 int currentFrame() const;
0074 qreal currentValue() const;
0075
0076 int frameForTime(int msec) const;
0077 virtual qreal valueForTime(int msec) const;
0078
0079 public Q_SLOTS:
0080 void start();
0081 void resume();
0082 void stop();
0083 void setPaused(bool paused);
0084 void setCurrentTime(int msec);
0085 void toggleDirection();
0086
0087 Q_SIGNALS:
0088 void valueChanged(qreal x, QPrivateSignal);
0089 void frameChanged(int, QPrivateSignal);
0090 void stateChanged(QTimeLine::State newState, QPrivateSignal);
0091 void finished(QPrivateSignal);
0092
0093 protected:
0094 void timerEvent(QTimerEvent *event) override;
0095
0096 private:
0097 Q_DISABLE_COPY(QTimeLine)
0098 Q_DECLARE_PRIVATE(QTimeLine)
0099 };
0100
0101 QT_END_NAMESPACE
0102
0103 #endif
0104