File indexing completed on 2024-09-08 06:47:56
0001 /* 0002 SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef ANIMATION_H 0008 #define ANIMATION_H 0009 0010 #include <QList> 0011 #include <QObject> 0012 #include <QPoint> 0013 #include <QGraphicsItem> 0014 0015 0016 class Animation : public QObject 0017 { 0018 Q_OBJECT 0019 public: 0020 ~Animation() override; 0021 virtual void start(int t) = 0; 0022 virtual bool step(int t) = 0; 0023 0024 Q_SIGNALS: 0025 void done(); 0026 }; 0027 0028 class AnimationGroup : public Animation 0029 { 0030 Q_OBJECT 0031 typedef QList<Animation*> Animations; 0032 Animations m_animations; 0033 int m_running; 0034 public: 0035 AnimationGroup(); 0036 ~AnimationGroup() override; 0037 void start(int t) override; 0038 bool step(int t) override; 0039 virtual void stop(); 0040 0041 void add(Animation*); 0042 }; 0043 0044 class FadeAnimation : public Animation 0045 { 0046 Q_OBJECT 0047 QGraphicsItem* m_sprite; 0048 int m_from; 0049 qreal m_to; 0050 int m_time; 0051 int m_start; 0052 public: 0053 FadeAnimation(QGraphicsItem* sprite, int from, qreal to, int time); 0054 void start(int t) override; 0055 bool step(int t) override; 0056 }; 0057 0058 class MovementAnimation : public Animation 0059 { 0060 Q_OBJECT 0061 QGraphicsItem* m_sprite; 0062 QPointF m_from; 0063 QPointF m_to; 0064 int m_time; 0065 int m_start; 0066 public: 0067 MovementAnimation(QGraphicsItem* sprite, const QPointF& from, 0068 const QPointF& to, int time); 0069 void start(int t) override; 0070 bool step(int t) override; 0071 }; 0072 0073 #endif // ANIMATION_H 0074