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:
authorCampbell Barton <ideasman42@gmail.com>2019-05-28 17:48:48 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-28 17:52:43 +0300
commite4ac8ab212769b569334d0cd15d4bf04f42cbc89 (patch)
tree62cc58acd12f6f1bf974ff810900fa231d918354 /intern/ghost/GHOST_Rect.h
parenta7ebb4b7d96b129d3ac1950ee415754b282bfbc4 (diff)
WM: support X/Y axis cursor wrapping
Operator flags to wrap on a single axis. D4865 by @Gvgeo with updates. Resolves T64585
Diffstat (limited to 'intern/ghost/GHOST_Rect.h')
-rw-r--r--intern/ghost/GHOST_Rect.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/intern/ghost/GHOST_Rect.h b/intern/ghost/GHOST_Rect.h
index 831d3ef1445..88053f83fb9 100644
--- a/intern/ghost/GHOST_Rect.h
+++ b/intern/ghost/GHOST_Rect.h
@@ -125,7 +125,10 @@ class GHOST_Rect {
* \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);
+ virtual inline void wrapPoint(GHOST_TInt32 &x,
+ GHOST_TInt32 &y,
+ GHOST_TInt32 ofs,
+ GHOST_TAxisFlag axis);
/**
* Returns whether the point is inside this rectangle.
@@ -236,7 +239,11 @@ 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)
+
+inline void GHOST_Rect::wrapPoint(GHOST_TInt32 &x,
+ GHOST_TInt32 &y,
+ GHOST_TInt32 ofs,
+ GHOST_TAxisFlag axis)
{
GHOST_TInt32 w = getWidth();
GHOST_TInt32 h = getHeight();
@@ -246,14 +253,18 @@ inline void GHOST_Rect::wrapPoint(GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32
return;
}
- while (x - ofs < m_l)
- x += w - (ofs * 2);
- while (y - ofs < m_t)
- y += h - (ofs * 2);
- while (x + ofs > m_r)
- x -= w - (ofs * 2);
- while (y + ofs > m_b)
- y -= h - (ofs * 2);
+ if (axis & GHOST_kAxisX) {
+ while (x - ofs < m_l)
+ x += w - (ofs * 2);
+ while (x + ofs > m_r)
+ x -= w - (ofs * 2);
+ }
+ if (axis & GHOST_kGrabAxisY) {
+ while (y - ofs < m_t)
+ y += h - (ofs * 2);
+ while (y + ofs > m_b)
+ y -= h - (ofs * 2);
+ }
}
inline bool GHOST_Rect::isInside(GHOST_TInt32 x, GHOST_TInt32 y) const