all repos — openbox @ 83b39a9a3e366d9bc4baadb7c988b874cfe25a08

openbox fork - make it a bit more like ryudo

added Inflate, Deflate, and Translate to the Rect geometry class
Dana Jansens danakj@orodu.net
commit

83b39a9a3e366d9bc4baadb7c988b874cfe25a08

parent

13ac6f2abd09ea0f8bbdd8f3131115200cadc225

2 files changed, 48 insertions(+), 0 deletions(-)

jump to
M src/Geometry.ccsrc/Geometry.cc

@@ -107,3 +107,39 @@ ( (x()+w()) > r.x()) &&

(y() < (r.y()+r.h()) ) && ( (y()+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()); +}
M src/Geometry.hsrc/Geometry.h

@@ -99,6 +99,18 @@ return m_size.h();

} bool Intersect(const Rect &r) const; + // returns a rect that is this rect increased in size by the passed in amount + Rect Inflate(const unsigned int i) const; + Rect Inflate(const unsigned int iw, const unsigned int ih) const; + Rect Inflate(const Size &i) const; + // returns a rect that is this rect decreased in size by the passed in amount + Rect Deflate(const unsigned int d) const; + Rect Deflate(const unsigned int dw, const unsigned int dh) const; + Rect Deflate(const Size &d) const; + // returns a rect that is moved the amount specified + Rect Translate(const int t) const; + Rect Translate(const int tx, const int ty) const; + Rect Translate(const Point &t) const; }; #endif // __geometry_h