Fixed showing mark routine.

This commit is contained in:
vng 2014-06-05 19:47:03 +03:00 committed by Alex Zolotarev
parent 54877816d2
commit a1688c0fe9
11 changed files with 58 additions and 38 deletions

View file

@ -251,7 +251,9 @@ const long long LITE_IDL = 431183278L;
{
CGFloat const scaleFactor = self.view.contentScaleFactor;
m2::PointD pxClicked(point.x * scaleFactor, point.y * scaleFactor);
GetFramework().GetBalloonManager().OnClick(m2::PointD(pxClicked.x, pxClicked.y), isLongClick);
Framework & f = GetFramework();
f.GetBalloonManager().OnShowMark(f.GetUserMark(m2::PointD(pxClicked.x, pxClicked.y), isLongClick));
}
- (void)onSingleTap:(NSValue *)point

View file

@ -240,7 +240,7 @@ __weak SearchView * selfPointer;
{
search::SearchParams params = [self searchParameters];
params.SetPosition(info.m_latitude, info.m_longitude);
GetFramework().Search(params);
GetFramework().Search(params, false);
[self recalculateDistances];
[self.tableView reloadRowsAtIndexPaths:self.tableView.indexPathsForVisibleRows withRowAnimation:UITableViewRowAnimationNone];

View file

@ -15,6 +15,7 @@
#include "../gui/controller.hpp"
PinClickManager::PinClickManager(Framework & f)
: m_f(f)
{}
@ -24,9 +25,8 @@ void PinClickManager::Hide()
m_f.Invalidate();
}
void PinClickManager::OnClick(m2::PointD const & pxPoint, bool isLongTouch)
void PinClickManager::OnShowMark(UserMark const * mark)
{
UserMark const * mark = m_f.GetUserMark(pxPoint, isLongTouch);
if (mark != NULL)
OnActivateUserMark(mark->Copy());
SetBalloonVisible(mark != NULL);
@ -35,7 +35,7 @@ void PinClickManager::OnClick(m2::PointD const & pxPoint, bool isLongTouch)
void PinClickManager::OnBookmarkClick(BookmarkAndCategory const & bnc)
{
Bookmark * mark = m_f.GetBmCategory(bnc.first)->GetBookmark(bnc.second);
m_f.GetBookmarkManager ().ActivateMark(mark);
m_f.GetBookmarkManager().ActivateMark(mark);
SetBalloonVisible(true);
}

View file

@ -30,9 +30,10 @@ public:
void RenderPolicyCreated(graphics::EDensity density) {}
void LocationChanged(location::GpsInfo const & info) {}
void OnClick(m2::PointD const & pxPoint, bool isLongTouch);
void OnBookmarkClick(BookmarkAndCategory const & bnc);
void OnShowMark(UserMark const * mark);
void Hide();
void RemovePin();
@ -42,8 +43,8 @@ private:
/// @name Platform dependent listeners to show special activities.
//@{
// You must delete UserMarkCopy obtained by this callback
function<void (UserMarkCopy *)> m_userMarkListener;
function<void (void)> m_dismissListener;
function<void (UserMarkCopy *)> m_userMarkListener;
function<void (void)> m_dismissListener;
public:
template <class T> void ConnectUserMarkListener(T const & t) { m_userMarkListener = t; }

View file

@ -1118,7 +1118,7 @@ void Framework::PrepareSearch(bool hasPt, double lat, double lon)
GetSearchEngine()->PrepareSearch(GetCurrentViewport(), hasPt, lat, lon);
}
bool Framework::Search(search::SearchParams const & params)
bool Framework::Search(search::SearchParams const & params, bool saveQuery /*= true*/)
{
#ifdef FIXED_LOCATION
search::SearchParams rParams(params);
@ -1133,7 +1133,8 @@ bool Framework::Search(search::SearchParams const & params)
if (GetSearchEngine()->Search(rParams, GetCurrentViewport()))
{
m_lastSearch = rParams;
if (saveQuery)
m_lastSearch = rParams;
return true;
}
else
@ -1160,14 +1161,16 @@ void Framework::ShowSearchResult(search::Result const & res)
m_bmManager.UserMarksSetVisible(type, true);
m_bmManager.UserMarksClear(type);
m_lastSearch.Clear();
search::AddressInfo info;
info.MakeFrom(res);
m2::PointD ptOrg = res.GetFeatureCenter();
m2::PointD const ptOrg = res.GetFeatureCenter();
SearchMarkPoint * mark = static_cast<SearchMarkPoint *>(m_bmManager.UserMarksAddMark(type, ptOrg));
mark->SetInfo(info);
m_balloonManager.OnClick(GtoP(mark->GetOrg()), true);
m_balloonManager.OnShowMark(mark);
int scale;
m2::PointD center;
@ -1392,8 +1395,10 @@ anim::Controller * Framework::GetAnimController() const
bool Framework::ShowMapForURL(string const & url)
{
m2::PointD clickPoint;
m2::PointD point;
m2::RectD rect;
string name;
UserMark const * apiMark = 0;
enum ResultT { FAILED, NEED_CLICK, NO_NEED_CLICK };
ResultT result = FAILED;
@ -1410,9 +1415,8 @@ bool Framework::ShowMapForURL(string const & url)
ParseGeoURL(url, info);
if (info.IsValid())
{
clickPoint = m2::PointD(MercatorBounds::LonToX(info.m_lon),
MercatorBounds::LatToY(info.m_lat));
rect = m_scales.GetRectForDrawScale(info.m_zoom, clickPoint);
point = m2::PointD(MercatorBounds::LonToX(info.m_lon), MercatorBounds::LatToY(info.m_lat));
rect = m_scales.GetRectForDrawScale(info.m_zoom, point);
result = NEED_CLICK;
}
}
@ -1424,9 +1428,9 @@ bool Framework::ShowMapForURL(string const & url)
if (parser.Parse(url, pt, zoom))
{
clickPoint = m2::PointD(MercatorBounds::LonToX(pt.m_lon),
MercatorBounds::LatToY(pt.m_lat));
rect = m_scales.GetRectForDrawScale(zoom, clickPoint);
point = m2::PointD(MercatorBounds::LonToX(pt.m_lon), MercatorBounds::LatToY(pt.m_lat));
rect = m_scales.GetRectForDrawScale(zoom, point);
name = pt.m_name;
result = NEED_CLICK;
}
}
@ -1437,7 +1441,7 @@ bool Framework::ShowMapForURL(string const & url)
if (!m_ParsedMapApi.GetViewportRect(m_scales, rect))
rect = ScalesProcessor::GetWorldRect();
if (m_ParsedMapApi.GetSinglePoint(clickPoint))
if (apiMark = m_ParsedMapApi.GetSinglePoint())
result = NEED_CLICK;
else
result = NO_NEED_CLICK;
@ -1448,10 +1452,21 @@ bool Framework::ShowMapForURL(string const & url)
{
// set viewport and stop follow mode if any
StopLocationFollow();
SetViewPortASync(rect);
ShowRectExVisibleScale(rect);
if (result != NO_NEED_CLICK)
m_balloonManager.OnClick(GtoP(clickPoint), true);
{
if (apiMark)
m_balloonManager.OnShowMark(apiMark);
else
{
PoiMarkPoint * mark = GetAddressMark(point);
if (!name.empty())
mark->SetName(name);
m_balloonManager.OnShowMark(mark);
}
}
return true;
}
else
@ -1569,7 +1584,7 @@ void Framework::ActivateUserMark(UserMark const * mark)
m_bmManager.ActivateMark(mark);
}
UserMark const * Framework::GetUserMark(m2::PointD const & pxPoint, bool isLongPress)
UserMark const * Framework::GetUserMark(m2::PointD const & pxPoint, bool isLongPress) const
{
m2::AnyRectD rect;
m_navigator.GetTouchRect(pxPoint, TOUCH_PIXEL_RADIUS * GetVisualScale(), rect);
@ -1596,10 +1611,11 @@ UserMark const * Framework::GetUserMark(m2::PointD const & pxPoint, bool isLongP
mark = poiMark;
}
}
return mark;
}
UserMark const * Framework::GetAddressMark(m2::PointD const & globalPoint)
PoiMarkPoint * Framework::GetAddressMark(m2::PointD const & globalPoint) const
{
search::AddressInfo info;
GetAddressInfoForGlobalPoint(globalPoint, info);
@ -1608,7 +1624,7 @@ UserMark const * Framework::GetAddressMark(m2::PointD const & globalPoint)
return mark;
}
BookmarkAndCategory Framework::FindBookmark(UserMark const * mark)
BookmarkAndCategory Framework::FindBookmark(UserMark const * mark) const
{
BookmarkAndCategory empty = MakeEmptyBookmarkAndCategory();
BookmarkAndCategory result = empty;

View file

@ -248,8 +248,6 @@ private:
search::Engine * GetSearchEngine() const;
search::SearchParams m_lastSearch;
void UpdateUserViewportChanged();
void OnSearchResultsCallback(search::Results const & results);
void OnSearchResultsCallbackUI(search::Results const & results);
void FillSearchResultsMarks(search::Results const & results, m2::RectD & rect);
@ -257,12 +255,14 @@ private:
public:
m2::RectD GetCurrentViewport() const;
void UpdateUserViewportChanged();
/// Call this function before entering search GUI.
/// While it's loading, we can cache features near user's position.
/// @param[in] hasPt Are (lat, lon) valid
/// @param[in] (lat, lon) Current user's position
void PrepareSearch(bool hasPt, double lat = 0.0, double lon = 0.0);
bool Search(search::SearchParams const & params);
bool Search(search::SearchParams const & params, bool saveQuery = true);
bool GetCurrentPosition(double & lat, double & lon) const;
void ShowSearchResult(search::Result const & res);
@ -437,9 +437,9 @@ public:
shared_ptr<location::State> const & GetLocationState() const;
void ActivateUserMark(UserMark const * mark);
UserMark const * GetUserMark(m2::PointD const & pxPoint, bool isLongPress);
UserMark const * GetAddressMark(m2::PointD const & globalPoint);
BookmarkAndCategory FindBookmark(UserMark const * mark);
UserMark const * GetUserMark(m2::PointD const & pxPoint, bool isLongPress) const;
PoiMarkPoint * GetAddressMark(m2::PointD const & globalPoint) const;
BookmarkAndCategory FindBookmark(UserMark const * mark) const;
public:
string CodeGe0url(Bookmark const * bmk, bool addName);

View file

@ -26,6 +26,7 @@ void MoveScreenTask::OnEnd(double ts)
anim::SegmentInterpolation::OnEnd(ts);
Navigator & nav = m_framework->GetNavigator();
nav.SetOrg(m_outPt);
m_framework->UpdateUserViewportChanged();
}
bool MoveScreenTask::IsVisual() const

