X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FGeometry.cc;h=cdc39474e88bac7f639f9c1e5d263fdff02fe430;hb=e7c332a586280ac1ea9d0f993d637802d64c9f87;hp=0b00b24a5c9f8adba6733208172b91c8c9ab83bb;hpb=25cbe08cb6c46740b63f1259256433558bf38a5f;p=chaz%2Fopenbox diff --git a/src/Geometry.cc b/src/Geometry.cc index 0b00b24a..cdc39474 100644 --- a/src/Geometry.cc +++ b/src/Geometry.cc @@ -102,8 +102,44 @@ void Rect::setH(unsigned int h) { bool Rect::Intersect(const Rect &r) const { return - (x() < (r.x()+r.w()) ) && - ( (x()+w()) > r.x()) && - (y() < (r.y()+r.h()) ) && - ( (y()+h()) > r.y()); + (x() < (r.x()+(signed)r.w()) ) && + ( (x()+(signed)w()) > r.x()) && + (y() < (r.y()+(signed)r.h()) ) && + ( (y()+(signed)h()) > r.y()); +} + +Rect Rect::Inflate(const unsigned int i) const { + return Rect(x(), y(), w()+i, h()+i); +} + +Rect Rect::Inflate(const unsigned int iw, const unsigned int ih) const { + return Rect(x(), y(), w()+iw, h()+ih); +} + +Rect Rect::Inflate(const Size &i) const { + return Rect(x(), y(), w()+i.w(), h()+i.h()); +} + +Rect Rect::Deflate(const unsigned int d) const { + return Rect(x(), y(), w()-d, h()-d); +} + +Rect Rect::Deflate(const unsigned int dw, const unsigned int dh) const { + return Rect(x(), y(), w()-dw, h()-dh); +} + +Rect Rect::Deflate(const Size &d) const { + return Rect(x(), y(), w()-d.w(), h()-d.h()); +} + +Rect Rect::Translate(const int t) const { + return Rect(x()+t, y()+t, w(), h()); +} + +Rect Rect::Translate(const int tx, const int ty) const { + return Rect(x()+tx, y()+ty, w(), h()); +} + +Rect Rect::Translate(const Point &t) const { + return Rect(x()+t.x(), y()+t.y(), w(), h()); }