summaryrefslogtreecommitdiffstats
path: root/examples/animation
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-05-05 16:17:43 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-05-05 16:17:43 (GMT)
commit2e0430832d3656753f73b09765769d10aa51add3 (patch)
tree04c9fa068c57b90de15ebd01831a0e140b2b8e6c /examples/animation
parent6eae8aedd14acbc4ea73f336124b0243e9ebb9c0 (diff)
downloadQt-2e0430832d3656753f73b09765769d10aa51add3.zip
Qt-2e0430832d3656753f73b09765769d10aa51add3.tar.gz
Qt-2e0430832d3656753f73b09765769d10aa51add3.tar.bz2
add event as argument to onEntry(), onExit() and onTransition()
Accessing the event can be useful. E.g., onEntry() can do some common event processing regardless of which transition caused the state to be entered; onTransition() can be used in combination with eventTest(), where eventTest() would first check that the input matches some criteria, and then the actual processing of that input would be done in onTransition.
Diffstat (limited to 'examples/animation')
-rw-r--r--examples/animation/moveblocks/main.cpp6
-rw-r--r--examples/animation/sub-attaq/boat_p.h12
-rw-r--r--examples/animation/sub-attaq/qanimationstate.cpp4
-rw-r--r--examples/animation/sub-attaq/qanimationstate.h4
-rw-r--r--examples/animation/sub-attaq/states.cpp16
-rw-r--r--examples/animation/sub-attaq/states.h14
-rw-r--r--examples/animation/sub-attaq/submarine_p.h12
7 files changed, 34 insertions, 34 deletions
diff --git a/examples/animation/moveblocks/main.cpp b/examples/animation/moveblocks/main.cpp
index eb23bd5..06ed3dd 100644
--- a/examples/animation/moveblocks/main.cpp
+++ b/examples/animation/moveblocks/main.cpp
@@ -101,7 +101,7 @@ protected:
&& (static_cast<StateSwitchEvent *>(event)->rand() == m_rand);
}
- virtual void onTransition() {}
+ virtual void onTransition(QEvent *) {}
private:
int m_rand;
@@ -116,7 +116,7 @@ public:
m_stateCount(0), m_lastIndex(0)
{ }
- virtual void onEntry()
+ virtual void onEntry(QEvent *)
{
int n;
while ((n = (qrand() % m_stateCount + 1)) == m_lastIndex)
@@ -124,7 +124,7 @@ public:
m_lastIndex = n;
m_machine->postEvent(new StateSwitchEvent(n));
}
- virtual void onExit() {}
+ virtual void onExit(QEvent *) {}
void addState(QState *state, QAbstractAnimation *animation) {
StateSwitchTransition *trans = new StateSwitchTransition(++m_stateCount);
diff --git a/examples/animation/sub-attaq/boat_p.h b/examples/animation/sub-attaq/boat_p.h
index 855b10f..17fbe5c 100644
--- a/examples/animation/sub-attaq/boat_p.h
+++ b/examples/animation/sub-attaq/boat_p.h
@@ -104,7 +104,7 @@ protected:
return false;
}
- void onTransition()
+ void onTransition(QEvent *)
{
//We decrease the speed if needed
if (key == Qt::Key_Left && boat->currentDirection() == Boat::Right)
@@ -156,7 +156,7 @@ public:
this->boat = boat;
}
protected:
- void onEntry()
+ void onEntry(QEvent *)
{
boat->setCurrentDirection(Boat::Right);
boat->updateBoatMovement();
@@ -174,7 +174,7 @@ public:
this->boat = boat;
}
protected:
- void onEntry()
+ void onEntry(QEvent *)
{
boat->setCurrentDirection(Boat::Left);
boat->updateBoatMovement();
@@ -192,7 +192,7 @@ public:
this->boat = boat;
}
protected:
- void onEntry()
+ void onEntry(QEvent *)
{
boat->setCurrentSpeed(0);
boat->setCurrentDirection(Boat::None);
@@ -211,7 +211,7 @@ public:
this->boat = boat;
}
protected:
- void onEntry()
+ void onEntry(QEvent *)
{
Bomb *b = new Bomb();
b->setPos(boat->x()+boat->size().width(),boat->y());
@@ -233,7 +233,7 @@ public:
this->boat = boat;
}
protected:
- void onEntry()
+ void onEntry(QEvent *)
{
Bomb *b = new Bomb();
b->setPos(boat->x() - b->size().width(), boat->y());
diff --git a/examples/animation/sub-attaq/qanimationstate.cpp b/examples/animation/sub-attaq/qanimationstate.cpp
index 3659657..0f30ac2 100644
--- a/examples/animation/sub-attaq/qanimationstate.cpp
+++ b/examples/animation/sub-attaq/qanimationstate.cpp
@@ -146,7 +146,7 @@ QAbstractAnimation* QAnimationState::animation() const
/*!
\reimp
*/
-void QAnimationState::onEntry()
+void QAnimationState::onEntry(QEvent *)
{
Q_D(QAnimationState);
if (d->animation)
@@ -156,7 +156,7 @@ void QAnimationState::onEntry()
/*!
\reimp
*/
-void QAnimationState::onExit()
+void QAnimationState::onExit(QEvent *)
{
Q_D(QAnimationState);
if (d->animation)
diff --git a/examples/animation/sub-attaq/qanimationstate.h b/examples/animation/sub-attaq/qanimationstate.h
index ddf5681..88c0a6d 100644
--- a/examples/animation/sub-attaq/qanimationstate.h
+++ b/examples/animation/sub-attaq/qanimationstate.h
@@ -74,8 +74,8 @@ Q_SIGNALS:
void animationFinished();
protected:
- void onEntry();
- void onExit();
+ void onEntry(QEvent *);
+ void onExit(QEvent *);
bool event(QEvent *e);
private:
diff --git a/examples/animation/sub-attaq/states.cpp b/examples/animation/sub-attaq/states.cpp
index 0b98016..c6af924 100644
--- a/examples/animation/sub-attaq/states.cpp
+++ b/examples/animation/sub-attaq/states.cpp
@@ -76,7 +76,7 @@ PlayState::~PlayState()
{
}
-void PlayState::onEntry()
+void PlayState::onEntry(QEvent *)
{
//We are now playing?
if (machine) {
@@ -159,7 +159,7 @@ void PlayState::onEntry()
LevelState::LevelState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game)
{
}
-void LevelState::onEntry()
+void LevelState::onEntry(QEvent *)
{
initializeLevel();
}
@@ -202,12 +202,12 @@ void LevelState::initializeLevel()
PauseState::PauseState(GraphicsScene *scene, QState *parent) : QState(parent),scene(scene)
{
}
-void PauseState::onEntry()
+void PauseState::onEntry(QEvent *)
{
AnimationManager::self()->pauseAll();
scene->boat->setEnabled(false);
}
-void PauseState::onExit()
+void PauseState::onExit(QEvent *)
{
AnimationManager::self()->resumeAll();
scene->boat->setEnabled(true);
@@ -219,7 +219,7 @@ LostState::LostState(GraphicsScene *scene, PlayState *game, QState *parent) : QS
{
}
-void LostState::onEntry()
+void LostState::onEntry(QEvent *)
{
//The message to display
QString message = QString("You lose on level %1. Your score is %2.").arg(game->currentLevel+1).arg(game->score);
@@ -242,7 +242,7 @@ WinState::WinState(GraphicsScene *scene, PlayState *game, QState *parent) : QSta
{
}
-void WinState::onEntry()
+void WinState::onEntry(QEvent *)
{
//We clear the scene
scene->clearScene();
@@ -269,9 +269,9 @@ UpdateScoreState::UpdateScoreState(PlayState *game, QState *parent) : QState(par
{
this->game = game;
}
-void UpdateScoreState::onEntry()
+void UpdateScoreState::onEntry(QEvent *e)
{
- QState::onEntry();
+ QState::onEntry(e);
}
/** Win transition */
diff --git a/examples/animation/sub-attaq/states.h b/examples/animation/sub-attaq/states.h
index ec69ae7..27beb71 100644
--- a/examples/animation/sub-attaq/states.h
+++ b/examples/animation/sub-attaq/states.h
@@ -68,7 +68,7 @@ public:
~PlayState();
protected:
- void onEntry();
+ void onEntry(QEvent *);
private :
GraphicsScene *scene;
@@ -91,7 +91,7 @@ class LevelState : public QState
public:
LevelState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
protected:
- void onEntry();
+ void onEntry(QEvent *);
private :
void initializeLevel();
GraphicsScene *scene;
@@ -104,8 +104,8 @@ public:
PauseState(GraphicsScene *scene, QState *parent = 0);
protected:
- void onEntry();
- void onExit();
+ void onEntry(QEvent *);
+ void onExit(QEvent *);
private :
GraphicsScene *scene;
Boat *boat;
@@ -117,7 +117,7 @@ public:
LostState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
protected:
- void onEntry();
+ void onEntry(QEvent *);
private :
GraphicsScene *scene;
PlayState *game;
@@ -129,7 +129,7 @@ public:
WinState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
protected:
- void onEntry();
+ void onEntry(QEvent *);
private :
GraphicsScene *scene;
PlayState *game;
@@ -140,7 +140,7 @@ class UpdateScoreState : public QState
public:
UpdateScoreState(PlayState *game, QState *parent);
protected:
- void onEntry();
+ void onEntry(QEvent *);
private:
QPropertyAnimation *scoreAnimation;
PlayState *game;
diff --git a/examples/animation/sub-attaq/submarine_p.h b/examples/animation/sub-attaq/submarine_p.h
index 918e7f5..c76d991 100644
--- a/examples/animation/sub-attaq/submarine_p.h
+++ b/examples/animation/sub-attaq/submarine_p.h
@@ -77,7 +77,7 @@ protected slots:
}
protected:
- void onEntry()
+ void onEntry(QEvent *e)
{
if (submarine->currentDirection() == SubMarine::Left) {
movementAnimation->setEndValue(QPointF(0,submarine->y()));
@@ -88,7 +88,7 @@ protected:
movementAnimation->setDuration((submarine->scene()->width()-submarine->size().width()-submarine->x())/submarine->currentSpeed()*12);
}
movementAnimation->setStartValue(submarine->pos());
- QAnimationState::onEntry();
+ QAnimationState::onEntry(e);
}
private:
@@ -109,19 +109,19 @@ public:
}
protected:
- void onEntry()
+ void onEntry(QEvent *e)
{
returnAnimation->stop();
returnAnimation->setStartValue(submarine->yRotation());
returnAnimation->setEndValue(submarine->currentDirection() == SubMarine::Right ? 360. : 180.);
returnAnimation->setDuration(500);
- QAnimationState::onEntry();
+ QAnimationState::onEntry(e);
}
- void onExit()
+ void onExit(QEvent *e)
{
submarine->currentDirection() == SubMarine::Right ? submarine->setCurrentDirection(SubMarine::Left) : submarine->setCurrentDirection(SubMarine::Right);
- QAnimationState::onExit();
+ QAnimationState::onExit(e);
}
private: