Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qabstractanimation.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QABSTRACTANIMATION_H
6#define QABSTRACTANIMATION_H
7
8#include <QtCore/qobject.h>
9
11
12QT_BEGIN_NAMESPACE
13
14class QAnimationGroup;
15class QSequentialAnimationGroup;
16class QAnimationDriver;
17class QUnifiedTimer;
18
19class QAbstractAnimationPrivate;
20class Q_CORE_EXPORT QAbstractAnimation : public QObject
21{
22 Q_OBJECT
23
24 Q_PROPERTY(State state READ state NOTIFY stateChanged BINDABLE bindableState)
25 Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount BINDABLE bindableLoopCount)
26 Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime BINDABLE bindableCurrentTime)
27 Q_PROPERTY(int currentLoop READ currentLoop NOTIFY currentLoopChanged
28 BINDABLE bindableCurrentLoop)
29 Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged
30 BINDABLE bindableDirection)
31 Q_PROPERTY(int duration READ duration)
32
33public:
34 enum Direction {
35 Forward,
36 Backward
37 };
38 Q_ENUM(Direction)
39
40 enum State {
41 Stopped,
42 Paused,
43 Running
44 };
45 Q_ENUM(State)
46
47 enum DeletionPolicy {
48 KeepWhenStopped = 0,
49 DeleteWhenStopped
50 };
51
52 QAbstractAnimation(QObject *parent = nullptr);
53 virtual ~QAbstractAnimation();
54
55 State state() const;
56 QBindable<QAbstractAnimation::State> bindableState() const;
57
58 QAnimationGroup *group() const;
59
60 Direction direction() const;
61 void setDirection(Direction direction);
62 QBindable<Direction> bindableDirection();
63
64 int currentTime() const;
65 QBindable<int> bindableCurrentTime();
66
67 int currentLoopTime() const;
68
69 int loopCount() const;
70 void setLoopCount(int loopCount);
71 QBindable<int> bindableLoopCount();
72
73 int currentLoop() const;
74 QBindable<int> bindableCurrentLoop() const;
75
76 virtual int duration() const = 0;
77 int totalDuration() const;
78
79Q_SIGNALS:
80 void finished();
81 void stateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
82 void currentLoopChanged(int currentLoop);
83 void directionChanged(QAbstractAnimation::Direction);
84
85public Q_SLOTS:
86 void start(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped);
87 void pause();
88 void resume();
89 void setPaused(bool);
90 void stop();
91 void setCurrentTime(int msecs);
92
93protected:
94 QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = nullptr);
95 bool event(QEvent *event) override;
96
97 virtual void updateCurrentTime(int currentTime) = 0;
98 virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
99 virtual void updateDirection(QAbstractAnimation::Direction direction);
100
101private:
102 Q_DISABLE_COPY(QAbstractAnimation)
103 Q_DECLARE_PRIVATE(QAbstractAnimation)
104};
105
106class QAnimationDriverPrivate;
107class Q_CORE_EXPORT QAnimationDriver : public QObject
108{
109 Q_OBJECT
110 Q_DECLARE_PRIVATE(QAnimationDriver)
111
112public:
113 QAnimationDriver(QObject *parent = nullptr);
114 ~QAnimationDriver();
115
116 virtual void advance();
117
118 void install();
119 void uninstall();
120
121 bool isRunning() const;
122
123 virtual qint64 elapsed() const;
124
125Q_SIGNALS:
126 void started();
127 void stopped();
128
129protected:
130 void advanceAnimation();
131 virtual void start();
132 virtual void stop();
133
134 QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = nullptr);
135
136private:
137 friend class QUnifiedTimer;
138
139};
140
141QT_END_NAMESPACE
142
143#endif // QABSTRACTANIMATION_H
\inmodule QtCore
static void unregisterAnimation(QAbstractAnimation *animation)
static QAnimationTimer * instance(bool create)
static void updateAnimationTimer()
void updateAnimationsTime(qint64 delta) override
~QAnimationTimer() override
void restartAnimationTimer() override
static void ensureTimerUpdate()
static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel)
static QAnimationTimer * instance()
void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
QList< QAbstractAnimation * >::ConstIterator AnimationListConstIt
#define DEFAULT_TIMER_INTERVAL
QT_BEGIN_NAMESPACE typedef QList< QAbstractAnimationTimer * >::ConstIterator TimerListConstIt
#define PAUSE_TIMER_COARSE_THRESHOLD
QT_REQUIRE_CONFIG(animation)