]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGRect.hxx
HTTP: Rename urlretrieve/urlload to save/load.
[simgear.git] / simgear / math / SGRect.hxx
index 20976a0c35c4711c4c4d3fd04b1f12cf22e4b3b9..ad5771e9c803c37c6bdabc24f24c72c51b9c0b96 100644 (file)
@@ -99,11 +99,36 @@ class SGRect
     T t() const { return _min.y(); }
     T b() const { return _max.y(); }
 
+    T& l() { return _min.x(); }
+    T& r() { return _max.x(); }
+    T& t() { return _min.y(); }
+    T& b() { return _max.y(); }
+
     void setLeft(T l) { _min.x() = l; }
     void setRight(T r) { _max.x() = r; }
     void setTop(T t) { _min.y() = t; }
     void setBottom(T b) { _max.y() = b; }
 
+    /**
+     * Move rect by vector
+     */
+    SGRect& operator+=(const SGVec2<T>& offset)
+    {
+      _min += offset;
+      _max += offset;
+      return *this;
+    }
+
+    /**
+     * Move rect by vector in inverse direction
+     */
+    SGRect& operator-=(const SGVec2<T>& offset)
+    {
+      _min -= offset;
+      _max -= offset;
+      return *this;
+    }
+
     bool contains(T x, T y) const
     {
       return _min.x() <= x && x <= _max.x()
@@ -121,6 +146,30 @@ class SGRect
               _max;
 };
 
+template<typename T>
+inline SGRect<T> operator+(SGRect<T> rect, const SGVec2<T>& offset)
+{
+  return rect += offset;
+}
+
+template<typename T>
+inline SGRect<T> operator+(const SGVec2<T>& offset, SGRect<T> rect)
+{
+  return rect += offset;
+}
+
+template<typename T>
+inline SGRect<T> operator-(SGRect<T> rect, const SGVec2<T>& offset)
+{
+  return rect -= offset;
+}
+
+template<typename T>
+inline SGRect<T> operator-(const SGVec2<T>& offset, SGRect<T> rect)
+{
+  return rect -= offset;
+}
+
 template<typename char_type, typename traits_type, typename T>
 inline
 std::basic_ostream<char_type, traits_type>&