From 76e39eac8cee2175ec62a191f7c91ca53857e80c Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Fri, 5 Mar 2021 18:07:48 -0500 Subject: more raleigh, including button and vbox widgets --- src/user/raleigh/w/padding.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/user/raleigh/w/padding.cpp') diff --git a/src/user/raleigh/w/padding.cpp b/src/user/raleigh/w/padding.cpp index 6833c5d..3dd027b 100644 --- a/src/user/raleigh/w/padding.cpp +++ b/src/user/raleigh/w/padding.cpp @@ -1,9 +1,10 @@ #include namespace raleigh { - padding::padding(uint32_t pad_by, _pixel_t color, widget &inner) - : pad_by(pad_by), color(color), inner(inner) { + padding::padding(widget &inner, uint32_t pad_by) + : inner(inner), pad_by(pad_by) { size = coord(inner.size.x + pad_by * 2, inner.size.y + pad_by * 2); + closest_opaque = 0; } void padding::notify_window_change() { @@ -13,19 +14,18 @@ namespace raleigh { } void padding::paint(_pixel_t *pixbuf, uint32_t pitch) { - for (uint32_t y = window_offset.y; y < window_offset.y + pad_by; ++y) - for (uint32_t x = window_offset.x; x < window_offset.x + size.x; ++x) - pixbuf[y * pitch + x] = color; - for (uint32_t y = window_offset.y + size.y - pad_by; y < window_offset.y + size.y; ++y) - for (uint32_t x = window_offset.x; x < window_offset.x + size.x; ++x) - pixbuf[y * pitch + x] = color; - for (uint32_t y = window_offset.y + pad_by; y < window_offset.y + size.y - pad_by; ++y) { - for (uint32_t x = window_offset.x; x < window_offset.x + pad_by; ++x) - pixbuf[y * pitch + x] = color; - for (uint32_t x = window_offset.x + size.x - pad_by; x < window_offset.x + size.x; ++x) - pixbuf[y * pitch + x] = color; - } - inner.paint(pixbuf, pitch); } + + bool padding::try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) { + return (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.try_handle_click(window_coords, click_type, up); + } + + void padding::notify_has_opaque_parent(widget *parent) { + closest_opaque = parent; + } } \ No newline at end of file -- cgit v1.2.3