aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGregory Montoir2007-12-07 20:53:06 +0000
committerGregory Montoir2007-12-07 20:53:06 +0000
commita34df6e72d298ecccdaaf881809184fc4b3f0623 (patch)
tree4351c18b83173d8d5bdd1b306ace6557146afa75 /common
parent0718e41c82144d0a617b5a1ec254c34c8a9bf13d (diff)
downloadscummvm-rg350-a34df6e72d298ecccdaaf881809184fc4b3f0623.tar.gz
scummvm-rg350-a34df6e72d298ecccdaaf881809184fc4b3f0623.tar.bz2
scummvm-rg350-a34df6e72d298ecccdaaf881809184fc4b3f0623.zip
add Common::Rect::center (handy for ::setFocusRectangle())
svn-id: r29751
Diffstat (limited to 'common')
-rw-r--r--common/rect.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/common/rect.h b/common/rect.h
index b4355052f6..2230111538 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -189,7 +189,7 @@ struct Rect {
}
void translate(int16 dx, int16 dy) {
- left += dx; right += dx;
+ left += dx; right += dx;
top += dy; bottom += dy;
}
@@ -200,6 +200,13 @@ struct Rect {
void debugPrint(int debuglevel = 0, const char *caption = "Rect:") const {
debug(debuglevel, "%s %d, %d, %d, %d", caption, left, top, right, bottom);
}
+
+ /*! @brief create a rectangle around the given center */
+ static Rect center(int16 cx, int16 cy, int16 w, int16 h) {
+ w /= 2;
+ h /= 2;
+ return Rect(cx - w, cy - h, cx + w, cy + h);
+ }
};
} // End of namespace Common