~ubuntu-branches/ubuntu/wily/qtbase-opensource-src/wily

« back to all changes in this revision

Viewing changes to src/corelib/animation/qabstractanimation.h

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 12:46:17 UTC
  • Revision ID: package-import@ubuntu.com-20130205124617-c8jouts182j002fx
Tags: upstream-5.0.1+dfsg
ImportĀ upstreamĀ versionĀ 5.0.1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 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
 
 
47
QT_BEGIN_HEADER
 
48
 
 
49
QT_BEGIN_NAMESPACE
 
50
 
 
51
 
 
52
#ifndef QT_NO_ANIMATION
 
53
 
 
54
class QAnimationGroup;
 
55
class QSequentialAnimationGroup;
 
56
class QAnimationDriver;
 
57
 
 
58
class QAbstractAnimationPrivate;
 
59
class Q_CORE_EXPORT QAbstractAnimation : public QObject
 
60
{
 
61
    Q_OBJECT
 
62
    Q_ENUMS(State)
 
63
    Q_ENUMS(Direction)
 
64
    Q_PROPERTY(State state READ state NOTIFY stateChanged)
 
65
    Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount)
 
66
    Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime)
 
67
    Q_PROPERTY(int currentLoop READ currentLoop NOTIFY currentLoopChanged)
 
68
    Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged)
 
69
    Q_PROPERTY(int duration READ duration)
 
70
 
 
71
public:
 
72
    enum Direction {
 
73
        Forward,
 
74
        Backward
 
75
    };
 
76
 
 
77
    enum State {
 
78
        Stopped,
 
79
        Paused,
 
80
        Running
 
81
    };
 
82
 
 
83
    enum DeletionPolicy {
 
84
        KeepWhenStopped = 0,
 
85
        DeleteWhenStopped
 
86
    };
 
87
 
 
88
    QAbstractAnimation(QObject *parent = 0);
 
89
    virtual ~QAbstractAnimation();
 
90
 
 
91
    State state() const;
 
92
 
 
93
    QAnimationGroup *group() const;
 
94
 
 
95
    Direction direction() const;
 
96
    void setDirection(Direction direction);
 
97
 
 
98
    int currentTime() const;
 
99
    int currentLoopTime() const;
 
100
 
 
101
    int loopCount() const;
 
102
    void setLoopCount(int loopCount);
 
103
    int currentLoop() const;
 
104
 
 
105
    virtual int duration() const = 0;
 
106
    int totalDuration() const;
 
107
 
 
108
Q_SIGNALS:
 
109
    void finished();
 
110
    void stateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
 
111
    void currentLoopChanged(int currentLoop);
 
112
    void directionChanged(QAbstractAnimation::Direction);
 
113
 
 
114
public Q_SLOTS:
 
115
    void start(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped);
 
116
    void pause();
 
117
    void resume();
 
118
    void setPaused(bool);
 
119
    void stop();
 
120
    void setCurrentTime(int msecs);
 
121
 
 
122
protected:
 
123
    QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = 0);
 
124
    bool event(QEvent *event);
 
125
 
 
126
    virtual void updateCurrentTime(int currentTime) = 0;
 
127
    virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
 
128
    virtual void updateDirection(QAbstractAnimation::Direction direction);
 
129
 
 
130
private:
 
131
    Q_DISABLE_COPY(QAbstractAnimation)
 
132
    Q_DECLARE_PRIVATE(QAbstractAnimation)
 
133
};
 
134
 
 
135
class QAnimationDriverPrivate;
 
136
class Q_CORE_EXPORT QAnimationDriver : public QObject
 
137
{
 
138
    Q_OBJECT
 
139
    Q_DECLARE_PRIVATE(QAnimationDriver)
 
140
 
 
141
public:
 
142
    QAnimationDriver(QObject *parent = 0);
 
143
    ~QAnimationDriver();
 
144
 
 
145
    virtual void advance();
 
146
 
 
147
    void install();
 
148
    void uninstall();
 
149
 
 
150
    bool isRunning() const;
 
151
 
 
152
    virtual qint64 elapsed() const;
 
153
 
 
154
    void setStartTime(qint64 startTime);
 
155
    qint64 startTime() const;
 
156
 
 
157
Q_SIGNALS:
 
158
    void started();
 
159
    void stopped();
 
160
 
 
161
protected:
 
162
    void advanceAnimation(qint64 timeStep = -1);
 
163
    virtual void start();
 
164
    virtual void stop();
 
165
 
 
166
    QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = 0);
 
167
 
 
168
private:
 
169
    friend class QUnifiedTimer;
 
170
 
 
171
};
 
172
 
 
173
 
 
174
 
 
175
 
 
176
#endif //QT_NO_ANIMATION
 
177
 
 
178
QT_END_NAMESPACE
 
179
 
 
180
QT_END_HEADER
 
181
 
 
182
#endif // QABSTRACTANIMATION_H