8 #include "vstguibase.h" 20 inline CRect (CCoord left, CCoord top, CCoord right, CCoord bottom);
24 inline CRect& operator () (CCoord left, CCoord top, CCoord right, CCoord bottom);
25 inline bool operator != (
const CRect& other)
const;
26 inline bool operator == (
const CRect& other)
const;
28 inline CCoord getWidth ()
const;
29 inline CCoord getHeight ()
const;
31 inline CRect& setWidth (CCoord width);
32 inline CRect& setHeight (CCoord height);
34 inline CPoint getTopLeft ()
const;
35 inline CPoint getTopRight ()
const;
36 inline CPoint getBottomLeft ()
const;
37 inline CPoint getBottomRight ()
const;
40 inline CRect& setBottomLeft (
const CPoint& inPoint);
41 inline CRect& setBottomRight (
const CPoint& inPoint);
43 inline CPoint getCenter ()
const;
45 inline CPoint getSize ()
const;
48 inline CRect& offset (CCoord c);
49 inline CRect& offset (CCoord x, CCoord y);
50 inline CRect& inset (CCoord deltaX, CCoord deltaY);
51 inline CRect& extend (CCoord deltaX, CCoord deltaY);
52 inline CRect& moveTo (CCoord x, CCoord y);
61 inline bool isEmpty ()
const;
62 inline bool rectOverlap (
const CRect& rect)
const;
65 inline CRect& normalize ();
66 inline CRect& originize ();
68 inline CRect& makeIntegral ();
77 inline CRect::CRect (CCoord left, CCoord top, CCoord right, CCoord bottom)
78 : left (left), top (top), right (right), bottom (bottom)
82 inline CRect::CRect (
const CRect& r)
83 : left (r.left), top (r.top), right (r.right), bottom (r.bottom)
87 inline CRect::CRect (
const CPoint& origin,
const CPoint& size)
94 CRect& CRect::operator () (CCoord _left, CCoord _top, CCoord _right, CCoord _bottom)
120 bool CRect::operator != (
const CRect& other)
const 122 return (left != other.left || right != other.right ||
123 top != other.top || bottom != other.bottom);
127 bool CRect::operator == (
const CRect& other)
const 129 return (left == other.left && right == other.right &&
130 top == other.top && bottom == other.bottom);
134 inline CCoord CRect::getWidth ()
const 140 inline CCoord CRect::getHeight ()
const 146 inline CRect& CRect::setWidth (CCoord width)
148 right = left + width;
153 inline CRect& CRect::setHeight (CCoord height)
155 bottom = top + height;
160 inline CRect& CRect::offset (CCoord c)
162 return offset (c, c);
166 inline CRect& CRect::offset (CCoord x, CCoord y)
176 inline CRect& CRect::inset (CCoord deltaX, CCoord deltaY)
186 inline CRect& CRect::extend (CCoord deltaX, CCoord deltaY)
188 return inset (-deltaX, -deltaY);
192 inline CRect& CRect::moveTo (CCoord x, CCoord y)
194 CCoord vDiff = y - top;
195 CCoord hDiff = x - left;
204 inline bool CRect::isEmpty ()
const 214 inline bool CRect::rectOverlap (
const CRect& rect)
const 216 if (right < rect.left)
218 if (left > rect.right)
220 if (bottom < rect.top)
222 if (top > rect.bottom)
228 inline CRect& CRect::bound (
const CRect& rect)
230 if (left < rect.left)
234 if (right > rect.right)
236 if (bottom > rect.bottom)
237 bottom = rect.bottom;
246 inline CRect& CRect::normalize ()
249 std::swap (left, right);
251 std::swap (top, bottom);
256 inline CRect& CRect::originize ()
258 return offset (-left, -top);
262 inline CRect& CRect::unite (
const CRect& rect)
264 if (left > rect.left)
266 if (right < rect.right)
270 if (bottom < rect.bottom)
271 bottom = rect.bottom;
276 inline CRect& CRect::makeIntegral ()
278 left = std::floor (left + 0.5);
279 right = std::floor (right + 0.5);
280 top = std::floor (top + 0.5);
281 bottom = std::floor (bottom + 0.5);
288 return where.x >= left && where.x < right && where.y >= top && where.y < bottom;
292 inline CPoint CRect::getTopLeft ()
const 294 CPoint myPoint (left, top);
299 inline CPoint CRect::getTopRight ()
const 301 CPoint myPoint (right, top);
306 inline CPoint CRect::getBottomLeft ()
const 308 CPoint myPoint (left, bottom);
313 inline CPoint CRect::getBottomRight ()
const 315 CPoint myPoint (right, bottom);
320 inline CRect& CRect::setTopLeft (
const CPoint& inPoint)
328 inline CRect& CRect::setTopRight (
const CPoint& inPoint)
336 inline CRect& CRect::setBottomLeft (
const CPoint& inPoint)
344 inline CRect& CRect::setBottomRight (
const CPoint& inPoint)
352 inline CPoint CRect::getCenter ()
const 354 CPoint myPoint (left + getWidth () / 2., top + getHeight () / 2.);
359 inline CPoint CRect::getSize ()
const 361 CPoint myPoint (getWidth (), getHeight ());
366 inline CRect& CRect::setSize (
const CPoint& size)
369 return setHeight (size.y);
375 CPoint cp = r.getCenter ();
376 CPoint cp2 = getCenter ();
377 return offset (cp.x - cp2.x, cp.y - cp2.y);
383 return offset (p.x, p.y);
387 inline CRect& CRect::inset (
const CPoint& p)
389 return inset (p.x, p.y);
393 inline CRect& CRect::extend (
const CPoint& p)
395 return extend (p.x, p.y);
399 inline CRect& CRect::moveTo (
const CPoint& p)
401 return moveTo (p.x, p.y);
405 inline CRect& CRect::offsetInverse (
const CPoint& p)
407 return offset (-p.x, -p.y);
Rect structure.
Definition: crect.h:17
bool pointInside(const CPoint &where) const
Checks if point is inside this rect.
Definition: crect.h:286
Definition: customcontrols.cpp:8
CRect & centerInside(const CRect &r)
moves this rect to the center of r
Definition: crect.h:373
Point structure.
Definition: cpoint.h:17