X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FGeometry.cc;h=cdc39474e88bac7f639f9c1e5d263fdff02fe430;hb=f75083669f65aadd6b32f8ed25880ca362296a2f;hp=e9fa2b9eb2be33fb516ff4d0db3cc86951d24020;hpb=24f9448c2efc6daf97a4061cfd6c62da2980c0ad;p=chaz%2Fopenbox diff --git a/src/Geometry.cc b/src/Geometry.cc index e9fa2b9e..cdc39474 100644 --- a/src/Geometry.cc +++ b/src/Geometry.cc @@ -30,11 +30,11 @@ Point::Point(const Point &point) : m_x(point.m_x), m_y(point.m_y) { Point::Point(const int x, const int y) : m_x(x), m_y(y) { } -inline void Point::setX(const int x) { +void Point::setX(const int x) { m_x = x; } -inline void Point::setY(const int y) { +void Point::setY(const int y) { m_y = y; } @@ -44,14 +44,14 @@ Size::Size() : m_w(0), m_h(0) { Size::Size(const Size &size) : m_w(size.m_w), m_h(size.m_h) { } -Size::Size(const int w, const int h) : m_w(w), m_h(h) { +Size::Size(const unsigned int w, const unsigned int h) : m_w(w), m_h(h) { } -inline void Size::setW(const int w) { +void Size::setW(const unsigned int w) { m_w = w; } -inline void Size::setH(const int h) { +void Size::setH(const unsigned int h) { m_h = h; } @@ -62,18 +62,28 @@ Rect::Rect(const Point &origin, const Size &size) : m_origin(origin), m_size(size) { } -Rect::Rect(const int x, const int y, const int w, const int h) : m_origin(x, y), - m_size(w, h) { +Rect::Rect(const int x, const int y, const unsigned int w, const unsigned int h) + : m_origin(x, y), m_size(w, h) { } void Rect::setSize(const Size &size) { m_size = size; } +void Rect::setSize(const unsigned int w, const unsigned int h) { + m_size.setW(w); + m_size.setH(h); +} + void Rect::setOrigin(const Point &origin) { m_origin = origin; } +void Rect::setOrigin(const int x, const int y) { + m_origin.setX(x); + m_origin.setY(y); +} + void Rect::setX(const int x) { m_origin.setX(x); } @@ -82,18 +92,54 @@ void Rect::setY(const int y) { m_origin.setY(y); } -void Rect::setW(int w) { +void Rect::setW(unsigned int w) { m_size.setW(w); } -void Rect::setH(int h) { +void Rect::setH(unsigned int h) { m_size.setH(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()); }