-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpalette.h
57 lines (41 loc) · 1.21 KB
/
palette.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
#ifndef PALETTE_H
#define PALETTE_H
#include <array>
#include <functional>
#include <QColor>
#include <QObject>
#include <QString>
#include "data-stream.h"
struct Palette
{
struct Line
{
static constexpr int TOTAL_COLOURS = 16;
struct Colour
{
Colour& operator=(const uint colour)
{
this->colour = colour;
return *this;
}
Colour& operator=(const QColor &colour);
QColor toQColor(const std::function<uint(uint)> &callback) const;
QColor toQColor224() const;
QColor toQColor256() const;
void toDataStream(DataStream &stream) const;
void fromDataStream(DataStream &stream);
quint16 colour;
};
void toDataStream(DataStream &stream) const;
void fromDataStream(DataStream &stream);
std::array<Colour, TOTAL_COLOURS> colours;
};
static constexpr int TOTAL_LINES = 4;
static constexpr int COLOURS_PER_LINE = Line::TOTAL_COLOURS;
Palette() {reset();}
void reset();
void toDataStream(DataStream &stream, int starting_palette_line = 0, int ending_palette_line = TOTAL_LINES) const;
void fromDataStream(DataStream &stream, int starting_palette_line = 0);
std::array<Line, TOTAL_LINES> lines;
};
#endif // PALETTE_H