blob: 6833c5d545aa1a20e343b10ba4e0901018e42a9f (
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
|
#include <raleigh/w/padding.h>
namespace raleigh {
padding::padding(uint32_t pad_by, _pixel_t color, widget &inner)
: pad_by(pad_by), color(color), inner(inner) {
size = coord(inner.size.x + pad_by * 2, inner.size.y + pad_by * 2);
}
void padding::notify_window_change() {
inner.w = w;
inner.window_offset = coord(window_offset.x + pad_by, window_offset.y + pad_by);
inner.notify_window_change();
}
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);
}
}
|