aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/math/rect32.h
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-21 18:19:07 +0200
committerEinar Johan Trøan Sømåen2012-07-21 19:15:33 +0200
commit5683f076331d2831eb4720b65bb53e8d01ca33ee (patch)
tree4357d989476643db887d5f5a95f6fd165afd0514 /engines/wintermute/math/rect32.h
parent0622b2c5b8260c0f0c01122d6fbc5e10013d1613 (diff)
downloadscummvm-rg350-5683f076331d2831eb4720b65bb53e8d01ca33ee.tar.gz
scummvm-rg350-5683f076331d2831eb4720b65bb53e8d01ca33ee.tar.bz2
scummvm-rg350-5683f076331d2831eb4720b65bb53e8d01ca33ee.zip
WINTERMUTE: Rename CamelCased filenames to prefixed_under_score-filenames
This is mostly a lead-up to namespacing the Ad/Base folders, and then possibly removing the prefixes from the files, it also has the added benefit of getting rid of the odd case-typos that makes for issues on platforms that don't ignore case.
Diffstat (limited to 'engines/wintermute/math/rect32.h')
-rw-r--r--engines/wintermute/math/rect32.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h
new file mode 100644
index 0000000000..e0babcbbb9
--- /dev/null
+++ b/engines/wintermute/math/rect32.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WINTERMUTE_RECT32_H
+#define WINTERMUTE_RECT32_H
+
+#include "common/system.h"
+
+namespace WinterMute {
+
+struct Point32 {
+ int32 x;
+ int32 y;
+};
+
+struct Rect32 {
+ int32 top, left; ///< The point at the top left of the rectangle (part of the rect).
+ int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect).
+
+ Rect32() : top(0), left(0), bottom(0), right(0) {}
+ Rect32(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {}
+ Rect32(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) {
+ assert(isValidRect());
+ }
+ bool operator==(const Rect32 &rhs) const { return equals(rhs); }
+ bool operator!=(const Rect32 &rhs) const { return !equals(rhs); }
+
+ int16 width() const { return right - left; }
+ int16 height() const { return bottom - top; }
+
+ void setWidth(int16 aWidth) {
+ right = left + aWidth;
+ }
+
+ void setHeight(int16 aHeight) {
+ bottom = top + aHeight;
+ }
+
+ void setEmpty() {
+ left = right = top = bottom = 0;
+ }
+
+ void offsetRect(int dx, int dy) {
+ left += dx;
+ top += dy;
+ right += dx;
+ bottom += dy;
+ }
+ /**
+ * Check if the given rect is equal to this one.
+ *
+ * @param r The rectangle to check
+ *
+ * @return true if the given rect is equal, false otherwise
+ */
+ bool equals(const Rect32 &r) const {
+ return (left == r.left) && (right == r.right) && (top == r.top) && (bottom == r.bottom);
+ }
+
+ bool isValidRect() const {
+ return (left <= right && top <= bottom);
+ }
+};
+
+} // end of namespace WinterMute
+
+#endif // WINTERMUTE_RECT32_H