-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SurfaceCell.h
116 lines (77 loc) · 3.06 KB
/
SurfaceCell.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* QtSssSNibblers: SwissalpS Nibbles written with Qt-Framework
* Copyright (C) 2018-2019 Luke J. Zimmermann aka SwissalpS <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SURFACECELL_H
#define SURFACECELL_H
#include <QFrame>
#include <QTimer>
#include "Lingo.h"
namespace Ui {
class SurfaceCell;
} // namespace Ui
namespace SwissalpS { namespace QtNibblers {
class SurfaceCell : public QFrame {
Q_OBJECT
private:
Ui::SurfaceCell *pUi;
QTimer *pTimer;
protected:
bool bBuilder;
quint8 ubState; // L::Tiles
quint8 ubStateFrozen;
quint8 ubColumn;
quint8 ubRow;
QVector<L::Heading> aeHeadingsBloated;
void changeEvent(QEvent *pEvent);
QColor colour() const;
virtual void mouseReleaseEvent(QMouseEvent *pEvent);
virtual void paintEvent(QPaintEvent *pEvent);
protected slots:
virtual void onDesnakeTimer();
public:
explicit SurfaceCell(QWidget *pParent = nullptr);
explicit SurfaceCell(bool bBuilder, quint8 ubState,
quint8 ubColumn, quint8 ubRow, QWidget *pParent = nullptr);
~SurfaceCell();
inline virtual void addBloatedHeading(const L::Heading eHeading) {
this->aeHeadingsBloated.append(eHeading); }
virtual void defrostState();
virtual void desnakeState();
inline virtual void freezeState() { this->ubStateFrozen = this->ubState; }
inline virtual quint8 getColumn() const { return this->ubColumn; }
inline virtual QPoint getPos() const { return QPoint(this->ubColumn, this->ubRow); }
inline virtual quint8 getRow() const { return this->ubRow; }
inline virtual quint8 getState() const { return this->ubState; }
inline virtual quint8 getStateFrozen() const { return this->ubStateFrozen; }
inline virtual bool isNull() const { return nullptr == this->pUi; }
inline virtual void setState(const quint8 ubState) {
this->ubState = ubState; this->onChanged(); }
bool operator ==(SurfaceCell *pOther) const;
signals:
void changed(const QPoint oPoint, const quint8 ubState) const;
void clicked(const quint8 ubColumn, const quint8 ubRow, bool bShift,
SurfaceCell *pCell);
void debugMessage(const QString &sMessage) const;
public slots:
inline void onChanged() const {
Q_EMIT this->changed(this->getPos(), this->ubState); }
inline void onDebugMessage(const QString &sMessage) const {
Q_EMIT this->debugMessage("SurfaceCell:" + sMessage); }
inline void onTrailChanged(const int iValue) { this->pTimer->setInterval(iValue); }
}; // SurfaceCell
} } // namespace SwissalpS::QtNibblers
#endif // SURFACECELL_H