forked from organicmaps/organicmaps
Correct touch rect for catching bookmarks.
This commit is contained in:
parent
57680b9cce
commit
107e4e0adb
5 changed files with 26 additions and 9 deletions
|
@ -225,6 +225,13 @@ void ScreenBase::PtoG(m2::RectD const & pxRect, m2::RectD & glbRect) const
|
|||
glbRect = m2::RectD(PtoG(pxRect.LeftTop()), PtoG(pxRect.RightBottom()));
|
||||
}
|
||||
|
||||
void ScreenBase::GetTouchRect(m2::PointD const & pixPoint, double pixRadius,
|
||||
m2::AnyRectD & glbRect) const
|
||||
{
|
||||
double const r = pixRadius * m_Scale;
|
||||
glbRect = m2::AnyRectD(PtoG(pixPoint), m_Angle, m2::RectD(-r, -r, r, r));
|
||||
}
|
||||
|
||||
bool IsPanningAndRotate(ScreenBase const & s1, ScreenBase const & s2)
|
||||
{
|
||||
m2::RectD const & r1 = s1.GlobalRect().GetLocalRect();
|
||||
|
|
|
@ -97,6 +97,8 @@ public:
|
|||
void GtoP(m2::RectD const & gr, m2::RectD & sr) const;
|
||||
void PtoG(m2::RectD const & pr, m2::RectD & gr) const;
|
||||
|
||||
void GetTouchRect(m2::PointD const & pixPoint, double pixRadius, m2::AnyRectD & glbRect) const;
|
||||
|
||||
math::Matrix<double, 3, 3> const & GtoPMatrix() const;
|
||||
math::Matrix<double, 3, 3> const & PtoGMatrix() const;
|
||||
|
||||
|
|
|
@ -422,9 +422,9 @@ BookmarkAndCategory Framework::GetBookmark(m2::PointD const & pxPoint) const
|
|||
BookmarkAndCategory Framework::GetBookmark(m2::PointD const & pxPoint, double visualScale) const
|
||||
{
|
||||
// Get the global rect of touching area.
|
||||
int const sm = TOUCH_PIXEL_RADIUS * visualScale;
|
||||
m2::RectD rect(PtoG(m2::PointD(pxPoint.x - sm, pxPoint.y - sm)),
|
||||
PtoG(m2::PointD(pxPoint.x + sm, pxPoint.y + sm)));
|
||||
m2::AnyRectD rect;
|
||||
m_navigator.GetTouchRect(pxPoint, TOUCH_PIXEL_RADIUS * visualScale, rect);
|
||||
m2::PointD const center = rect.GlobalCenter();
|
||||
|
||||
int retBookmarkCategory = -1;
|
||||
int retBookmark = -1;
|
||||
|
@ -438,7 +438,7 @@ BookmarkAndCategory Framework::GetBookmark(m2::PointD const & pxPoint, double vi
|
|||
m2::PointD const pt = m_bmManager.AdditionalPoiLayerGetBookmark(i)->GetOrg();
|
||||
if (rect.IsPointInside(pt))
|
||||
{
|
||||
double const d = rect.Center().SquareLength(pt);
|
||||
double const d = center.SquareLength(pt);
|
||||
if (d < minD)
|
||||
{
|
||||
retBookmarkCategory = static_cast<int>(additionalLayerCategory);
|
||||
|
@ -463,7 +463,7 @@ BookmarkAndCategory Framework::GetBookmark(m2::PointD const & pxPoint, double vi
|
|||
|
||||
if (rect.IsPointInside(pt))
|
||||
{
|
||||
double const d = rect.Center().SquareLength(pt);
|
||||
double const d = center.SquareLength(pt);
|
||||
if ((currentCategoryIsVisible && !returnBookmarkIsVisible) ||
|
||||
(d < minD))
|
||||
{
|
||||
|
@ -1601,9 +1601,10 @@ void Framework::DrawMapApiPoints(shared_ptr<PaintEvent> const & e)
|
|||
/// @todo Create method that will run all layers without copy/past
|
||||
bool Framework::GetMapApiPoint(m2::PointD const & pxPoint, url_scheme::ApiPoint & point)
|
||||
{
|
||||
int const sm = TOUCH_PIXEL_RADIUS * GetVisualScale();
|
||||
m2::RectD const rect(PtoG(m2::PointD(pxPoint.x - sm, pxPoint.y - sm)),
|
||||
PtoG(m2::PointD(pxPoint.x + sm, pxPoint.y + sm)));
|
||||
m2::AnyRectD rect;
|
||||
m_navigator.GetTouchRect(pxPoint, TOUCH_PIXEL_RADIUS * GetVisualScale(), rect);
|
||||
m2::PointD const center = rect.GlobalCenter();
|
||||
|
||||
double minD = numeric_limits<double>::max();
|
||||
bool result = false;
|
||||
|
||||
|
@ -1615,7 +1616,7 @@ bool Framework::GetMapApiPoint(m2::PointD const & pxPoint, url_scheme::ApiPoint
|
|||
MercatorBounds::LatToY(vect[i].m_lat)));
|
||||
if (rect.IsPointInside(pt))
|
||||
{
|
||||
double const d = rect.Center().SquareLength(pt);
|
||||
double const d = center.SquareLength(pt);
|
||||
if (d < minD)
|
||||
{
|
||||
point = vect[i];
|
||||
|
|
|
@ -118,6 +118,11 @@ m2::PointD Navigator::PtoG(m2::PointD const & pt) const
|
|||
return m_Screen.PtoG(ShiftPoint(pt));
|
||||
}
|
||||
|
||||
void Navigator::GetTouchRect(m2::PointD const & pixPoint, double pixRadius, m2::AnyRectD & glbRect) const
|
||||
{
|
||||
m_Screen.GetTouchRect(ShiftPoint(pixPoint), pixRadius, glbRect);
|
||||
}
|
||||
|
||||
bool Navigator::CanShrinkInto(ScreenBase const & screen, m2::RectD const & boundRect)
|
||||
{
|
||||
m2::RectD clipRect = screen.ClipRect();
|
||||
|
|
|
@ -28,6 +28,8 @@ public:
|
|||
m2::PointD GtoP(m2::PointD const & pt) const;
|
||||
m2::PointD PtoG(m2::PointD const & pt) const;
|
||||
|
||||
void GetTouchRect(m2::PointD const & pixPoint, double pixRadius, m2::AnyRectD & glbRect) const;
|
||||
|
||||
void StartDrag(m2::PointD const & pt, double timeInSec);
|
||||
void DoDrag(m2::PointD const & pt, double timeInSec);
|
||||
void StopDrag(m2::PointD const & pt, double timeInSec, bool animate);
|
||||
|
|
Loading…
Add table
Reference in a new issue