aboutsummaryrefslogtreecommitdiff
path: root/src/RectangleUtil.hh
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2013-05-23 07:18:37 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2013-05-23 07:18:37 (GMT)
commit2da808667301d27110497e036b8cbdec6f65023d (patch)
treecd499cf5e37b0d0c7586326abe1ff956684e32e8 /src/RectangleUtil.hh
parent9b0cedf9618f382c8691d3243668771e065732b2 (diff)
downloadfluxbox-2da808667301d27110497e036b8cbdec6f65023d.zip
fluxbox-2da808667301d27110497e036b8cbdec6f65023d.tar.bz2
Use shared code, minor code simplification
Diffstat (limited to 'src/RectangleUtil.hh')
-rw-r--r--src/RectangleUtil.hh21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/RectangleUtil.hh b/src/RectangleUtil.hh
index 9725e63..dfb0082 100644
--- a/src/RectangleUtil.hh
+++ b/src/RectangleUtil.hh
@@ -3,6 +3,14 @@
3 3
4namespace RectangleUtil { 4namespace RectangleUtil {
5 5
6inline bool insideRectangle(int x, int y, int width, int height, int px, int py) {
7
8 return
9 px >= x &&
10 px < (x + width) &&
11 py >= y &&
12 py < (y + height);
13}
6 14
7/* 15/*
8 * Determines if a point is inside a rectangle-like objects border. 16 * Determines if a point is inside a rectangle-like objects border.
@@ -10,18 +18,17 @@ namespace RectangleUtil {
10 * height. 18 * height.
11 * @param x 19 * @param x
12 * @param y 20 * @param y
13 * @param border_width The size of the border. 21 * @param border The size of the border.
14 * @returns true if point is inside the rectangle-like object. 22 * @returns true if point is inside the rectangle-like object.
15*/ 23*/
24
16template <typename RectangleLike> 25template <typename RectangleLike>
17bool insideBorder(const RectangleLike& rect, 26bool insideBorder(const RectangleLike& rect,
18 int x, int y, 27 int x, int y,
19 int border_width) { 28 int border) {
20 return 29 const int w = static_cast<int>(rect.width()) - border;
21 x >= rect.x() + border_width && 30 const int h = static_cast<int>(rect.height()) - border;
22 x < rect.x() + (int)rect.width() + border_width && 31 return insideRectangle(rect.x() + border, rect.y() + border, w, h, x, y);
23 y >= rect.y() + border_width &&
24 y < rect.y() + (int)rect.height() + border_width;
25} 32}
26 33
27 34