]> git.localhorst.tv Git - space.git/blob - src/ui/DualGauge.h
simple dual gauge (vertical)
[space.git] / src / ui / DualGauge.h
1 #ifndef SPACE_DUALGAUGE_H_
2 #define SPACE_DUALGAUGE_H_
3
4 #include "../graphics/Color.h"
5 #include "../graphics/Vector.h"
6
7
8 namespace space {
9
10 class Canvas;
11
12 class DualGauge {
13
14 public:
15         constexpr DualGauge(
16                 Vector<int> size,
17                 Vector<int> pos,
18                 Color borderCol,
19                 Color bgCol,
20                 Color posCol,
21                 Color negCol)
22         : pos(pos), size(size)
23         , bgPos(pos + Vector<int>(1, 1)), bgSize(size - Vector<int>(2, 2))
24         , valPos(pos.x + 2, pos.y + 2 + (size.y - 4) / 2)
25         , valSize(size.x - 4, (size.y - 4) / 2)
26         , borderCol(borderCol), bgCol(bgCol)
27         , posCol(posCol), negCol(negCol) { }
28
29 public:
30         void Render(Canvas &, float value) const;
31
32 private:
33         Vector<int> pos;
34         Vector<int> size;
35         Vector<int> bgPos;
36         Vector<int> bgSize;
37         Vector<int> valPos;
38         Vector<int> valSize;
39         Color borderCol;
40         Color bgCol;
41         Color posCol;
42         Color negCol;
43
44 };
45
46 }
47
48 #endif