1
0
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:
Ivan Savenko
2023-09-06 01:06:01 +03:00
parent 9d4d2e0bae
commit 3973624278
11 changed files with 93 additions and 24 deletions

View File

@@ -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