-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamecanvas.h
34 lines (23 loc) · 761 Bytes
/
gamecanvas.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef GAMECANVAS_H
#define GAMECANVAS_H
#include <QWidget>
#include "game.h"
class GameCanvas : public QWidget
{
Q_OBJECT
private:
const static QColor portalColors[];
const Game *game{};
std::function<void(int, int, bool)> onMouseSelect;
public:
explicit GameCanvas(QWidget *parent = nullptr) : QWidget(parent) {};
void SetGame(const Game *_game);
void SetOnMouseSelect(std::function<void(int, int, bool)>);
public slots:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
private:
void CalculateBlockSizeAndOffset(int &blockSize, int &row, int &col, int &xOffset, int &yOffset) const;
};
#endif // GAMECANVAS_H