Code

Disable the page selector when there's only one page
[inkscape.git] / src / libnr / nr-rect.cpp
index a9487045a11b05a4a4b52c69c62eb184430d7e49..72bced37bb048ca9337d8c03658710f412c2dd81 100644 (file)
@@ -245,11 +245,7 @@ namespace NR {
 Rect::Rect(const Point &p0, const Point &p1)
 : _min(std::min(p0[X], p1[X]), std::min(p0[Y], p1[Y])),
   _max(std::max(p0[X], p1[X]), std::max(p0[Y], p1[Y]))
-{
-    if ( _min[X] == _max[X] || _min[Y] == _max[Y] ) {
-        throw EmptyRectangle();
-    }
-}
+{}
 
 /** returns the four corners of the rectangle in the correct winding order */
 Point Rect::corner(unsigned i) const {
@@ -289,6 +285,16 @@ void Rect::expandTo(Point p) {
        }
 }
 
+void Rect::growBy(double size) {
+  for ( unsigned d = 0 ; d < 2 ; d++ ) {
+    _min[d] -= size;
+    _max[d] += size;
+    if ( _min[d] > _max[d] ) {
+      _min[d] = _max[d] = ( _min[d] + _max[d] ) / 2;
+    }
+  }
+} 
+
 /** Returns the set of points shared by both rectangles. */
 Maybe<Rect> intersection(Maybe<Rect> const & a, Maybe<Rect> const & b) {
     if ( !a || !b ) {
@@ -298,7 +304,7 @@ Maybe<Rect> intersection(Maybe<Rect> const & a, Maybe<Rect> const & b) {
         for ( int i=0 ; i < 2 ; i++ ) {
             r._min[i] = std::max(a->_min[i], b->_min[i]);
             r._max[i] = std::min(a->_max[i], b->_max[i]);
-            if ( r._min[i] >= r._max[i] ) {
+            if ( r._min[i] > r._max[i] ) {
                return Nothing();
             }
        }