From 579463633c120d5097aae00083ceff5970170114 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 23 Nov 2012 20:47:23 +0100 Subject: utils/rectangle: add + and =+ operator to move rectangle Points could be added to rectangles and moves the rectangle by this amount. --- src/utils/rectangle.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/utils/rectangle.hpp b/src/utils/rectangle.hpp index 7297cf47..5ea2787f 100644 --- a/src/utils/rectangle.hpp +++ b/src/utils/rectangle.hpp @@ -144,6 +144,25 @@ namespace usdx return result; } + + const Rectangle operator+(const Point& offset) + { + Rectangle tmp(*this); + tmp += offset; + return tmp; + } + + Rectangle& operator+=(const Point& offset) + { + T height = this->get_height(); + T width = this->get_width(); + T left = this->get_left() + offset.get_x(); + T top = this->get_top() + offset.get_y(); + + this->point1 = Point(left, top); + this->point2 = Point(left + width, top + height); + return *this; + } }; }; -- cgit v1.2.3