From fd4557c4adddf710979a42e9f9d470bc8b3f77bd Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 8 Mar 2021 18:06:38 -0500 Subject: hbox, better painting logic in raleigh --- src/user/raleigh/w/hbox.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/user/raleigh/w/hbox.cpp (limited to 'src/user/raleigh/w/hbox.cpp') diff --git a/src/user/raleigh/w/hbox.cpp b/src/user/raleigh/w/hbox.cpp new file mode 100644 index 0000000..e989ff7 --- /dev/null +++ b/src/user/raleigh/w/hbox.cpp @@ -0,0 +1,29 @@ +#include + +namespace raleigh { + hbox::hbox(dllist widgets) + : multicontainer(widgets) { + size = determine_size(); + } + + coord hbox::determine_size() { + uint32_t w = 0, h = 0; + for (dllist::node *n = widgets.first; n; n = n->next) { + n->d.parent = this; + w += n->d.size.x; + if (n->d.size.y > h) + h = n->d.size.y; + } + return coord(w, h); + } + + void hbox::set_child_offsets() { + uint32_t x = window_offset.x; + for (dllist::node *n = widgets.first; n; n = n->next) { + n->d.w = w; + n->d.window_offset = coord(x, window_offset.y + size.y / 2 - n->d.size.y / 2); + n->d.notify_window_change(); + x += n->d.size.x; + } + } +} \ No newline at end of file -- cgit v1.2.3