]> git.localhorst.tv Git - space.git/blobdiff - src/ui/DualGauge.h
simple dual gauge (vertical)
[space.git] / src / ui / DualGauge.h
diff --git a/src/ui/DualGauge.h b/src/ui/DualGauge.h
new file mode 100644 (file)
index 0000000..9aa30e3
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef SPACE_DUALGAUGE_H_
+#define SPACE_DUALGAUGE_H_
+
+#include "../graphics/Color.h"
+#include "../graphics/Vector.h"
+
+
+namespace space {
+
+class Canvas;
+
+class DualGauge {
+
+public:
+       constexpr DualGauge(
+               Vector<int> size,
+               Vector<int> pos,
+               Color borderCol,
+               Color bgCol,
+               Color posCol,
+               Color negCol)
+       : pos(pos), size(size)
+       , bgPos(pos + Vector<int>(1, 1)), bgSize(size - Vector<int>(2, 2))
+       , valPos(pos.x + 2, pos.y + 2 + (size.y - 4) / 2)
+       , valSize(size.x - 4, (size.y - 4) / 2)
+       , borderCol(borderCol), bgCol(bgCol)
+       , posCol(posCol), negCol(negCol) { }
+
+public:
+       void Render(Canvas &, float value) const;
+
+private:
+       Vector<int> pos;
+       Vector<int> size;
+       Vector<int> bgPos;
+       Vector<int> bgSize;
+       Vector<int> valPos;
+       Vector<int> valSize;
+       Color borderCol;
+       Color bgCol;
+       Color posCol;
+       Color negCol;
+
+};
+
+}
+
+#endif