[Scummvm-cvs-logs] CVS: scummvm/common rect.h,1.16,1.17

Max Horn fingolfin at users.sourceforge.net
Wed Jan 7 19:25:00 CET 2004


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv29360

Modified Files:
	rect.h 
Log Message:
useful convenience method

Index: rect.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/rect.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- rect.h	6 Jan 2004 12:45:28 -0000	1.16
+++ rect.h	8 Jan 2004 03:24:01 -0000	1.17
@@ -100,11 +100,26 @@
 		bottom = MAX(bottom, r.bottom);
 	}
 	
+	/*!	@brief extend this rectangle in all four directions by the given number of pixels
+		
+		@param offset the size to grow by
+	*/
 	void grow(int16 offset) {
 		top -= offset;
 		left -= offset;
 		bottom += offset;
 		right += offset;
+	}
+	
+	void clip(const Rect & r) {
+		if (top < r.top) top = r.top;
+		if (left < r.left) left = r.left;
+		if (bottom > r.bottom) bottom = r.bottom;
+		if (right > r.right) right = r.right;
+	}
+	
+	void clip(int maxw, int maxh) {
+		clip(Rect(0, 0, maxw, maxh));
 	}
 };
 





More information about the Scummvm-git-logs mailing list