From a34df6e72d298ecccdaaf881809184fc4b3f0623 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Fri, 7 Dec 2007 20:53:06 +0000 Subject: add Common::Rect::center (handy for ::setFocusRectangle()) svn-id: r29751 --- common/rect.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'common') 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 -- cgit v1.2.3