diff options
Diffstat (limited to 'src/user/raleigh/w')
-rw-r--r-- | src/user/raleigh/w/button.cpp | 8 | ||||
-rw-r--r-- | src/user/raleigh/w/colorpicker.cpp | 27 | ||||
-rw-r--r-- | src/user/raleigh/w/multicontainer.cpp | 11 | ||||
-rw-r--r-- | src/user/raleigh/w/padding.cpp | 8 |
4 files changed, 17 insertions, 37 deletions
diff --git a/src/user/raleigh/w/button.cpp b/src/user/raleigh/w/button.cpp index da88f6a..5b5f756 100644 --- a/src/user/raleigh/w/button.cpp +++ b/src/user/raleigh/w/button.cpp @@ -59,12 +59,4 @@ namespace raleigh { } void button::notify_has_opaque_parent(widget *parent) {} - - void button::on_mouse_move(coord window_coords) { - if ((window_coords.x >= inner.window_offset.x) && - (window_coords.y >= inner.window_offset.y) && - (window_coords.x < inner.window_offset.x + inner.size.x) && - (window_coords.y < inner.window_offset.y + inner.size.y)) - inner.on_mouse_move(window_coords); - } }
\ No newline at end of file diff --git a/src/user/raleigh/w/colorpicker.cpp b/src/user/raleigh/w/colorpicker.cpp index 4ccd0ce..5a9aa82 100644 --- a/src/user/raleigh/w/colorpicker.cpp +++ b/src/user/raleigh/w/colorpicker.cpp @@ -3,7 +3,7 @@ namespace raleigh { colorpicker::colorpicker(_pixel_t default_color, uint8_t resolution) : picked_color(default_color), resolution(resolution), - inv_res(256 / resolution), selected(NO) { + inv_res(256 / resolution) { size = coord(inv_res * 2, inv_res * 2); closest_opaque = this; } @@ -33,12 +33,8 @@ namespace raleigh { } void colorpicker::handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) { - if (click_type != mouse_packet::LEFT) + if (up || (click_type != mouse_packet::LEFT)) return; - if (up) { - selected = NO; - return; - } window_coords.x -= window_offset.x; window_coords.y -= window_offset.y; if ((window_coords.x < inv_res) && (window_coords.y < inv_res)) { @@ -57,37 +53,48 @@ namespace raleigh { picked_color.g = (window_coords.y - inv_res) * resolution; } w->notify_needs_paint(*this); + w->notify_wants_movements(*this, mouse_packet::LEFT); } void colorpicker::notify_has_opaque_parent(widget *parent) {} void colorpicker::on_mouse_move(coord window_coords) { - uint32_t x = window_coords.x - window_offset.x; - uint32_t y = window_coords.y - window_offset.y; + int32_t x = window_coords.x - window_offset.x; + int32_t y = window_coords.y - window_offset.y; switch (selected) { - case NO: - return; case R: if (x >= inv_res) x = inv_res - 1; + if (x < 0) + x = 0; if (y >= inv_res) y = inv_res - 1; + if (y < 0) + y = 0; picked_color.g = x * resolution; picked_color.b = y * resolution; break; case G: if (x < inv_res) x = inv_res; + if (x >= inv_res * 2) + x = inv_res * 2 - 1; if (y >= inv_res) y = inv_res - 1; + if (y < 0) + y = 0; picked_color.b = x * resolution; picked_color.r = y * resolution; break; case B: if (x >= inv_res) x = inv_res - 1; + if (x < 0) + x = 0; if (y < inv_res) y = inv_res; + if (y >= inv_res * 2) + y = inv_res * 2 - 1; picked_color.r = x * resolution; picked_color.g = y * resolution; break; diff --git a/src/user/raleigh/w/multicontainer.cpp b/src/user/raleigh/w/multicontainer.cpp index 3021deb..edc60aa 100644 --- a/src/user/raleigh/w/multicontainer.cpp +++ b/src/user/raleigh/w/multicontainer.cpp @@ -39,15 +39,4 @@ namespace raleigh { set_size(determine_size()); set_child_offsets(); } - - void multicontainer::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 diff --git a/src/user/raleigh/w/padding.cpp b/src/user/raleigh/w/padding.cpp index 21289d4..57ac011 100644 --- a/src/user/raleigh/w/padding.cpp +++ b/src/user/raleigh/w/padding.cpp @@ -38,12 +38,4 @@ namespace raleigh { void padding::notify_child_size_change(widget &child, coord old_size) { set_size(coord(inner.size.x + pad_by * 2, inner.size.y + pad_by * 2)); } - - void padding::on_mouse_move(coord window_coords) { - if ((window_coords.x >= inner.window_offset.x) && - (window_coords.y >= inner.window_offset.y) && - (window_coords.x < inner.window_offset.x + inner.size.x) && - (window_coords.y < inner.window_offset.y + inner.size.y)) - inner.on_mouse_move(window_coords); - } }
\ No newline at end of file |