Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/ghost/GHOST_Rect.h')
-rw-r--r--intern/ghost/GHOST_Rect.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/intern/ghost/GHOST_Rect.h b/intern/ghost/GHOST_Rect.h
index 6271ecad408..98169ad2aa4 100644
--- a/intern/ghost/GHOST_Rect.h
+++ b/intern/ghost/GHOST_Rect.h
@@ -127,6 +127,13 @@ public:
virtual inline void unionPoint(GHOST_TInt32 x, GHOST_TInt32 y);
/**
+ * Grows the rectangle to included a point.
+ * @param x The x-coordinate of the point.
+ * @param y The y-coordinate of the point.
+ */
+ virtual inline void wrapPoint(GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32 ofs);
+
+ /**
* Returns whether the point is inside this rectangle.
* Point on the boundary is considered inside.
* @param x x-coordinate of point to test.
@@ -222,6 +229,21 @@ inline void GHOST_Rect::unionPoint(GHOST_TInt32 x, GHOST_TInt32 y)
if (y > m_b) m_b = y;
}
+inline void GHOST_Rect::wrapPoint(GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32 ofs)
+{
+ GHOST_TInt32 w= getWidth();
+ GHOST_TInt32 h= getHeight();
+
+ /* highly unlikely but avoid eternal loop */
+ if(w-ofs <= 0 || h-ofs <= 0)
+ return;
+
+ while(x-ofs < m_l) x+= w;
+ while(y-ofs < m_t) y+= h;
+ while(x+ofs > m_r) x-= w;
+ while(y+ofs > m_b) y-= h;
+}
+
inline bool GHOST_Rect::isInside(GHOST_TInt32 x, GHOST_TInt32 y) const
{
return (x >= m_l) && (x <= m_r) && (y >= m_t) && (y <= m_b);