aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-11-23 20:47:23 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-18 19:34:20 +0100
commit579463633c120d5097aae00083ceff5970170114 (patch)
tree2a54bffce0f2b8521d2d06535af114d6a7120f7b
parent6901f994667dbc2fd18eb23bb4ed1aae88929200 (diff)
downloadusdx-579463633c120d5097aae00083ceff5970170114.tar.gz
usdx-579463633c120d5097aae00083ceff5970170114.tar.xz
usdx-579463633c120d5097aae00083ceff5970170114.zip
utils/rectangle: add + and =+ operator to move rectangle
Points could be added to rectangles and moves the rectangle by this amount.
-rw-r--r--src/utils/rectangle.hpp19
1 files changed, 19 insertions, 0 deletions
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<T> operator+(const Point<T>& offset)
+ {
+ Rectangle<T> tmp(*this);
+ tmp += offset;
+ return tmp;
+ }
+
+ Rectangle<T>& operator+=(const Point<T>& 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<T>(left, top);
+ this->point2 = Point<T>(left + width, top + height);
+ return *this;
+ }
};
};