aboutsummaryrefslogtreecommitdiff
path: root/common/rect.h
diff options
context:
space:
mode:
authorMax Horn2003-05-15 21:52:10 +0000
committerMax Horn2003-05-15 21:52:10 +0000
commitf695aa388550a3cfb2a0e09811b6d16e3a5686ea (patch)
treecc865c601731399cc186b09ec35cf93cbaefb989 /common/rect.h
parent128f793be03e389891a0fe92373269bfb8b39114 (diff)
downloadscummvm-rg350-f695aa388550a3cfb2a0e09811b6d16e3a5686ea.tar.gz
scummvm-rg350-f695aa388550a3cfb2a0e09811b6d16e3a5686ea.tar.bz2
scummvm-rg350-f695aa388550a3cfb2a0e09811b6d16e3a5686ea.zip
renamed isInside() to contains() (this is more intuitive, because r.isInside(p) actually meant 'p is inside r', which was confusing; now it's r.contains(p) which means 'r contains p')
svn-id: r7541
Diffstat (limited to 'common/rect.h')
-rw-r--r--common/rect.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/common/rect.h b/common/rect.h
index 8f983abe66..408fc0ccfe 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -39,6 +39,7 @@ struct Point {
explicit Point(int16 x1, int16 y1) : x(x1), y(y1) {};
Point & operator=(const Point & p) { x = p.x; y = p.y; return *this; };
bool operator==(const Point & p) const { return x == p.x && y == p.y; };
+ bool operator!=(const Point & p) const { return x != p.x || y != p.y; };
};
/*! @brief simple class for handling a rectangular zone.
@@ -56,25 +57,36 @@ struct Rect {
int16 width() const { return right - left; }
int16 height() const { return top - bottom; }
- /*! @brief check if given position is inside the rectangle
+ /*! @brief check if given position is inside this rectangle
@param x the horizontal position to check
@param y the vertical position to check
- @return true if the given position is inside the rectangle, false otherwise
+ @return true if the given position is inside this rectangle, false otherwise
*/
- bool isInside(int16 x, int16 y) const {
+ bool contains(int16 x, int16 y) const {
return (left <= x) && (x < right) && (top <= y) && (y < bottom);
}
- /*! @brief check if given point is inside the rectangle
+
+ /*! @brief check if given point is inside this rectangle
@param p the point to check
- @return true if the given point is inside the rectangle, false otherwise
+ @return true if the given point is inside this rectangle, false otherwise
*/
- bool isInside(const Point & p) const {
+ bool contains(const Point & p) const {
return (left <= p.x) && (p.x < right) && (top <= p.y) && (p.y < bottom);
}
+
+ /*! @brief check if given rectangle is inside this rectangle
+
+ @param p the point to check
+
+ @return true if the given rectangle is inside the rectangle, false otherwise
+ */
+ bool contains(const Rect & r) const {
+ return (left <= r.right) && (r.left < right) && (top <= r.bottom) && (r.top < bottom);
+ }
};
}; // End of namespace ScummVM