Qt 4.8
qdeclarativeflickable_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 QDECLARATIVEFLICKABLE_P_H
43 #define QDECLARATIVEFLICKABLE_P_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 "private/qdeclarativeflickable_p.h"
57 
58 #include "private/qdeclarativeitem_p.h"
59 #include "private/qdeclarativeitemchangelistener_p.h"
60 
61 #include <qdeclarative.h>
64 
65 #include <qdatetime.h>
66 #include "qplatformdefs.h"
67 
69 
70 // Really slow flicks can be annoying.
71 #ifndef QML_FLICK_MINVELOCITY
72 #define QML_FLICK_MINVELOCITY 175
73 #endif
74 
76 
79 {
81 
82 public:
84  void init();
85 
87  {
89  : parent(p) {}
90  virtual void setValue(qreal v) {
91  if (v != value()) {
94  }
95  }
97  };
98 
99  struct AxisData {
101  : move(fp, func), viewSize(-1), smoothVelocity(fp), atEnd(false), atBeginning(true)
102  , fixingUp(false), inOvershoot(false), moving(false), flicking(false)
103  {}
104 
105  void reset() {
106  velocityBuffer.clear();
107  dragStartOffset = 0;
108  fixingUp = false;
109  inOvershoot = false;
110  }
111 
112  void addVelocitySample(qreal v, qreal maxVelocity);
113  void updateVelocity();
114 
125  bool atEnd : 1;
126  bool atBeginning : 1;
127  bool fixingUp : 1;
128  bool inOvershoot : 1;
129  bool moving : 1;
130  bool flicking : 1;
131  };
132 
133  void flickX(qreal velocity);
134  void flickY(qreal velocity);
135  virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
136  QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
137 
138  void fixupX();
139  void fixupY();
140  virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
141 
142  void updateBeginningEnd();
143 
144  bool isOutermostPressDelay() const;
146  void clearDelayedPress();
147 
148  void setRoundedViewportX(qreal x);
149  void setRoundedViewportY(qreal y);
150 
152 
153  void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &);
154 
155 public:
157 
160 
162  bool hMoved : 1;
163  bool vMoved : 1;
164  bool stealMouse : 1;
165  bool pressed : 1;
166  bool interactive : 1;
167  bool calcVelocity : 1;
182 
185 
186  static void fixupY_callback(void *);
187  static void fixupX_callback(void *);
188 
189  void updateVelocity();
190  int vTime;
195 
199 
200  // flickableData property
205 };
206 
208 {
209  Q_OBJECT
210 
215 
216 public:
218 
219  qreal xPosition() const;
220  qreal widthRatio() const;
221  qreal yPosition() const;
222  qreal heightRatio() const;
223 
224  void updateVisible();
225 
226 signals:
227  void xPositionChanged(qreal xPosition);
228  void yPositionChanged(qreal yPosition);
229  void widthRatioChanged(qreal widthRatio);
230  void heightRatioChanged(qreal heightRatio);
231 
232 private:
238 };
239 
241 
243 
244 #endif
static QObject * data_at(QDeclarativeListProperty< QObject > *, int)
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QML_DECLARE_TYPE(TYPE)
Definition: qdeclarative.h:56
QDeclarativeFlickablePrivate::Velocity smoothVelocity
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
void handleMousePressEvent(QGraphicsSceneMouseEvent *)
void captureDelayedPress(QGraphicsSceneMouseEvent *event)
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:53
void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &)
The QDeclarativeTimeLineValue class provides a value that can be modified by QDeclarativeTimeLine.
AxisData(QDeclarativeFlickablePrivate *fp, void(QDeclarativeFlickablePrivate::*func)(qreal))
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
const qreal MinimumFlickVelocity
Velocity(QDeclarativeFlickablePrivate *p)
The QDeclarativeItem class provides the most basic of all visual items in QML.
virtual qreal value() const
Return the current value.
QGraphicsSceneMouseEvent * delayedPressEvent
virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent)
void handleMouseMoveEvent(QGraphicsSceneMouseEvent *)
static void data_append(QDeclarativeListProperty< QObject > *, QObject *)
static int data_count(QDeclarativeListProperty< QObject > *)
QDeclarativeFlickable::FlickableDirection flickableDirection
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QDeclarativeTimeLineValueProxy< QDeclarativeFlickablePrivate > move
virtual void setValue(qreal v)
Set the current value.
#define QML_FLICK_MINVELOCITY
The QDeclarativeTimeLine class provides a timeline for controlling animations.
virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
The QBasicTimer class provides timer events for objects.
Definition: qbasictimer.h:55
QDeclarativeFlickableVisibleArea * visibleArea
static void data_clear(QDeclarativeListProperty< QObject > *)
virtual void setValue(qreal v)
Set the current value.
#define signals
Definition: qobjectdefs.h:69
QDeclarativeListProperty< QObject > data()
void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *)
QDeclarativeFlickable::BoundsBehavior boundsBehavior