00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MOUSEFOLLOWERTEST_H
00019 #define MOUSEFOLLOWERTEST_H
00020
00021 #include <QThread>
00022 #include <QMutex>
00023 #include <QGraphicsScene>
00024 #include <QPixmap>
00025 #include <QGraphicsPixmapItem>
00026 #include <QGraphicsTextItem>
00027 #include "AnimationEngineAPI.h"
00028
00029 #define RUNNING_SPEED 20.0
00030 #define ANIMATION_SPEED 100 //delay between frames in ms's (lower = faster)
00031 #define RUNNING_ANIMATION_FRAMES 8
00032 #define COLLITION_ANIMATION_FRAMES 5
00033
00034
00035 class mouseFollowerTest : public QThread, public AnimationEngineAPI
00036 {
00037 Q_OBJECT
00038 public:
00039 mouseFollowerTest();
00040 virtual ~mouseFollowerTest();
00041 void startAnimation(QGraphicsScene *targetGraphicsScene);
00042 void startAnimationPreview(QGraphicsScene *targetGraphicsScene);
00043
00044
00045 void stopAndCleanUp();
00046
00047 QString getAnimationName();
00048 QString getAnimationBg();
00049 void refreshMouseCoordinates(int x, int y);
00050 protected:
00051 void run();
00052 private:
00053
00054 QPixmap* iFollowerPixmap;
00055 QPixmap* iFollowerEmptyPixmap;
00056 QPixmap* iFollowerChaserLPixmap[RUNNING_ANIMATION_FRAMES];
00057 QPixmap* iFollowerChaserRPixmap[RUNNING_ANIMATION_FRAMES];
00058 QPixmap* iCollitionPixmap[COLLITION_ANIMATION_FRAMES];
00059 QGraphicsPixmapItem* iMouseFollower;
00060 QGraphicsPixmapItem* iMouseFollowerChaser;
00061 unsigned char iAnimIndex;
00062 char iAnimDirection;
00063 bool iFirstCollition;
00064 bool iTimerReady;
00065 bool iStarted;
00066 QGraphicsScene* iTargetScene;
00067 QMutex iRunningMux;
00068 QGraphicsTextItem *iPreviewMsg;
00069 private slots:
00070
00071
00072
00073 void updateGraphics();
00074 signals:
00075 void sigUpdateGraphics();
00076 };
00077 #endif