1/*******************************************************************
2 *
3 * Copyright 2006 Dmitry Suzdalev <dimsuz@gmail.com>
4 *
5 * This file is part of the KDE project "KLines"
6 *
7 * KLines is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * KLines is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with KLines; see the file COPYING. If not, write to
19 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 ********************************************************************/
23#ifndef BALL_ITEM_H
24#define BALL_ITEM_H
25
26#include <KGameRenderedItem>
27#include <QTimeLine>
28
29#include "commondefs.h"
30
31/**
32 * KGameRenderedItem for Ball
33 */
34class BallItem : public QObject, public KGameRenderedItem
35{
36 Q_OBJECT
37public:
38 explicit BallItem( QGraphicsScene* parent );
39 /**
40 * Sets ball's color
41 * @param setPix specifies whether to set corresponding ball pixmap to this
42 * item. In rare cases this may not be needed.
43 * (for example when the ball is created and born animation is played immediately)
44 */
45 void setColor( BallColor c, bool setPix = true );
46 /**
47 * @return color of the ball
48 */
49 BallColor color() const { return m_color; }
50 /**
51 * Starts "Selected" animation
52 */
53 void startSelectedAnimation();
54 /**
55 * Interrupts animation
56 */
57 void stopAnimation();
58
59 // enable use of qgraphicsitem_cast
60 enum { Type = UserType + 1 };
61 virtual int type() const { return Type; }
62private slots:
63 void animFrameChanged(int);
64private:
65 /**
66 * Timeline for controlling animations
67 */
68 QTimeLine m_timeLine;
69 /**
70 * Color of the ball
71 */
72 BallColor m_color;
73};
74
75#endif
76