aboutsummaryrefslogtreecommitdiff
path: root/src/RectangleUtil.hh
diff options
context:
space:
mode:
authorHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-14 18:06:28 (GMT)
committerHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-14 18:06:28 (GMT)
commit9f519ec0fcb7cd0dec61a4c31d246800f9a73cb3 (patch)
tree4e3f181c4a14c185f934b29455ff0cfaa2636982 /src/RectangleUtil.hh
parentde8275f68860f8088c582f0e02494b5a46c871d5 (diff)
downloadfluxbox_pavel-9f519ec0fcb7cd0dec61a4c31d246800f9a73cb3.zip
fluxbox_pavel-9f519ec0fcb7cd0dec61a4c31d246800f9a73cb3.tar.bz2
some minor code cleaning.
Diffstat (limited to 'src/RectangleUtil.hh')
-rw-r--r--src/RectangleUtil.hh30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/RectangleUtil.hh b/src/RectangleUtil.hh
new file mode 100644
index 0000000..88c3a33
--- /dev/null
+++ b/src/RectangleUtil.hh
@@ -0,0 +1,30 @@
1#ifndef RECTANGLEUTIL_HH
2#define RECTANGLEUTIL_HH
3
4namespace RectangleUtil {
5
6
7/*
8 * Determines if a point is inside a rectangle-like objects border.
9 * @param rect A rectangle-like object that has accessors for x, y, width, and
10 * height.
11 * @param x
12 * @param y
13 * @param border_width The size of the border.
14 * @returns true if point is inside the rectangle-like object.
15*/
16template <typename RectangleLike>
17bool insideBorder(const RectangleLike& rect,
18 int x, int y,
19 int border_width) {
20 return
21 x >= rect.x() + border_width &&
22 x < rect.x() + (int)rect.width() + border_width &&
23 y >= rect.y() + border_width &&
24 y < rect.y() + (int)rect.height() + border_width;
25}
26
27} // namespace RectangleUtil
28
29
30#endif // RECTANGLEUTIL_HH