diff options
author | Max Horn | 2003-06-01 17:06:07 +0000 |
---|---|---|
committer | Max Horn | 2003-06-01 17:06:07 +0000 |
commit | f91de2ae1e731d3d02b55c33e52cd303b4ed2beb (patch) | |
tree | b4387ee265710018414eed159a712ebf980466af | |
parent | ff5705b32c70406db97e64142472ae806f4b8413 (diff) | |
download | scummvm-rg350-f91de2ae1e731d3d02b55c33e52cd303b4ed2beb.tar.gz scummvm-rg350-f91de2ae1e731d3d02b55c33e52cd303b4ed2beb.tar.bz2 scummvm-rg350-f91de2ae1e731d3d02b55c33e52cd303b4ed2beb.zip |
renamed&fixed contains(Rect) -> intersects(Rect); added extend() method
svn-id: r8246
-rw-r--r-- | common/rect.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/common/rect.h b/common/rect.h index a3460743f8..e4a711958c 100644 --- a/common/rect.h +++ b/common/rect.h @@ -23,6 +23,7 @@ #define COMMON_RECT_H #include "scummsys.h" +#include "util.h" namespace ScummVM { @@ -78,14 +79,25 @@ struct Rect { return (left <= p.x) && (p.x < right) && (top <= p.y) && (p.y < bottom); } - /*! @brief check if given rectangle is inside this rectangle + /*! @brief check if given rectangle intersects with this rectangle @param r the rectangle 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); + bool intersects(const Rect & r) const { + return (left < r.right) && (r.left < right) && (top < r.bottom) && (r.top < bottom); + } + + /*! @brief extend this rectangle so that it contains r + + @param r the rectangle to extend by + */ + void extend(const Rect & r) { + left = MIN(left, r.left); + right = MAX(right, r.right); + top = MIN(top, r.top); + bottom = MAX(bottom, r.bottom); } void grow(int16 offset) { |