Merge remote-tracking branch 'origin/master' into api_changes
[profile/ivi/qtbase.git] / src / corelib / tools / qtimeline.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QTIMELINE_H
43 #define QTIMELINE_H
44
45 #include <QtCore/qeasingcurve.h>
46 #include <QtCore/qobject.h>
47
48 QT_BEGIN_HEADER
49
50 QT_BEGIN_NAMESPACE
51
52
53 class QTimeLinePrivate;
54 class Q_CORE_EXPORT QTimeLine : public QObject
55 {
56     Q_OBJECT
57     Q_PROPERTY(int duration READ duration WRITE setDuration)
58     Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval)
59     Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime)
60     Q_PROPERTY(Direction direction READ direction WRITE setDirection)
61     Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount)
62     Q_PROPERTY(CurveShape curveShape READ curveShape WRITE setCurveShape)
63     Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve)
64 public:
65     enum State {
66         NotRunning,
67         Paused,
68         Running
69     };
70     enum Direction {
71         Forward,
72         Backward
73     };
74     enum CurveShape {
75         EaseInCurve,
76         EaseOutCurve,
77         EaseInOutCurve,
78         LinearCurve,
79         SineCurve,
80         CosineCurve
81     };
82
83     explicit QTimeLine(int duration = 1000, QObject *parent = 0);
84     virtual ~QTimeLine();
85
86     State state() const;
87
88     int loopCount() const;
89     void setLoopCount(int count);
90
91     Direction direction() const;
92     void setDirection(Direction direction);
93
94     int duration() const;
95     void setDuration(int duration);
96
97     int startFrame() const;
98     void setStartFrame(int frame);
99     int endFrame() const;
100     void setEndFrame(int frame);
101     void setFrameRange(int startFrame, int endFrame);
102
103     int updateInterval() const;
104     void setUpdateInterval(int interval);
105
106     CurveShape curveShape() const;
107     void setCurveShape(CurveShape shape);
108
109     QEasingCurve easingCurve() const;
110     void setEasingCurve(const QEasingCurve &curve);
111
112     int currentTime() const;
113     int currentFrame() const;
114     qreal currentValue() const;
115
116     int frameForTime(int msec) const;
117     virtual qreal valueForTime(int msec) const;
118
119 public Q_SLOTS:
120     void start();
121     void resume();
122     void stop();
123     void setPaused(bool paused);
124     void setCurrentTime(int msec);
125     void toggleDirection();
126
127 Q_SIGNALS:
128     void valueChanged(qreal x);
129     void frameChanged(int);
130     void stateChanged(QTimeLine::State newState);
131     void finished();
132
133 protected:
134     void timerEvent(QTimerEvent *event);
135
136 private:
137     Q_DISABLE_COPY(QTimeLine)
138     Q_DECLARE_PRIVATE(QTimeLine)
139 };
140
141 QT_END_NAMESPACE
142
143 QT_END_HEADER
144
145 #endif
146