mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Implemented tolerance for touch events
This commit is contained in:
@@ -136,4 +136,12 @@ Rect Rect::intersect(const Rect & other) const
|
||||
}
|
||||
}
|
||||
|
||||
int Rect::distanceTo(const Point & target) const
|
||||
{
|
||||
int distanceX = std::max({left() - target.x, 0, target.x - right()});
|
||||
int distanceY = std::max({top() - target.y, 0, target.y - bottom()});
|
||||
|
||||
return Point(distanceX, distanceY).length();
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
Reference in New Issue
Block a user