From 406af09ade55553e2b064506c3ba3c89bd965d73 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 4 Mar 2021 19:11:42 -0500 Subject: start of a c++ widget toolkit, c++ runtime --- src/user/include/cxx/raleigh/runtime.h | 12 ++++++++++++ src/user/include/cxx/raleigh/util.h | 15 +++++++++++++++ src/user/include/cxx/raleigh/w/label.h | 24 ++++++++++++++++++++++++ src/user/include/cxx/raleigh/w/padding.h | 20 ++++++++++++++++++++ src/user/include/cxx/raleigh/widget.h | 27 +++++++++++++++++++++++++++ src/user/include/cxx/raleigh/window.h | 27 +++++++++++++++++++++++++++ 6 files changed, 125 insertions(+) create mode 100644 src/user/include/cxx/raleigh/runtime.h create mode 100644 src/user/include/cxx/raleigh/util.h create mode 100644 src/user/include/cxx/raleigh/w/label.h create mode 100644 src/user/include/cxx/raleigh/w/padding.h create mode 100644 src/user/include/cxx/raleigh/widget.h create mode 100644 src/user/include/cxx/raleigh/window.h (limited to 'src/user/include/cxx/raleigh') 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 +#include + +namespace raleigh { + void start_runtime() __attribute__ ((noreturn)); + extern dllist 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 + +#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 +#include + +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 + +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 +#include +#include + +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 +#include +#include + +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 -- cgit v1.2.3