blob: 08c2539885f7cda3bd6ec07bcba1afc0a5f96a4e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#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);
}
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::handle_key(struct key_packet kp) {};
void vbox::on_focus() {};
void vbox::on_unfocus() {};
}
|