diff options
Diffstat (limited to 'src/user/raleigh/w/vbox.cpp')
-rw-r--r-- | src/user/raleigh/w/vbox.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/user/raleigh/w/vbox.cpp b/src/user/raleigh/w/vbox.cpp index 08c2539..263da2a 100644 --- a/src/user/raleigh/w/vbox.cpp +++ b/src/user/raleigh/w/vbox.cpp @@ -4,6 +4,7 @@ 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) { + n->d.parent = this; h += n->d.size.y; if (n->d.size.x > w) w = n->d.size.x; @@ -45,7 +46,21 @@ namespace raleigh { n->d.notify_has_opaque_parent(parent); } - void vbox::handle_key(struct key_packet kp) {}; - void vbox::on_focus() {}; - void vbox::on_unfocus() {}; + void vbox::notify_child_size_change(widget &from, coord old_size) { + if ((old_size.y == from.size.y) && (from.size.x <= size.x)) { + from.window_offset.x = window_offset.x + size.x / 2 - from.size.x / 2; + from.notify_window_change(); + } + + else {//lazy, less efficient approach + uint32_t h = 0, w = 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; + } + set_size(coord(w, h)); + notify_window_change(); + } + } }
\ No newline at end of file |