summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-03-14 19:49:01 +1000
committerQt Continuous Integration System <qt-info@nokia.com>2011-03-14 19:49:01 +1000
commit5de30ecf4c28279fe8eed0ed8cb53504eb1350d7 (patch)
tree49af06e86b70d06ea090077f68931877c36e0ff9 /examples
parent5b6933ae8e2bb8b3ca33ef7f31ba564b4cb53bec (diff)
parentf2e723839b4067581fc2974a29aebdd41cb881f6 (diff)
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging: Fix static text item positioning GL2 paint engine Fix combining marks handling in Core Text shaper Fix PBuffer example to work again
Diffstat (limited to 'examples')
-rw-r--r--examples/opengl/pbuffers/cube.cpp49
-rw-r--r--examples/opengl/pbuffers/cube.h3
-rw-r--r--examples/opengl/pbuffers/glwidget.cpp2
3 files changed, 36 insertions, 18 deletions
diff --git a/examples/opengl/pbuffers/cube.cpp b/examples/opengl/pbuffers/cube.cpp
index 5bd35e1212..631595a2d7 100644
--- a/examples/opengl/pbuffers/cube.cpp
+++ b/examples/opengl/pbuffers/cube.cpp
@@ -46,7 +46,7 @@
static const qreal FACE_SIZE = 0.4;
-static const qreal speeds[] = { 1.8f, 2.4f, 3.6f };
+static const qreal speeds[] = { 3.8f, 4.4f, 5.6f };
static const qreal amplitudes[] = { 2.0f, 2.5f, 3.0f };
static inline void qSetColor(float colorVec[], QColor c)
@@ -197,7 +197,8 @@ Tile *TileBuilder::newTile(const QVector3D &loc) const
Cube::Cube(const QVector3D &loc)
: Tile(loc)
, rot(0.0f)
- , r(0), a(0)
+ , r(0)
+ , animGroup(0)
{
}
@@ -234,8 +235,8 @@ void Cube::setRotation(qreal r)
void Cube::removeBounce()
{
- delete a;
- a = 0;
+ delete animGroup;
+ animGroup = 0;
delete r;
r = 0;
}
@@ -247,8 +248,8 @@ void Cube::startAnimation()
r->start();
r->setCurrentTime(startx);
}
- if (a)
- a->start();
+ if (animGroup)
+ animGroup->start();
if (rtn)
rtn->start();
}
@@ -259,8 +260,8 @@ void Cube::setAnimationPaused(bool paused)
{
if (r)
r->pause();
- if (a)
- a->pause();
+ if (animGroup)
+ animGroup->pause();
if (rtn)
rtn->pause();
}
@@ -268,8 +269,8 @@ void Cube::setAnimationPaused(bool paused)
{
if (r)
r->resume();
- if (a)
- a->resume();
+ if (animGroup)
+ animGroup->resume();
if (rtn)
rtn->resume();
}
@@ -312,13 +313,29 @@ Cube *CubeBuilder::newCube(const QVector3D &loc) const
c->r->setDuration(d * 4.0f);
c->r->setLoopCount(-1);
c->r->setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve));
+
+ c->animGroup = new QSequentialAnimationGroup(c);
+
// Animate movement from bottom to top
- c->a = new QPropertyAnimation(c, "altitude");
- c->a->setEndValue(loc.y());
- c->a->setStartValue(loc.y() + amplitudes[ix]);
- c->a->setDuration(d / speeds[ix]);
- c->a->setLoopCount(-1);
- c->a->setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve));
+ QPropertyAnimation *a_up = new QPropertyAnimation(c, "altitude", c->animGroup);
+ a_up->setEndValue(loc.y());
+ a_up->setStartValue(loc.y() + amplitudes[ix]);
+ a_up->setDuration(d / speeds[ix]);
+ a_up->setLoopCount(1);
+ a_up->setEasingCurve(QEasingCurve(QEasingCurve::InQuad));
+
+ // Animate movement from top to bottom
+ QPropertyAnimation *a_down = new QPropertyAnimation(c, "altitude", c->animGroup);
+ a_down->setEndValue(loc.y() + amplitudes[ix]);
+ a_down->setStartValue(loc.y());
+ a_down->setDuration(d / speeds[ix]);
+ a_down->setLoopCount(1);
+ a_down->setEasingCurve(QEasingCurve(QEasingCurve::OutQuad));
+
+ c->animGroup->addAnimation(a_up);
+ c->animGroup->addAnimation(a_down);
+ c->animGroup->setLoopCount(-1);
+
// Animate rotation
c->rtn = new QPropertyAnimation(c, "rotation");
c->rtn->setStartValue(c->rot);
diff --git a/examples/opengl/pbuffers/cube.h b/examples/opengl/pbuffers/cube.h
index 2577e765d3..5c985a3782 100644
--- a/examples/opengl/pbuffers/cube.h
+++ b/examples/opengl/pbuffers/cube.h
@@ -43,6 +43,7 @@
#include <QtOpenGL/qgl.h>
#include <QtCore/qvector.h>
+#include <QtCore/qsequentialanimationgroup.h>
#include <QtGui/qmatrix4x4.h>
#include <QtGui/qvector3d.h>
#include <QtGui/qvector2d.h>
@@ -130,8 +131,8 @@ signals:
private:
qreal rot;
QPropertyAnimation *r;
- QPropertyAnimation *a;
QPropertyAnimation *rtn;
+ QSequentialAnimationGroup *animGroup;
qreal startx;
friend class CubeBuilder;
};
diff --git a/examples/opengl/pbuffers/glwidget.cpp b/examples/opengl/pbuffers/glwidget.cpp
index 930cbc8920..f6f89e5a0e 100644
--- a/examples/opengl/pbuffers/glwidget.cpp
+++ b/examples/opengl/pbuffers/glwidget.cpp
@@ -135,7 +135,7 @@ void GLWidget::initializeGeometry()
CubeBuilder cBuilder(geom, 0.5);
cBuilder.setColor(QColor(255, 255, 255, 212));
// build the 3 bouncing, spinning cubes
- for (int i = 0; i < 3; ++i)
+ for (int i = 3; i > 0; --i)
cubes.append(cBuilder.newCube(QVector3D((float)(i-1), -1.5f, 5 - i)));
// build the spinning cube which goes in the dynamic texture