-
Notifications
You must be signed in to change notification settings - Fork 1
/
tileview.h
64 lines (52 loc) · 1.61 KB
/
tileview.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
#ifndef TILEVIEW_H
#define TILEVIEW_H
#include <QWidget>
#include <QList>
#include <QVector>
#include <QMap>
#include "abstracttile.h"
#include "colormap.h"
class TileView : public QWidget
{
Q_OBJECT
public:
TileView(QWidget *parent = 0);
virtual ~TileView();
virtual void clear();
virtual void add(const AbstractTile& block);
virtual void set(int index, const AbstractTile& block);
int addColorMap(const ColorMap& map);
void setColorMap(int index, const ColorMap& map);
ColorMap colorMap(int index) const;
ColorMap itemColorMap(int index) const;
void setSelected(int index);
int selected() const;
virtual int itemX(int index) const;
virtual int itemY(int index) const;
virtual int itemIndex(int x, int y) const;
void setBackground(QRgb color);
static constexpr int TILE_SIZE = 32;
static constexpr int TILE_SPACE = 1;
static constexpr int TILE_PITCH = TILE_SIZE+TILE_SPACE;
static constexpr int TILE_OUTER_SIZE = TILE_SIZE+2*TILE_SPACE;
signals:
void selectionChanged(int index);
protected:
virtual void resizeEvent(QResizeEvent*);
virtual void paintEvent(QPaintEvent*);
virtual void mousePressEvent(QMouseEvent*);
QList<AbstractTile> _tiles;
QVector<ColorMap> _colorMaps;
QMap<int,int> _colorMapMap;
bool _layoutChanged = false;
bool _mapsChanged = false;
QRgb* _pixels = NULL;
QImage* _image = NULL;
int _selected = -1;
QRgb _bgColor = 0;
static constexpr int MIN_H = TILE_OUTER_SIZE;
static int _cols(int w);
static int _col(int x);
static int _row(int y);
};
#endif // TILEVIEW_H