View file

@ -191,14 +191,13 @@ bool ParsedMapApi::GetViewportRect(ScalesProcessor const & scales, m2::RectD & r
}
}
bool ParsedMapApi::GetSinglePoint(m2::PointD & point) const
UserMark const * ParsedMapApi::GetSinglePoint() const
{
ASSERT(m_controller != NULL, ());
if (m_controller->GetUserMarkCount() != 1)
return false;
return 0;
point = m_controller->GetUserMark(0)->GetOrg();
return true;
return m_controller->GetUserMark(0);
}
}

View file

@ -39,7 +39,7 @@ public:
/// @name Used in settings map viewport after invoking API.
bool GetViewportRect(ScalesProcessor const & scales, m2::RectD & rect) const;
bool GetSinglePoint(m2::PointD & point) const;
UserMark const * GetSinglePoint() const;
private:
bool Parse(Uri const & uri);

View file

@ -127,7 +127,7 @@ public:
return new UserMarkCopy(new SearchMarkPoint(m_info, m_ptOrg, m_container));
}
private:
protected:
search::AddressInfo m_info;
};
@ -144,6 +144,7 @@ public:
}
void SetPtOrg(m2::PointD const & ptOrg) { m_ptOrg = ptOrg; }
void SetName(string const & name) { m_info.m_name = name; }
};
class ICustomDrawable : public UserMark

View file

@ -336,7 +336,7 @@ namespace qt
void DrawWidget::OnPressTaskEvent(m2::PointD const & pt, unsigned ms)
{
m_wasLongClick = (ms == LONG_TOUCH_MS);
GetBalloonManager().OnClick(pt, m_wasLongClick);
GetBalloonManager().OnShowMark(m_framework->GetUserMark(pt, m_wasLongClick));
}
m2::PointD DrawWidget::GetDevicePoint(QMouseEvent * e) const