1 /*
2     SPDX-FileCopyrightText: 2008-2010 Stefan Majewsky <majewsky@gmx.net>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #ifndef KDIAMOND_DIAMOND_H
8 #define KDIAMOND_DIAMOND_H
9 
10 #include <KGameRenderedObjectItem>
11 
12 namespace KDiamond
13 {
14 //registered colors of diamonds
15 enum Color {
16     NoColor = -1,  //use this if no actual color can be named (e.g. for a null Diamond pointer)
17     Selection = 0, //actually no diamond type, but this allows to reuse the Diamond class' code for the selection marker
18     RedDiamond = 1,
19     GreenDiamond,
20     BlueDiamond,
21     YellowDiamond,
22     WhiteDiamond,
23     BlackDiamond,
24     OrangeDiamond,
25     ColorsCount
26 };
27 }
28 
29 class Diamond : public KGameRenderedObjectItem
30 {
31     Q_OBJECT
32 public:
33     explicit Diamond(KDiamond::Color color, KGameRenderer *renderer, QGraphicsItem *parent = nullptr);
34 
35     KDiamond::Color color() const;
36 Q_SIGNALS:
37     void clicked();
38     void dragged(const QPoint &direction);
39 protected:
40     void mousePressEvent(QGraphicsSceneMouseEvent *) override;
41     void mouseMoveEvent(QGraphicsSceneMouseEvent *) override;
42     void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
43 private:
44     KDiamond::Color m_color;
45     bool m_mouseDown;
46     QPointF m_mouseDownPos; //position of last mouse-down event in local coordinates
47 };
48 
49 #endif //KDIAMOND_DIAMOND_H
50