File indexing completed on 2024-04-21 04:02:05

0001 /******************************************************************************
0002 *   KBlocks, a falling blocks game by KDE                                     *
0003 *   SPDX-FileCopyrightText: 2009-2021 Mauricio Piacentini <mauricio@tabuleiro.com>      *
0004 *                           Zhongjie Cai <squall.leonhart.cai@gmail.com>      *
0005 *                           Julian Helfferich <julian.helfferich@mailbox.org> *
0006 *                                                                             *
0007 *   SPDX-License-Identifier: GPL-2.0-or-later
0008 ******************************************************************************/
0009 #ifndef KBLOCKSANIMATOR_H
0010 #define KBLOCKSANIMATOR_H
0011 
0012 #include <QTimeLine>
0013 
0014 #include "KBlocksAnimFade.h"
0015 #include "KBlocksAnimDrop.h"
0016 
0017 class SvgItemInterface;
0018 
0019 enum KBlocks_Animation_Type {
0020     KBlocks_Animation_None = 0,
0021     KBlocks_Animation_Fade_In,
0022     KBlocks_Animation_Fade_Out,
0023     KBlocks_Animation_Drop,
0024     KBlocks_Animation_Max_Count
0025 };
0026 
0027 class KBlocksAnimator : public QObject
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     KBlocksAnimator();
0033     ~KBlocksAnimator() override;
0034 
0035     bool createFadeAnim(const QList<SvgItemInterface *> &items, int duration, QTimeLine::Direction direction);
0036     bool deleteFadeAnim();
0037     KBlocksAnimFade *getFadeAnim();
0038 
0039     bool createDropAnim(const QList<SvgItemInterface *> &items, int duration, QTimeLine::Direction direction);
0040     bool deleteDropAnim();
0041     KBlocksAnimDrop *getDropAnim();
0042 
0043 private Q_SLOTS:
0044     void endFadeInAnim();
0045     void endFadeOutAnim();
0046     void endDropAnim();
0047 
0048 Q_SIGNALS:
0049     void animFinished(int animType);
0050 
0051 protected:
0052     KBlocksAnimFade *mpAnimFade = nullptr;
0053     KBlocksAnimDrop *mpAnimDrop = nullptr;
0054 };
0055 
0056 #endif