summaryrefslogtreecommitdiff
path: root/src/user/raleigh/w/vbox.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-05 18:07:48 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-05 18:07:48 -0500
commit76e39eac8cee2175ec62a191f7c91ca53857e80c (patch)
tree156946f6e8f491235453aa3cbecfda43d6baa2a7 /src/user/raleigh/w/vbox.cpp
parent5e5e524f08ad653a7bf5d6e97f3a49f6c27d08fa (diff)
downloadportland-os-76e39eac8cee2175ec62a191f7c91ca53857e80c.tar.gz
more raleigh, including button and vbox widgets
Diffstat (limited to 'src/user/raleigh/w/vbox.cpp')
-rw-r--r--src/user/raleigh/w/vbox.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/user/raleigh/w/vbox.cpp b/src/user/raleigh/w/vbox.cpp
new file mode 100644
index 0000000..30b0902
--- /dev/null
+++ b/src/user/raleigh/w/vbox.cpp
@@ -0,0 +1,45 @@
+#include <raleigh/w/vbox.h>
+
+namespace raleigh {
+ vbox::vbox(dllist<widget &> widgets) : widgets(widgets) {
+ uint32_t w = 0, h = 0;
+ for (dllist<widget &>::node *n = widgets.first; n; n = n->next) {
+ h += n->d.size.y;
+ if (n->d.size.x > w)
+ w = n->d.size.x;
+ }
+ size = coord(w, h);
+ closest_opaque = 0;
+ }
+
+ void vbox::notify_window_change() {
+ uint32_t h = window_offset.y;
+ for (dllist<widget &>::node *n = widgets.first; n; n = n->next) {
+ n->d.w = w;
+ n->d.window_offset = coord(window_offset.x + size.x / 2 - n->d.size.x / 2, h);
+ n->d.notify_window_change();
+ h += n->d.size.y;
+ }
+ }
+
+ void vbox::paint(_pixel_t *pixbuf, uint32_t pitch) {
+ for (dllist<widget &>::node *n = widgets.first; n; n = n->next)
+ n->d.paint(pixbuf, pitch);
+ }
+
+ bool vbox::try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) {
+ uint32_t h = window_offset.y;
+ dllist<widget &>::node *n = widgets.first;
+ while (h + n->d.size.y <= window_coords.y) {
+ h += n->d.size.y;
+ n = n->next;
+ }
+ return (window_coords.x >= n->d.window_offset.x) &&
+ (window_coords.x < n->d.window_offset.x + n->d.size.x) &&
+ n->d.try_handle_click(window_coords, click_type, up);
+ }
+
+ void vbox::notify_has_opaque_parent(widget *parent) {
+ closest_opaque = parent;
+ }
+} \ No newline at end of file