summaryrefslogtreecommitdiff
path: root/src/user/raleigh/w/hbox.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-08 18:06:38 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-08 18:06:38 -0500
commitfd4557c4adddf710979a42e9f9d470bc8b3f77bd (patch)
tree485ff6f0514cc1918f8758927a1e2da2198e7d8a /src/user/raleigh/w/hbox.cpp
parent920f1f010284d59bad86f78355ed90ac2f3e1d2c (diff)
downloadportland-os-fd4557c4adddf710979a42e9f9d470bc8b3f77bd.tar.gz
hbox, better painting logic in raleigh
Diffstat (limited to 'src/user/raleigh/w/hbox.cpp')
-rw-r--r--src/user/raleigh/w/hbox.cpp29
1 files changed, 29 insertions, 0 deletions
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 <raleigh/w/hbox.h>
+
+namespace raleigh {
+ hbox::hbox(dllist<widget &> widgets)
+ : multicontainer(widgets) {
+ size = determine_size();
+ }
+
+ coord hbox::determine_size() {
+ uint32_t w = 0, h = 0;
+ for (dllist<widget &>::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<widget &>::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