X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FGeometry.h;h=0ca914b5dae19a2b5056d09ce1ea30160c6ab580;hb=1b129560d033d6c560bb99e5e8465a3b075623cd;hp=b2454ac61ed778f2ff757e2eaf51b913ebec7416;hpb=24f9448c2efc6daf97a4061cfd6c62da2980c0ad;p=chaz%2Fopenbox diff --git a/src/Geometry.h b/src/Geometry.h index b2454ac6..0ca914b5 100644 --- a/src/Geometry.h +++ b/src/Geometry.h @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#ifndef __geometru_h +#ifndef __geometry_h #define __geometry_h class Point{ @@ -41,19 +41,19 @@ public: }; class Size{ - int m_w, m_h; + unsigned int m_w, m_h; public: Size(); Size(const Size &size); - Size(const int w, const int h); + Size(const unsigned int w, const unsigned int h); - void setW(const int w); - inline int w() const { + void setW(const unsigned int w); + inline unsigned int w() const { return m_w; } - void setH(const int h); - inline int h() const { + void setH(const unsigned int h); + inline unsigned int h() const { return m_h; } }; @@ -64,14 +64,16 @@ class Rect{ public: Rect(); Rect(const Point &origin, const Size &size); - Rect(const int x, const int y, const int w, const int h); + Rect(const int x, const int y, const unsigned int w, const unsigned int h); void setSize(const Size &size); + void setSize(const unsigned int w, const unsigned int h); inline const Size &size() const { return const_cast(m_size); } void setOrigin(const Point &origin); + void setOrigin(const int x, const int y); inline const Point &origin() const { return const_cast(m_origin); } @@ -86,17 +88,29 @@ public: return m_origin.y(); } - void setW(const int w); - inline int w() const { + void setW(const unsigned int w); + inline unsigned int w() const { return m_size.w(); } - void setH(const int h); - inline int h() const { + void setH(const unsigned int h); + inline unsigned int h() const { 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 // __geomtry_h +#endif // __geometry_h