]> Dogcows Code - chaz/openbox/blob - openbox/geom.h
oooops RECT_SET_POINT was broken
[chaz/openbox] / openbox / geom.h
1 #ifndef __geom_h
2 #define __geom_h
3
4 typedef struct _Point {
5 int x;
6 int y;
7 } Point;
8
9 #define POINT_SET(pt, nx, ny) (pt).x = (nx), (pt).y = (ny)
10
11 typedef struct _Size {
12 int width;
13 int height;
14 } Size;
15
16 #define SIZE_SET(sz, w, h) (sz).width = (w), (sz).height = (h)
17
18 typedef struct _Rect {
19 int x;
20 int y;
21 int width;
22 int height;
23 } Rect;
24
25 #define RECT_SET_POINT(r, nx, ny) \
26 (r).x = (nx), (r).y = (ny)
27 #define RECT_SET_SIZE(r, w, h) \
28 (r).width = (w), (r).height = (h)
29 #define RECT_SET(r, nx, ny, w, h) \
30 (r).x = (nx), (r).y = (ny), (r).width = (w), (r).height = (h)
31
32 #define RECT_EQUAL(r1, r2) ((r1).x == (r2).x && (r1).y == (r2).y && \
33 (r1).width == (r2).width && \
34 (r1).height == (r2).height)
35
36 #define RECT_CONTAINS(r, x, y) \
37 ((x) >= (r).x && (x) < (r).x + (r).width && \
38 (y) >= (r).y && (y) < (r).y + (r).height)
39 #define RECT_CONTAINS_RECT(r, o) \
40 ((o).x >= (r).x && (o).x + (o).width <= (r).x + (r).width && \
41 (o).y >= (r).y && (o).y + (o).height <= (r).y + (r).height)
42 #define RECT_INTERSECTS_RECT(r, o) \
43 ((o).x < (r).x + (r).width && (o).x + (o).width > (r).x && \
44 (o).y < (r).y + (r).height && (o).y + (o).height > (r).y)
45
46 typedef struct _Strut {
47 int left;
48 int top;
49 int right;
50 int bottom;
51 } Strut;
52
53 typedef struct _StrutPartial {
54 int left;
55 int top;
56 int right;
57 int bottom;
58
59 int left_start, left_end;
60 int top_start, top_end;
61 int right_start, right_end;
62 int bottom_start, bottom_end;
63 } StrutPartial;
64
65 #define STRUT_SET(s, l, t, r, b) \
66 (s).left = (l), (s).top = (t), (s).right = (r), (s).bottom = (b)
67
68 #define STRUT_PARTIAL_SET(s, l, t, r, b, ls, le, ts, te, rs, re, bs, be) \
69 (s).left = (l), (s).top = (t), (s).right = (r), (s).bottom = (b), \
70 (s).left_start = (ls), (s).left_end = (le), \
71 (s).top_start = (ts), (s).top_end = (te), \
72 (s).right_start = (rs), (s).right_end = (re), \
73 (s).bottom_start = (bs), (s).bottom_end = (be)
74
75 #define STRUT_ADD(s1, s2) \
76 (s1).left = MAX((s1).left, (s2).left), \
77 (s1).right = MAX((s1).right, (s2).right), \
78 (s1).top = MAX((s1).top, (s2).top), \
79 (s1).bottom = MAX((s1).bottom, (s2).bottom)
80
81 #define STRUT_EQUAL(s1, s2) \
82 ((s1).left == (s2).left && \
83 (s1).top == (s2).top && \
84 (s1).right == (s2).right && \
85 (s1).bottom == (s2).bottom && \
86 (s1).left_start == (s2).left_start && \
87 (s1).left_end == (s2).left_end && \
88 (s1).top_start == (s2).top_start && \
89 (s1).top_end == (s2).top_end && \
90 (s1).right_start == (s2).right_start && \
91 (s1).right_end == (s2).right_end && \
92 (s1).bottom_start == (s2).bottom_start && \
93 (s1).bottom_end == (s2).bottom_end)
94
95 #endif
This page took 0.038525 seconds and 5 git commands to generate.