Qt 4.8
qdeclarativetimeline_p_p.h
Go to the documentation of this file.
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 QtDeclarative 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 QDECLARATIVETIMELINE_H
43 #define QDECLARATIVETIMELINE_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <QtCore/QObject>
57 #include <QtCore/QAbstractAnimation>
58 
60 
61 class QEasingCurve;
67 {
69 public:
70  QDeclarativeTimeLine(QObject *parent = 0);
72 
73  enum SyncMode { LocalSync, GlobalSync };
74  SyncMode syncMode() const;
75  void setSyncMode(SyncMode);
76 
77  void pause(QDeclarativeTimeLineObject &, int);
79  void set(QDeclarativeTimeLineValue &, qreal);
80 
81  int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel);
82  int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance);
83  int accelDistance(QDeclarativeTimeLineValue &, qreal velocity, qreal distance);
84 
85  void move(QDeclarativeTimeLineValue &, qreal destination, int time = 500);
86  void move(QDeclarativeTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500);
87  void moveBy(QDeclarativeTimeLineValue &, qreal change, int time = 500);
88  void moveBy(QDeclarativeTimeLineValue &, qreal change, const QEasingCurve &, int time = 500);
89 
90  void sync();
91  void setSyncPoint(int);
92  int syncPoint() const;
93 
94  void sync(QDeclarativeTimeLineValue &);
95  void sync(QDeclarativeTimeLineValue &, QDeclarativeTimeLineValue &);
96 
97  void reset(QDeclarativeTimeLineValue &);
98 
99  void complete();
100  void clear();
101  bool isActive() const;
102 
103  int time() const;
104 
105  virtual int duration() const;
106 Q_SIGNALS:
107  void updated();
108  void completed();
109 
110 protected:
111  virtual void updateCurrentTime(int);
112 
113 private:
114  void remove(QDeclarativeTimeLineObject *);
118 };
119 
121 {
122 public:
124  virtual ~QDeclarativeTimeLineObject();
125 
126 protected:
127  friend class QDeclarativeTimeLine;
130 };
131 
133 {
134 public:
135  QDeclarativeTimeLineValue(qreal v = 0.) : _v(v) {}
136 
137  virtual qreal value() const { return _v; }
138  virtual void setValue(qreal v) { _v = v; }
139 
140  QDeclarativeTimeLine *timeLine() const { return _t; }
141 
142  operator qreal() const { return _v; }
143  QDeclarativeTimeLineValue &operator=(qreal v) { setValue(v); return *this; }
144 private:
145  friend class QDeclarativeTimeLine;
148 };
149 
151 {
152 public:
153  typedef void (*Callback)(void *);
154 
158 
160  QDeclarativeTimeLineObject *callbackObject() const;
161 
162 private:
164  Callback d0;
165  void *d1;
167 };
168 
169 template<class T>
171 {
172 public:
173  QDeclarativeTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
174  : QDeclarativeTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
175  {
176  Q_ASSERT(_class);
177  }
178 
179  QDeclarativeTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
180  : QDeclarativeTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
181  {
182  Q_ASSERT(_class);
183  }
184 
185  virtual void setValue(qreal v)
186  {
188  if (_setFunctionReal) (_class->*_setFunctionReal)(v);
189  else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v);
190  }
191 
192 private:
193  T *_class;
194  void (T::*_setFunctionReal)(qreal);
195  void (T::*_setFunctionInt)(int);
196 };
197 
199 
200 #endif
QDeclarativeTimeLineObject * d2
static void callback(AuServer *, AuEventHandlerRec *, AuEvent *e, AuPointer p)
Definition: qsound_x11.cpp:170
virtual void updateCurrentTime(int currentTime)=0
This pure virtual function is called every time the animation&#39;s currentTime changes.
double qreal
Definition: qglobal.h:1193
virtual void setValue(qreal v)
Set the current value.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QEasingCurve class provides easing curves for controlling animation.
Definition: qeasingcurve.h:55
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
static void clear(QVariant::Private *d)
Definition: qvariant.cpp:197
QDeclarativeTimeLineValue(qreal v=0.)
Construct a new QDeclarativeTimeLineValue with an initial value.
QDeclarativeTimeLine * timeLine() const
If a QDeclarativeTimeLine is operating on this value, return a pointer to it, otherwise return null...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
The QDeclarativeTimeLineValue class provides a value that can be modified by QDeclarativeTimeLine.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QDeclarativeTimeLineValueProxy(T *cls, void(T::*func)(int), qreal v=0.)
virtual qreal value() const
Return the current value.
static int distance(QWidget *source, QWidget *target, QAccessible::RelationFlag relation)
The QAbstractAnimation class is the base of all animations.
#define Q_OBJECT
Definition: qobjectdefs.h:157
QDeclarativeTimeLinePrivate * d
QDeclarativeTimeLineValue & operator=(qreal v)
The QDeclarativeTimeLine class provides a timeline for controlling animations.
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
void pause()
Pauses the animation.
QDeclarativeTimeLineValueProxy(T *cls, void(T::*func)(qreal), qreal v=0.)
virtual int duration() const =0
virtual void setValue(qreal v)
Set the current value.