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

0001 /******************************************************************************
0002 *   KBlocks, a falling blocks game by KDE                                     *
0003 *   SPDX-FileCopyrightText: 2010-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 KBLOCKSSVGITEM_H
0010 #define KBLOCKSSVGITEM_H
0011 
0012 #include <QGraphicsPixmapItem>
0013 
0014 #include "KBlocksLayout.h"
0015 #include "SvgItemInterface.h"
0016 
0017 enum KBlocks_SvgItem_Type {
0018     KBlocksSvgItem_None = -1,
0019     KBlocksSvgItem_FieldArea = 0,
0020     KBlocksSvgItem_PrepareArea,
0021     KBlocksSvgItem_Max_Count
0022 };
0023 
0024 class KBlocksSvgItem : public SvgItemInterface
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     KBlocksSvgItem(KBlocksLayout *p, int type, int posX, int posY);
0030     ~KBlocksSvgItem() override;
0031 
0032     void setLayoutPos(int posX, int posY);
0033 
0034     bool updateSelf() override;
0035     void clearCache() override;
0036 
0037     void startOpAnim() override;
0038     void stopOpAnim() override;
0039 
0040     void startPosAnim(QPointF target) override;
0041     void execPosAnim(qreal step) override;
0042     void stopPosAnim() override;
0043 
0044 private:
0045     KBlocksLayout *mpGameLayout;
0046 
0047     int mPosX;
0048     int mPosY;
0049 
0050     int mType;
0051     int mColor;
0052 
0053     QPointF mOriginPos;
0054     QPointF mTargetPos;
0055 };
0056 
0057 #endif
0058