00001 /* Copyright (C) 2009 Väinö Lappi <djap84@gmail.com> 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 00017 */ 00018 #ifndef FLOATINGCLOUDS_H 00019 #define FLOATINGCLOUDS_H 00020 // 00021 #include <QThread> 00022 #include <QMutex> 00023 #include <QGraphicsScene> 00024 #include <QPixmap> 00025 #include <QGraphicsPixmapItem> 00026 #include "AnimationEngineAPI.h" 00027 00032 #define CLOUD_AMMOUNT 10 00033 00034 00039 class floatingClouds : public QThread, public AnimationEngineAPI 00040 { 00041 Q_OBJECT 00042 public: 00043 floatingClouds(); 00044 virtual ~floatingClouds(); 00045 00055 void startAnimation(QGraphicsScene *targetGraphicsScene); 00056 00065 void startAnimationPreview(QGraphicsScene *targetGraphicsScene); 00066 00073 void stopAndCleanUp(); 00074 QString getAnimationName(); 00075 QString getAnimationBg(); 00076 protected: 00083 void run(); 00084 private: 00085 //clouds 00090 QPixmap* iCloudPixmap; 00091 00096 QGraphicsPixmapItem* iCloud[CLOUD_AMMOUNT]; 00097 00102 float iCloudXLocation[CLOUD_AMMOUNT]; 00103 00108 float iCloudSpeed[CLOUD_AMMOUNT]; 00109 00114 QGraphicsScene* iTargetScene; 00115 00120 QMutex iRunningMux; //just to keep track when thread is running. 00121 00126 QMutex iCloudLocationMux; 00127 private slots: 00128 /* 00129 * Routing graphics updates through Qts signaling queue so they will be handled by the GUI thread 00130 */ 00138 void updateGraphics(); 00139 signals: 00147 void sigUpdateGraphics(); 00148 }; 00149 #endif