summaryrefslogtreecommitdiff
path: root/src/user/raleigh/w/padding.cpp
blob: 87167c3ff94e9c0ab51580e1e516cd0983c6e98a (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
#include <raleigh/w/padding.h>

namespace raleigh {
  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() {
    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) {
    inner.paint(pixbuf, pitch);
  }

  void padding::handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) {
    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.handle_click(window_coords, click_type, up);
  }

  void padding::notify_has_opaque_parent(widget *parent) {
    closest_opaque = parent;
    inner.notify_has_opaque_parent(parent);
  }

  void padding::handle_key(struct key_packet kp) {};
  void padding::on_focus() {};
  void padding::on_unfocus() {};
}