X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/1aeefd997cc362c3b37c1587c5f08891b35c3a75..3853baab1da16b514f58aeeba93fd29a9d1db3d0:/lib/gdi/erect.h?ds=sidebyside diff --git a/lib/gdi/erect.h b/lib/gdi/erect.h index a67d0fb9..34713ab4 100644 --- a/lib/gdi/erect.h +++ b/lib/gdi/erect.h @@ -52,6 +52,18 @@ public: ePoint bottomRight() const; ePoint topRight() const; ePoint bottomLeft() const; + + /* the sole intention of these functions + is to allow painting frames without + messing around with the coordinates. + they point to the last pixel included + in the rectangle (which means that 1 is + subtracted from the right and bottom + coordinates */ + ePoint topLeft1() const; + ePoint bottomRight1() const; + ePoint topRight1() const; + ePoint bottomLeft1() const; ePoint center() const; void rect( int *x, int *y, int *w, int *h ) const; @@ -107,6 +119,14 @@ public: static eRect emptyRect() { return eRect(0, 0, 0, 0); } static eRect invalidRect() { return eRect(); } + inline void scale(int x_n, int x_d, int y_n, int y_d) + { + x1 *= x_n; x1 /= x_d; + x2 *= x_n; x2 /= x_d; + y1 *= y_n; y1 /= y_d; + y2 *= y_n; y2 /= y_d; + } + private: int x1; int y1; @@ -131,7 +151,7 @@ inline eRect::eRect( int left, int top, int width, int height ) } inline bool eRect::empty() const -{ return x1 == x2 && y1 == y2; } +{ return x1 >= x2 || y1 >= y2; } inline bool eRect::valid() const { return x1 <= x2 && y1 <= y2; } @@ -196,6 +216,18 @@ inline ePoint eRect::topRight() const inline ePoint eRect::bottomLeft() const { return ePoint(x1, y2); } +inline ePoint eRect::topLeft1() const +{ return ePoint(x1, y1); } + +inline ePoint eRect::bottomRight1() const +{ return ePoint(x2-1, y2-1); } + +inline ePoint eRect::topRight1() const +{ return ePoint(x2-1, y1); } + +inline ePoint eRect::bottomLeft1() const +{ return ePoint(x1, y2-1); } + inline ePoint eRect::center() const { return ePoint((x1+x2)/2, (y1+y2)/2); }