summaryrefslogtreecommitdiff
path: root/src/user/include/cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/include/cxx')
-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
-rw-r--r--src/user/include/cxx/structs/dllist.h39
7 files changed, 164 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
diff --git a/src/user/include/cxx/structs/dllist.h b/src/user/include/cxx/structs/dllist.h
new file mode 100644
index 0000000..5783364
--- /dev/null
+++ b/src/user/include/cxx/structs/dllist.h
@@ -0,0 +1,39 @@
+#ifndef STRUCTS_DLLIST_H
+#define STRUCTS_DLLIST_H
+
+template<class data>
+class dllist {
+public:
+ class node {
+ public:
+ node *next;
+ node *prev;
+ data d;
+ node(node *next, node *prev, data d)
+ : next(next), prev(prev), d(d) {}
+ };
+ node *first;
+
+ dllist() : first(0) {}
+
+ void add_front(data d) {
+ node *const n = new node(first, 0, d);
+ if (first)
+ first->prev = n;
+ first = n;
+ }
+
+ //return previous, or zero if this is the first
+ node *remove_in_place(node *n) {
+ if (n == first)
+ first = n->next;
+ if (n->next)
+ n->next->prev = n->prev;
+ if (n->prev)
+ n->prev->next = n->next;
+ delete n;
+ return n->prev;
+ }
+};
+
+#endif \ No newline at end of file