summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-22 04:13:02 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-22 04:13:02 (GMT)
commitbffef59bcefd73a5474f3c3052c951977b60eb27 (patch)
tree1a4cef897f9b8993912888c7544cb1af92db4d2b /src/declarative
parent2ca7a8827c748c7ec5b60d0ebe1f8de27d58a693 (diff)
parentcef8907c1fd74f5b5d12b0c10c4b18a90233006a (diff)
downloadQt-bffef59bcefd73a5474f3c3052c951977b60eb27.zip
Qt-bffef59bcefd73a5474f3c3052c951977b60eb27.tar.gz
Qt-bffef59bcefd73a5474f3c3052c951977b60eb27.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp16
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h5
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview.cpp9
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview_p_p.h3
-rw-r--r--src/declarative/util/qmltimeline.cpp47
-rw-r--r--src/declarative/util/qmltimeline_p_p.h43
7 files changed, 65 insertions, 66 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index 6825f89..bfee8d4 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
@@ -132,8 +132,6 @@ QmlGraphicsFlickablePrivate::QmlGraphicsFlickablePrivate()
, horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0)
, flickDirection(QmlGraphicsFlickable::AutoFlickDirection)
{
- fixupXEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsFlickablePrivate, &QmlGraphicsFlickablePrivate::fixupX>(&_moveX, this);
- fixupYEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsFlickablePrivate, &QmlGraphicsFlickablePrivate::fixupY>(&_moveY, this);
}
void QmlGraphicsFlickablePrivate::init()
@@ -176,7 +174,7 @@ void QmlGraphicsFlickablePrivate::flickX(qreal velocity)
}
timeline.reset(_moveX);
timeline.accel(_moveX, v, deceleration, maxDistance);
- timeline.execute(fixupXEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this));
if (!flicked) {
flicked = true;
emit q->flickingChanged();
@@ -214,7 +212,7 @@ void QmlGraphicsFlickablePrivate::flickY(qreal velocity)
}
timeline.reset(_moveY);
timeline.accel(_moveY, v, deceleration, maxDistance);
- timeline.execute(fixupYEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this));
if (!flicked) {
flicked = true;
emit q->flickingChanged();
@@ -255,6 +253,16 @@ void QmlGraphicsFlickablePrivate::fixupX()
vTime = timeline.time();
}
+void QmlGraphicsFlickablePrivate::fixupY_callback(void *data)
+{
+ ((QmlGraphicsFlickablePrivate *)data)->fixupY();
+}
+
+void QmlGraphicsFlickablePrivate::fixupX_callback(void *data)
+{
+ ((QmlGraphicsFlickablePrivate *)data)->fixupX();
+}
+
void QmlGraphicsFlickablePrivate::fixupY()
{
Q_Q(QmlGraphicsFlickable);
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
index 0c98f7b..a76ee8a 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
@@ -110,8 +110,6 @@ public:
qreal velocityX;
qreal velocityY;
QTime pressTime;
- QmlTimeLineEvent fixupXEvent;
- QmlTimeLineEvent fixupYEvent;
qreal deceleration;
qreal maxVelocity;
QTime velocityTime;
@@ -125,6 +123,9 @@ public:
int pressDelay;
int fixupDuration;
+ static void fixupY_callback(void *);
+ static void fixupX_callback(void *);
+
void updateVelocity();
struct Velocity : public QmlTimeLineValue
{
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index c646d49..108ac75 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -1200,7 +1200,7 @@ void QmlGraphicsListViewPrivate::flickX(qreal velocity)
}
timeline.reset(_moveX);
timeline.accel(_moveX, v, accel, maxDistance + overshootDist);
- timeline.execute(fixupXEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this));
flicked = true;
emit q->flickingChanged();
emit q->flickStarted();
@@ -1226,7 +1226,7 @@ void QmlGraphicsListViewPrivate::flickX(qreal velocity)
}
timeline.reset(_moveX);
timeline.accelDistance(_moveX, v, -dist + (v < 0 ? -overshootDist : overshootDist));
- timeline.execute(fixupXEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this));
}
} else {
correctFlick = false;
@@ -1298,7 +1298,7 @@ void QmlGraphicsListViewPrivate::flickY(qreal velocity)
}
timeline.reset(_moveY);
timeline.accel(_moveY, v, accel, maxDistance + overshootDist);
- timeline.execute(fixupYEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this));
flicked = true;
emit q->flickingChanged();
emit q->flickStarted();
@@ -1324,7 +1324,7 @@ void QmlGraphicsListViewPrivate::flickY(qreal velocity)
}
timeline.reset(_moveY);
timeline.accelDistance(_moveY, v, -dist + (v < 0 ? -overshootDist : overshootDist));
- timeline.execute(fixupYEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this));
}
} else {
correctFlick = false;
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
index f862555..aba184d 100644
--- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
@@ -524,7 +524,7 @@ void QmlGraphicsPathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
qreal dist = qAbs(velocity/2 - qmlMod(velocity/2, qreal(100.0 / d->model->count()) - inc));
d->moveOffset.setValue(d->_offset);
d->tl.accel(d->moveOffset, velocity, 10, dist);
- d->tl.execute(d->fixupOffsetEvent);
+ d->tl.callback(QmlTimeLineCallback(&d->moveOffset, d->fixOffsetCallback, d));
} else {
d->fixOffset();
}
@@ -886,6 +886,11 @@ void QmlGraphicsPathViewPrivate::updateCurrent()
}
}
+void QmlGraphicsPathViewPrivate::fixOffsetCallback(void *d)
+{
+ ((QmlGraphicsPathViewPrivate *)d)->fixOffset();
+}
+
void QmlGraphicsPathViewPrivate::fixOffset()
{
Q_Q(QmlGraphicsPathView);
@@ -938,7 +943,7 @@ void QmlGraphicsPathViewPrivate::snapToCurrent()
rounds++;
tl.move(moveOffset, targetOffset + 100.0*(-rounds), QEasingCurve(QEasingCurve::InOutQuad),
int(100*items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds))));
- tl.execute(fixupOffsetEvent);
+ tl.callback(QmlTimeLineCallback(&moveOffset, fixOffsetCallback, this));
return;
}
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
index 723d2d5..c635833 100644
--- a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
@@ -82,7 +82,6 @@ public:
, firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1)
, moveReason(Other)
{
- fixupOffsetEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsPathViewPrivate, &QmlGraphicsPathViewPrivate::fixOffset>(&moveOffset, this);
}
void init()
@@ -104,6 +103,7 @@ public:
int calcCurrentIndex();
void updateCurrent();
+ static void fixOffsetCallback(void*);
void fixOffset();
void setOffset(qreal offset);
void regenerate();
@@ -127,7 +127,6 @@ public:
qreal dragMargin;
QmlTimeLine tl;
QmlTimeLineValueProxy<QmlGraphicsPathViewPrivate> moveOffset;
- QmlTimeLineEvent fixupOffsetEvent;
int firstIndex;
int pathItems;
int pathOffset;
diff --git a/src/declarative/util/qmltimeline.cpp b/src/declarative/util/qmltimeline.cpp
index 58c87e8..5c5df40 100644
--- a/src/declarative/util/qmltimeline.cpp
+++ b/src/declarative/util/qmltimeline.cpp
@@ -55,12 +55,12 @@ QT_BEGIN_NAMESPACE
struct Update {
Update(QmlTimeLineValue *_g, qreal _v)
: g(_g), v(_v) {}
- Update(const QmlTimeLineEvent &_e)
+ Update(const QmlTimeLineCallback &_e)
: g(0), v(0), e(_e) {}
QmlTimeLineValue *g;
qreal v;
- QmlTimeLineEvent e;
+ QmlTimeLineCallback e;
};
struct QmlTimeLinePrivate
@@ -79,7 +79,7 @@ struct QmlTimeLinePrivate
};
Op() {}
Op(Type t, int l, qreal v, qreal v2, int o,
- const QmlTimeLineEvent &ev = QmlTimeLineEvent(), const QEasingCurve &es = QEasingCurve())
+ const QmlTimeLineCallback &ev = QmlTimeLineCallback(), const QEasingCurve &es = QEasingCurve())
: type(t), length(l), value(v), value2(v2), order(o), event(ev),
easing(es) {}
Op(const Op &o)
@@ -98,7 +98,7 @@ struct QmlTimeLinePrivate
qreal value2;
int order;
- QmlTimeLineEvent event;
+ QmlTimeLineCallback event;
QEasingCurve easing;
};
struct TimeLine
@@ -244,7 +244,7 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
}
case Op::Execute:
- op.event.execute();
+ op.event.d0(op.event.d1);
*changed = false;
return -1;
}
@@ -364,10 +364,10 @@ void QmlTimeLine::pause(QmlTimeLineObject &obj, int time)
/*!
Execute the \a event.
*/
-void QmlTimeLine::execute(const QmlTimeLineEvent &event)
+void QmlTimeLine::callback(const QmlTimeLineCallback &callback)
{
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, event);
- d->add(*event.eventObject(), op);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback);
+ d->add(*callback.callbackObject(), op);
}
/*!
@@ -466,7 +466,7 @@ void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int t
void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
{
if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineCallback(), easing);
d->add(timeLineValue, op);
}
@@ -488,7 +488,7 @@ void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time
void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
{
if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineCallback(), easing);
d->add(timeLineValue, op);
}
@@ -805,10 +805,11 @@ int QmlTimeLinePrivate::advance(int t)
updateQueue = &updates;
for (int ii = 0; ii < updates.count(); ++ii) {
const Update &v = updates.at(ii).second;
- if (v.g)
+ if (v.g) {
v.g->setValue(v.v);
- else
- v.e.execute();
+ } else {
+ v.e.d0(v.e.d1);
+ }
}
updateQueue = 0;
} while(t);
@@ -854,7 +855,7 @@ void QmlTimeLine::remove(QmlTimeLineObject *v)
if (d->updateQueue) {
for (int ii = 0; ii < d->updateQueue->count(); ++ii) {
if (d->updateQueue->at(ii).second.g == v ||
- d->updateQueue->at(ii).second.e.eventObject() == v) {
+ d->updateQueue->at(ii).second.e.callbackObject() == v) {
d->updateQueue->removeAt(ii);
--ii;
}
@@ -910,17 +911,22 @@ QmlTimeLineObject::~QmlTimeLineObject()
}
}
-QmlTimeLineEvent::QmlTimeLineEvent()
+QmlTimeLineCallback::QmlTimeLineCallback()
: d0(0), d1(0), d2(0)
{
}
-QmlTimeLineEvent::QmlTimeLineEvent(const QmlTimeLineEvent &o)
+QmlTimeLineCallback::QmlTimeLineCallback(QmlTimeLineObject *b, Callback f, void *d)
+: d0(f), d1(d), d2(b)
+{
+}
+
+QmlTimeLineCallback::QmlTimeLineCallback(const QmlTimeLineCallback &o)
: d0(o.d0), d1(o.d1), d2(o.d2)
{
}
-QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o)
+QmlTimeLineCallback &QmlTimeLineCallback::operator=(const QmlTimeLineCallback &o)
{
d0 = o.d0;
d1 = o.d1;
@@ -928,12 +934,7 @@ QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o)
return *this;
}
-void QmlTimeLineEvent::execute() const
-{
- d0(d1);
-}
-
-QmlTimeLineObject *QmlTimeLineEvent::eventObject() const
+QmlTimeLineObject *QmlTimeLineCallback::callbackObject() const
{
return d2;
}
diff --git a/src/declarative/util/qmltimeline_p_p.h b/src/declarative/util/qmltimeline_p_p.h
index f271a3f..076355d 100644
--- a/src/declarative/util/qmltimeline_p_p.h
+++ b/src/declarative/util/qmltimeline_p_p.h
@@ -60,10 +60,10 @@ QT_BEGIN_NAMESPACE
class QEasingCurve;
class QmlTimeLineValue;
-class QmlTimeLineEvent;
+class QmlTimeLineCallback;
struct QmlTimeLinePrivate;
class QmlTimeLineObject;
-class Q_DECLARATIVE_EXPORT QmlTimeLine : public QAbstractAnimation
+class QmlTimeLine : public QAbstractAnimation
{
Q_OBJECT
public:
@@ -75,7 +75,7 @@ public:
void setSyncMode(SyncMode);
void pause(QmlTimeLineObject &, int);
- void execute(const QmlTimeLineEvent &);
+ void callback(const QmlTimeLineCallback &);
void set(QmlTimeLineValue &, qreal);
int accel(QmlTimeLineValue &, qreal velocity, qreal accel);
@@ -117,7 +117,7 @@ private:
QmlTimeLinePrivate *d;
};
-class Q_DECLARATIVE_EXPORT QmlTimeLineObject
+class QmlTimeLineObject
{
public:
QmlTimeLineObject();
@@ -129,7 +129,7 @@ protected:
QmlTimeLine *_t;
};
-class Q_DECLARATIVE_EXPORT QmlTimeLineValue : public QmlTimeLineObject
+class QmlTimeLineValue : public QmlTimeLineObject
{
public:
QmlTimeLineValue(qreal v = 0.) : _v(v) {}
@@ -147,36 +147,21 @@ private:
qreal _v;
};
-class Q_DECLARATIVE_EXPORT QmlTimeLineEvent
+class QmlTimeLineCallback
{
public:
- QmlTimeLineEvent();
- QmlTimeLineEvent(const QmlTimeLineEvent &o);
+ typedef void (*Callback)(void *);
- template<class T, void (T::*method)()>
- static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c)
- {
- QmlTimeLineEvent rv;
- rv.d0 = &callFunc<T, method>;
- rv.d1 = (void *)c;
- rv.d2 = b;
- return rv;
- }
+ QmlTimeLineCallback();
+ QmlTimeLineCallback(QmlTimeLineObject *b, Callback, void * = 0);
+ QmlTimeLineCallback(const QmlTimeLineCallback &o);
- QmlTimeLineEvent &operator=(const QmlTimeLineEvent &o);
- void execute() const;
- QmlTimeLineObject *eventObject() const;
+ QmlTimeLineCallback &operator=(const QmlTimeLineCallback &o);
+ QmlTimeLineObject *callbackObject() const;
private:
- typedef void (*CallFunc)(void *c);
-
- template <class T, void (T::*method)()>
- static void callFunc(void *c)
- {
- T *cls = (T *)c;
- (cls->*method)();
- }
- CallFunc d0;
+ friend class QmlTimeLinePrivate;
+ Callback d0;
void *d1;
QmlTimeLineObject *d2;
};