]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGRect.hxx
canvas::Text: get maximum width (if displayed on a single line).
[simgear.git] / simgear / math / SGRect.hxx
index 9c51f091def6d591d6099f920e19812dc3522a91..86dd482c9c8875c54bdd848abff6fe2df6656e32 100644 (file)
@@ -34,7 +34,7 @@ class SGRect
 
     }
 
-    SGRect(const SGVec2<T>& pt):
+    explicit SGRect(const SGVec2<T>& pt):
       _min(pt),
       _max(pt)
     {
@@ -113,6 +113,18 @@ class SGRect
     void setTop(T t) { _min.y() = t; }
     void setBottom(T b) { _max.y() = b; }
 
+    /**
+     * Expand rectangle to include the given position
+     */
+    void expandBy(T x, T y)
+    {
+      if( x < _min.x() ) _min.x() = x;
+      if( x > _max.x() ) _max.x() = x;
+
+      if( y < _min.y() ) _min.y() = y;
+      if( y > _max.y() ) _max.y() = y;
+    }
+
     /**
      * Move rect by vector
      */