diff options
Diffstat (limited to 'src/user/raleigh/w/vbox.cpp')
-rw-r--r-- | src/user/raleigh/w/vbox.cpp | 64 |
1 files changed, 8 insertions, 56 deletions
diff --git a/src/user/raleigh/w/vbox.cpp b/src/user/raleigh/w/vbox.cpp index 77ce592..b05c8bf 100644 --- a/src/user/raleigh/w/vbox.cpp +++ b/src/user/raleigh/w/vbox.cpp @@ -1,7 +1,12 @@ #include <raleigh/w/vbox.h> namespace raleigh { - vbox::vbox(dllist<widget &> widgets) : widgets(widgets) { + vbox::vbox(dllist<widget &> widgets) + : multicontainer(widgets) { + size = determine_size(); + } + + coord vbox::determine_size() { uint32_t w = 0, h = 0; for (dllist<widget &>::node *n = widgets.first; n; n = n->next) { n->d.parent = this; @@ -9,11 +14,10 @@ namespace raleigh { if (n->d.size.x > w) w = n->d.size.x; } - size = coord(w, h); - closest_opaque = 0; + return coord(w, h); } - void vbox::notify_window_change() { + void vbox::set_child_offsets() { uint32_t h = window_offset.y; for (dllist<widget &>::node *n = widgets.first; n; n = n->next) { n->d.w = w; @@ -22,56 +26,4 @@ namespace raleigh { 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); - } - - void vbox::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; - } - if ((window_coords.x >= n->d.window_offset.x) && - (window_coords.x < n->d.window_offset.x + n->d.size.x)) - n->d.handle_click(window_coords, click_type, up); - } - - void vbox::notify_has_opaque_parent(widget *parent) { - closest_opaque = parent; - for (dllist<widget &>::node *n = widgets.first; n; n = n->next) - n->d.notify_has_opaque_parent(parent); - } - - 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(); - } - } - - void vbox::on_mouse_move(coord window_coords) { - for (dllist<widget &>::node *n = widgets.first; n; n = n->next) - if ((window_coords.x >= n->d.window_offset.x) && - (window_coords.y >= n->d.window_offset.y) && - (window_coords.x < n->d.window_offset.x + n->d.size.x) && - (window_coords.y < n->d.window_offset.y + n->d.size.y)) { - n->d.on_mouse_move(window_coords); - return; - } - } }
\ No newline at end of file |