summaryrefslogtreecommitdiffstats
path: root/hal
diff options
context:
space:
mode:
Diffstat (limited to 'hal')
-rw-r--r--hal/ui/widget/base_widget.hpp25
-rw-r--r--hal/ui/widget/list_widget.cpp9
-rw-r--r--hal/ui/widget/list_widget.hpp9
3 files changed, 43 insertions, 0 deletions
diff --git a/hal/ui/widget/base_widget.hpp b/hal/ui/widget/base_widget.hpp
new file mode 100644
index 0000000..4deabc3
--- /dev/null
+++ b/hal/ui/widget/base_widget.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "../../api.hpp"
+#include "../../../init.hpp"
+
+class BaseWidget {
+ private:
+ // A pointer to the API is used by the paint method to draw the widget on-screen.
+ Api *m_app_api;
+
+ public:
+ // Widget geometry, in pixels
+ struct Geometry {
+ int x = 0; // top-left corner of widget
+ int y = 0; // top-left corner of widget
+ int width = 1;
+ int height = 1;
+ } m_geometry;
+
+ BaseWidget(Api *app_api, Geometry geometry) :
+ m_app_api{app_api},
+ m_geometry{geometry}
+ {}
+ virtual void paint(bool invert_colors = false) = 0;
+};
diff --git a/hal/ui/widget/list_widget.cpp b/hal/ui/widget/list_widget.cpp
new file mode 100644
index 0000000..5a759fe
--- /dev/null
+++ b/hal/ui/widget/list_widget.cpp
@@ -0,0 +1,9 @@
+#include "list_widget.hpp"
+
+ListWidget::ListWidget(Api *app_api, Geometry geometry) {
+ printf("On init: m_x=%d and x=%d", m_geometry.x, geometry.x);
+}
+
+void ListWidget::paint(bool invert_colors) {
+ m_app_api->display_draw_rectange(m_geometry.x, m_geometry.y, m_geometry.x+m_geometry.width, m_geometry.y+m_geometry.height, 1, 1);
+}
diff --git a/hal/ui/widget/list_widget.hpp b/hal/ui/widget/list_widget.hpp
new file mode 100644
index 0000000..27922f2
--- /dev/null
+++ b/hal/ui/widget/list_widget.hpp
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "base_widget.hpp"
+
+class ListWidget : private BaseWidget {
+ public:
+ ListWidget(Api *app_api, Geometry geometry);
+ void paint(bool invert_colors = false);
+};