| 1 | // This file is part of Dust Racing 2D. |
| 2 | // Copyright (C) 2013 Jussi Lind <[email protected]> |
| 3 | // |
| 4 | // Dust Racing 2D is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // Dust Racing 2D is distributed in the hope that it will be useful, |
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | // GNU General Public License for more details. |
| 12 | // |
| 13 | // You should have received a copy of the GNU General Public License |
| 14 | // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>. |
| 15 | |
| 16 | #ifndef FADEANIMATION_HPP |
| 17 | #define FADEANIMATION_HPP |
| 18 | |
| 19 | #include <QObject> |
| 20 | #include <QTimer> |
| 21 | |
| 22 | class FadeAnimation : public QObject |
| 23 | { |
| 24 | Q_OBJECT |
| 25 | |
| 26 | public: |
| 27 | explicit FadeAnimation(int updateFps = 60); |
| 28 | |
| 29 | bool isFading() const; |
| 30 | |
| 31 | signals: |
| 32 | |
| 33 | void fadeInFinished(); |
| 34 | |
| 35 | void fadeOutFinished(); |
| 36 | |
| 37 | void fadeValueChanged(float); |
| 38 | |
| 39 | public slots: |
| 40 | |
| 41 | void beginFadeIn(int preDelayMSec, int msec, int postDelayMSec); |
| 42 | |
| 43 | void beginFadeOut(int preDelayMSec, int msec, int postDelayMSec); |
| 44 | |
| 45 | void beginFadeOutFlash(int preDelayMSec, int msec, int postDelayMSec); |
| 46 | |
| 47 | private slots: |
| 48 | |
| 49 | void updateAnimation(); |
| 50 | |
| 51 | private: |
| 52 | QTimer m_timer; |
| 53 | float m_updateFps; |
| 54 | float m_fadeValue; |
| 55 | float m_step; |
| 56 | int m_preDelayMSec; |
| 57 | int m_postDelayMSec; |
| 58 | bool m_fadeIn; |
| 59 | }; |
| 60 | |
| 61 | #endif // FADEANIMATION_HPP |