1/****************************************************************************
2**
3** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtCore module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QABSTRACTANIMATION_H
43#define QABSTRACTANIMATION_H
44
45#include <QtCore/qobject.h>
46
47QT_BEGIN_HEADER
48
49QT_BEGIN_NAMESPACE
50
51QT_MODULE(Core)
52
53#ifndef QT_NO_ANIMATION
54
55class QAnimationGroup;
56class QSequentialAnimationGroup;
57class QAnimationDriver;
58
59class QAbstractAnimationPrivate;
60class Q_CORE_EXPORT QAbstractAnimation : public QObject
61{
62 Q_OBJECT
63 Q_ENUMS(State)
64 Q_ENUMS(Direction)
65 Q_PROPERTY(State state READ state NOTIFY stateChanged)
66 Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount)
67 Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime)
68 Q_PROPERTY(int currentLoop READ currentLoop NOTIFY currentLoopChanged)
69 Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged)
70 Q_PROPERTY(int duration READ duration)
71
72public:
73 enum Direction {
74 Forward,
75 Backward
76 };
77
78 enum State {
79 Stopped,
80 Paused,
81 Running
82 };
83
84 enum DeletionPolicy {
85 KeepWhenStopped = 0,
86 DeleteWhenStopped
87 };
88
89 QAbstractAnimation(QObject *parent = 0);
90 virtual ~QAbstractAnimation();
91
92 State state() const;
93
94 QAnimationGroup *group() const;
95
96 Direction direction() const;
97 void setDirection(Direction direction);
98
99 int currentTime() const;
100 int currentLoopTime() const;
101
102 int loopCount() const;
103 void setLoopCount(int loopCount);
104 int currentLoop() const;
105
106 virtual int duration() const = 0;
107 int totalDuration() const;
108
109Q_SIGNALS:
110 void finished();
111 void stateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
112 void currentLoopChanged(int currentLoop);
113 void directionChanged(QAbstractAnimation::Direction);
114
115public Q_SLOTS:
116 void start(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped);
117 void pause();
118 void resume();
119 void setPaused(bool);
120 void stop();
121 void setCurrentTime(int msecs);
122
123protected:
124 QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = 0);
125 bool event(QEvent *event);
126
127 virtual void updateCurrentTime(int currentTime) = 0;
128 virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
129 virtual void updateDirection(QAbstractAnimation::Direction direction);
130
131private:
132 Q_DISABLE_COPY(QAbstractAnimation)
133 Q_DECLARE_PRIVATE(QAbstractAnimation)
134};
135
136class QAnimationDriverPrivate;
137class Q_CORE_EXPORT QAnimationDriver : public QObject
138{
139 Q_OBJECT
140 Q_DECLARE_PRIVATE(QAnimationDriver)
141
142public:
143 QAnimationDriver(QObject *parent = 0);
144
145 void advance();
146 void install();
147
148 bool isRunning() const;
149
150protected:
151 virtual void started() {};
152 virtual void stopped() {};
153
154 QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = 0);
155
156private:
157 friend class QUnifiedTimer;
158
159 void start();
160 void stop();
161};
162
163
164
165
166#endif //QT_NO_ANIMATION
167
168QT_END_NAMESPACE
169
170QT_END_HEADER
171
172#endif // QABSTRACTANIMATION_H
173