From fd4557c4adddf710979a42e9f9d470bc8b3f77bd Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 8 Mar 2021 18:06:38 -0500 Subject: hbox, better painting logic in raleigh --- src/user/raleigh/w/button.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/user/raleigh/w/button.cpp') diff --git a/src/user/raleigh/w/button.cpp b/src/user/raleigh/w/button.cpp index 224b930..da88f6a 100644 --- a/src/user/raleigh/w/button.cpp +++ b/src/user/raleigh/w/button.cpp @@ -18,18 +18,22 @@ namespace raleigh { } void button::paint(_pixel_t *pixbuf, uint32_t pitch) { + if (next_paint_full) { + next_paint_full = false; + for (uint32_t x = window_offset.x; x < window_offset.x + size.x; ++x) { + pixbuf[window_offset.y * pitch + x] = border_color; + pixbuf[(window_offset.y + size.y - 1) * pitch + x] = border_color; + } + for (uint32_t y = window_offset.y + 1; y < window_offset.y + size.y - 1; ++y) { + pixbuf[y * pitch + window_offset.x] = border_color; + pixbuf[y * pitch + window_offset.x + size.x - 1] = border_color; + } + } for (uint32_t y = window_offset.y + 1; y < window_offset.y + size.y - 1; ++y) for (uint32_t x = window_offset.x + 1; x < window_offset.x + size.x - 1; ++x) pixbuf[y * pitch + x] = is_pressed ? pressed_color : bg_color; + inner.next_paint_full = true; inner.paint(pixbuf, pitch); - for (uint32_t x = window_offset.x; x < window_offset.x + size.x; ++x) { - pixbuf[window_offset.y * pitch + x] = border_color; - pixbuf[(window_offset.y + size.y - 1) * pitch + x] = border_color; - } - for (uint32_t y = window_offset.y + 1; y < window_offset.y + size.y - 1; ++y) { - pixbuf[y * pitch + window_offset.x] = border_color; - pixbuf[y * pitch + window_offset.x + size.x - 1] = border_color; - } } void button::handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) { -- cgit v1.2.3