File indexing completed on 2024-04-14 03:59:29

0001 /*
0002     SPDX-FileCopyrightText: 2008-2010 Stefan Majewsky <majewsky@gmx.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDIAMOND_DIAMOND_H
0008 #define KDIAMOND_DIAMOND_H
0009 
0010 #include <KGameRenderedGraphicsObject>
0011 
0012 namespace KDiamond
0013 {
0014 //registered colors of diamonds
0015 enum Color {
0016     NoColor = -1,  //use this if no actual color can be named (e.g. for a null Diamond pointer)
0017     Selection = 0, //actually no diamond type, but this allows to reuse the Diamond class' code for the selection marker
0018     RedDiamond = 1,
0019     GreenDiamond,
0020     BlueDiamond,
0021     YellowDiamond,
0022     WhiteDiamond,
0023     BlackDiamond,
0024     OrangeDiamond,
0025     ColorsCount
0026 };
0027 }
0028 
0029 class Diamond : public KGameRenderedGraphicsObject
0030 {
0031     Q_OBJECT
0032 public:
0033     explicit Diamond(KDiamond::Color color, KGameGraphicsViewRenderer *renderer, QGraphicsItem *parent = nullptr);
0034 
0035     KDiamond::Color color() const;
0036 Q_SIGNALS:
0037     void clicked();
0038     void dragged(const QPoint &direction);
0039 protected:
0040     void mousePressEvent(QGraphicsSceneMouseEvent *) override;
0041     void mouseMoveEvent(QGraphicsSceneMouseEvent *) override;
0042     void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
0043 private:
0044     KDiamond::Color m_color;
0045     bool m_mouseDown;
0046     QPointF m_mouseDownPos; //position of last mouse-down event in local coordinates
0047 };
0048 
0049 #endif //KDIAMOND_DIAMOND_H