From 76e39eac8cee2175ec62a191f7c91ca53857e80c Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Fri, 5 Mar 2021 18:07:48 -0500 Subject: more raleigh, including button and vbox widgets --- src/user/include/cxx/raleigh/w/button.h | 26 ++++++++++++++++++++++++++ src/user/include/cxx/raleigh/w/label.h | 9 ++++++--- src/user/include/cxx/raleigh/w/padding.h | 7 ++++--- src/user/include/cxx/raleigh/w/vbox.h | 22 ++++++++++++++++++++++ 4 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 src/user/include/cxx/raleigh/w/button.h create mode 100644 src/user/include/cxx/raleigh/w/vbox.h (limited to 'src/user/include/cxx/raleigh/w') diff --git a/src/user/include/cxx/raleigh/w/button.h b/src/user/include/cxx/raleigh/w/button.h new file mode 100644 index 0000000..1847cf1 --- /dev/null +++ b/src/user/include/cxx/raleigh/w/button.h @@ -0,0 +1,26 @@ +#ifndef RALEIGH_W_BUTTON_H +#define RALEIGH_W_BUTTON_H + +#include + +namespace raleigh { + class button : public widget { + public: + button(widget &inner, void (*on_click)(button &), _pixel_t border_color=RGB(00, 00, 00), + _pixel_t bg_color=RGB(bf, bf, bf), _pixel_t pressed_color=RGB(9f, 9f, 9f)); + + void notify_window_change() override; + void paint(_pixel_t *pixbuf, uint32_t pitch) override; + bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override; + void notify_has_opaque_parent(widget *parent) override; + private: + widget &inner; + void (*on_click)(button &); + _pixel_t border_color; + _pixel_t bg_color; + _pixel_t pressed_color; + bool is_pressed; + }; +} + +#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 index 51bf541..d133841 100644 --- a/src/user/include/cxx/raleigh/w/label.h +++ b/src/user/include/cxx/raleigh/w/label.h @@ -8,16 +8,19 @@ 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)); + label(const char *value, const char *font="fixed-10", bool bg_transparent=true, + _pixel_t fg=RGB(00, 00, 00), _pixel_t bg=RGB(bf, bf, bf)); void notify_window_change() override; void paint(_pixel_t *pixbuf, uint32_t pitch) override; + bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override __attribute__ ((const)); + void notify_has_opaque_parent(widget *parent) override; private: const char *const value; const struct font_info *const fi; - const _pixel_t bg; + bool bg_transparent; const _pixel_t fg; + const _pixel_t bg; }; } diff --git a/src/user/include/cxx/raleigh/w/padding.h b/src/user/include/cxx/raleigh/w/padding.h index 108cd28..216b984 100644 --- a/src/user/include/cxx/raleigh/w/padding.h +++ b/src/user/include/cxx/raleigh/w/padding.h @@ -6,14 +6,15 @@ namespace raleigh { class padding : public widget { public: - padding(uint32_t pad_by, _pixel_t color, widget &inner); + padding(widget &inner, uint32_t pad_by); void notify_window_change() override; void paint(_pixel_t *pixbuf, uint32_t pitch) override; + bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override; + void notify_has_opaque_parent(widget *parent) override; private: - uint32_t pad_by; - _pixel_t color; widget &inner; + uint32_t pad_by; }; } diff --git a/src/user/include/cxx/raleigh/w/vbox.h b/src/user/include/cxx/raleigh/w/vbox.h new file mode 100644 index 0000000..aead128 --- /dev/null +++ b/src/user/include/cxx/raleigh/w/vbox.h @@ -0,0 +1,22 @@ +#ifndef RALEIGH_W_VBOX_H +#define RALEIGH_W_VBOX_H + +#include +#include + +namespace raleigh { + class vbox : public widget { + public: + //do not modify this list afterward + vbox(dllist widgets); + + void notify_window_change() override; + void paint(_pixel_t *pixbuf, uint32_t pitch) override; + bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override; + void notify_has_opaque_parent(widget *parent) override; + private: + dllist widgets; + }; +} + +#endif \ No newline at end of file -- cgit v1.2.3