~ubuntu-branches/ubuntu/raring/kigo/raring

« back to all changes in this revision

Viewing changes to src/gui/graphicsview/gamescene.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-12-07 17:54:56 UTC
  • Revision ID: package-import@ubuntu.com-20121207175456-roe8z9z0jef97oo9
Tags: upstream-4.9.90
ImportĀ upstreamĀ versionĀ 4.9.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright 2008 Sascha Peilicke <sasch.pe@gmx.de>
 
3
 
 
4
    This program is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU General Public License as
 
6
    published by the Free Software Foundation; either version 2 of
 
7
    the License or (at your option) version 3 or any later version
 
8
    accepted by the membership of KDE e.V. (or its successor approved
 
9
    by the membership of KDE e.V.), which shall act as a proxy
 
10
    defined in Section 14 of version 3 of the license.
 
11
 
 
12
    This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*/
 
20
 
 
21
#ifndef KIGO_GAMESCENE_H
 
22
#define KIGO_GAMESCENE_H
 
23
 
 
24
#include <KGamePopupItem>
 
25
 
 
26
#include <QGraphicsScene>
 
27
 
 
28
namespace Kigo {
 
29
 
 
30
class Game;
 
31
 
 
32
/**
 
33
 * This class provides a graphical representation of the go game using
 
34
 * QGraphicsScene.
 
35
 *
 
36
 * It displays the go board in its current state, receives mouse events,
 
37
 * translates them and interacts with the Game. It also drives the game
 
38
 * flow, i.e. tells game when to make the next move.
 
39
 *
 
40
 * @author Sascha Peilicke <sasch.pe@gmx.de>
 
41
 * @since 0.1
 
42
 */
 
43
class GameScene : public QGraphicsScene
 
44
{
 
45
    Q_OBJECT
 
46
 
 
47
public:
 
48
    explicit GameScene(Game *game, QObject *parent = 0);
 
49
 
 
50
signals:
 
51
    void cursorPixmapChanged(const QPixmap &);
 
52
 
 
53
public slots:
 
54
    void resizeScene(int width, int height);
 
55
    void showLabels(bool show);
 
56
    void showHint(bool show);
 
57
    void showMoveNumbers(bool show);
 
58
    void showMessage(const QString &message, int msecs = 2000);
 
59
    void showPlacementMarker(bool show);
 
60
    void showTerritory(bool show);
 
61
 
 
62
private slots:
 
63
    void updateStoneItems();
 
64
    void updateHintItems();
 
65
    void updateTerritoryItems();
 
66
    void changeBoardSize(int size);
 
67
    void hideHint() { showHint(false); }
 
68
    void themeChanged();
 
69
 
 
70
private:
 
71
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
 
72
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
 
73
    void drawBackground(QPainter *painter, const QRectF &);
 
74
 
 
75
    Game *m_game;                           ///< Go game
 
76
 
 
77
    KGamePopupItem m_gamePopup;
 
78
    bool m_showLabels;                      ///< Show board labels or not
 
79
    bool m_showHint;
 
80
    bool m_showMoveNumbers;
 
81
    bool m_showPlacementMarker;
 
82
    bool m_showTerritory;
 
83
    QRectF m_boardRect;                     ///< Position of board in the scene
 
84
    QRectF m_mouseRect;                     ///< Board mouse interaction rect
 
85
    QRectF m_gridRect;                      ///< Board grid rect
 
86
    int m_cellSize;                         ///< Width of board grid cell
 
87
    QSize m_stonePixmapSize;                ///< Size of Go stone pixmap
 
88
    QSize m_placementMarkerPixmapSize;
 
89
    int m_boardSize;                        ///< Go board size (9, 13, 19, ..)
 
90
    QGraphicsPixmapItem *m_placementMarkerItem;
 
91
 
 
92
    QList<QGraphicsPixmapItem *> m_stoneItems;
 
93
    QList<QGraphicsPixmapItem *> m_hintItems;
 
94
    QList<QGraphicsPixmapItem *> m_territoryItems;
 
95
};
 
96
 
 
97
} // End of namespace Kigo
 
98
 
 
99
#endif