-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tile-viewer.h
92 lines (72 loc) · 1.63 KB
/
tile-viewer.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
#ifndef TILE_VIEWER_H
#define TILE_VIEWER_H
#include <functional>
#include <QColor>
#include <QObject>
#include <QTimer>
#include <QVector>
#include <QWidget>
#include "tile-manager.h"
class TileViewer : public QWidget
{
Q_OBJECT
public:
TileViewer(const TileManager &tile_manager);
void setBackgroundColour(const QColor &colour)
{
background_colour = colour;
update();
}
int paletteLine() const
{
return palette_line;
}
void setPaletteLine(const int palette_line)
{
this->palette_line = palette_line;
update();
}
void clearSelection()
{
selected.fill(false);
}
const QVector<bool>& selection() const
{
return selected;
}
void setSelection(bool scroll_to_selection, const std::function<void(QVector<bool> &selection)> &callback);
int scroll() const
{
return m_scroll;
}
void setScroll(const int scroll)
{
m_scroll = qBound(0, scroll, tile_manager.total_tiles() - 1);
update();
}
bool verticalOrientation() const
{
return vertical_orientation;
}
void setVerticalOrientation(const bool enabled)
{
vertical_orientation = enabled;
update();
}
void getGridDimensions(int &width, int &height);
signals:
void tileSelected(int tile);
private:
void deleteButtons();
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
const TileManager &tile_manager;
QColor background_colour;
QTimer timer;
QVector<bool> selected;
bool selection_flip_flop = false;
int palette_line = 0;
int m_scroll = 0;
bool vertical_orientation = false;
};
#endif // TILE_VIEWER_H