summaryrefslogtreecommitdiff
path: root/src/user/include/cxx/raleigh
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-04 19:11:42 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-04 19:11:42 -0500
commit406af09ade55553e2b064506c3ba3c89bd965d73 (patch)
treedd6da93bc329d6b1097aa1afcde2af19491dfc8e /src/user/include/cxx/raleigh
parent86af7f631080bc4b45846bd7f382c4cedcbec2b4 (diff)
downloadportland-os-406af09ade55553e2b064506c3ba3c89bd965d73.tar.gz
start of a c++ widget toolkit, c++ runtime
Diffstat (limited to 'src/user/include/cxx/raleigh')
-rw-r--r--src/user/include/cxx/raleigh/runtime.h12
-rw-r--r--src/user/include/cxx/raleigh/util.h15
-rw-r--r--src/user/include/cxx/raleigh/w/label.h24
-rw-r--r--src/user/include/cxx/raleigh/w/padding.h20
-rw-r--r--src/user/include/cxx/raleigh/widget.h27
-rw-r--r--src/user/include/cxx/raleigh/window.h27
6 files changed, 125 insertions, 0 deletions
diff --git a/src/user/include/cxx/raleigh/runtime.h b/src/user/include/cxx/raleigh/runtime.h
new file mode 100644
index 0000000..92bd230
--- /dev/null
+++ b/src/user/include/cxx/raleigh/runtime.h
@@ -0,0 +1,12 @@
+#ifndef RALEIGH_RUNTIME_H
+#define RALEIGH_RUNTIME_H
+
+#include <raleigh/window.h>
+#include <structs/dllist.h>
+
+namespace raleigh {
+ void start_runtime() __attribute__ ((noreturn));
+ extern dllist<window &> open_windows;
+}
+
+#endif \ No newline at end of file
diff --git a/src/user/include/cxx/raleigh/util.h b/src/user/include/cxx/raleigh/util.h
new file mode 100644
index 0000000..d2ed13d
--- /dev/null
+++ b/src/user/include/cxx/raleigh/util.h
@@ -0,0 +1,15 @@
+#ifndef RALEIGH_UTIL_H
+#define RALEIGH_UTIL_H
+
+#include <stdint.h>
+
+#define RGB(R, G, B) ((_pixel_t){.r = 0x##R, .g = 0x##G, .b = 0x##B})
+
+struct coord {
+ uint32_t x;
+ uint32_t y;
+ coord(uint32_t x, uint32_t y);
+ coord();
+};
+
+#endif \ No newline at end of file
diff --git a/src/user/include/cxx/raleigh/w/label.h b/src/user/include/cxx/raleigh/w/label.h
new file mode 100644
index 0000000..51bf541
--- /dev/null
+++ b/src/user/include/cxx/raleigh/w/label.h
@@ -0,0 +1,24 @@
+#ifndef RALEIGH_W_LABEL_H
+#define RALEIGH_W_LABEL_H
+
+#include <raleigh/widget.h>
+#include <libfont/fonts.h>
+
+namespace raleigh {
+ class label : public widget {
+ public:
+ //this pointer is used directly, and the contents of the string should not be changed afterward
+ label(const char *value, const char *font="fixed-10",
+ _pixel_t bg=RGB(bf, bf, bf), _pixel_t fg=RGB(00, 00, 00));
+
+ void notify_window_change() override;
+ void paint(_pixel_t *pixbuf, uint32_t pitch) override;
+ private:
+ const char *const value;
+ const struct font_info *const fi;
+ const _pixel_t bg;
+ const _pixel_t fg;
+ };
+}
+
+#endif \ No newline at end of file
diff --git a/src/user/include/cxx/raleigh/w/padding.h b/src/user/include/cxx/raleigh/w/padding.h
new file mode 100644
index 0000000..108cd28
--- /dev/null
+++ b/src/user/include/cxx/raleigh/w/padding.h
@@ -0,0 +1,20 @@
+#ifndef RALEIGH_W_PADDING_H
+#define RALEIGH_W_PADDING_H
+
+#include <raleigh/widget.h>
+
+namespace raleigh {
+ class padding : public widget {
+ public:
+ padding(uint32_t pad_by, _pixel_t color, widget &inner);
+
+ void notify_window_change() override;
+ void paint(_pixel_t *pixbuf, uint32_t pitch) override;
+ private:
+ uint32_t pad_by;
+ _pixel_t color;
+ widget &inner;
+ };
+}
+
+#endif \ No newline at end of file
diff --git a/src/user/include/cxx/raleigh/widget.h b/src/user/include/cxx/raleigh/widget.h
new file mode 100644
index 0000000..1839333
--- /dev/null
+++ b/src/user/include/cxx/raleigh/widget.h
@@ -0,0 +1,27 @@
+#ifndef RALEIGH_WIDGET_H
+#define RALEIGH_WIDGET_H
+
+namespace raleigh {
+ class widget;
+}
+
+#include <raleigh/window.h>
+#include <pland/syscall.h>
+#include <raleigh/util.h>
+
+namespace raleigh {
+ class widget {
+ public:
+ coord size;
+
+ //set by window class (or parent widget)
+ window *w;
+ coord window_offset;
+
+ //called by window class (or parent widget)
+ virtual void notify_window_change() = 0;
+ virtual void paint(_pixel_t *pixbuf, uint32_t pitch) = 0;
+ };
+}
+
+#endif \ No newline at end of file
diff --git a/src/user/include/cxx/raleigh/window.h b/src/user/include/cxx/raleigh/window.h
new file mode 100644
index 0000000..7e45e22
--- /dev/null
+++ b/src/user/include/cxx/raleigh/window.h
@@ -0,0 +1,27 @@
+#ifndef RALEIGH_WINDOW_H
+#define RALEIGH_WINDOW_H
+
+namespace raleigh {
+ class window;
+}
+
+#include <raleigh/widget.h>
+#include <pland/syscall.h>
+#include <raleigh/util.h>
+
+namespace raleigh {
+ class window {
+ public:
+ window(widget &root);
+ void notify_needs_paint(widget &from);
+ enum try_actions_return_t {NONE, GOOD, DELETE};
+ try_actions_return_t try_actions();
+ private:
+ _window_handle_t handle;
+ _pixel_t *pixbuf;
+ coord size;
+ widget &root;
+ };
+}
+
+#endif \ No newline at end of file