Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/map
diff options
context:
space:
mode:
authormpimenov <mpimenov@users.noreply.github.com>2016-09-20 14:46:15 +0300
committerGitHub <noreply@github.com>2016-09-20 14:46:15 +0300
commit5c8dccd40170371adea2bb35f59a6147dc544faf (patch)
treee08f80606d086e061f56e3a67682bf90154ecb82 /map
parent0a5405dbb1859ec77960d3003c14df21595465c4 (diff)
parentb106c294953a88aa31d40773f5ded0d7158de7c6 (diff)
Merge pull request #4323 from ygorshenin/fix-tap-restore
[core] Fixed tap restore.
Diffstat (limited to 'map')
-rw-r--r--map/framework.cpp36
-rw-r--r--map/framework.hpp23
2 files changed, 44 insertions, 15 deletions
diff --git a/map/framework.cpp b/map/framework.cpp
index 5995fd6f94..09e428f08e 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -810,7 +810,7 @@ void Framework::ShowBookmark(BookmarkAndCategory const & bnc)
place_page::Info info;
FillBookmarkInfo(*mark, bnc, info);
ActivateMapSelection(true, df::SelectionShape::OBJECT_USER_MARK, info);
- m_lastTapEvent.reset(new df::TapInfo { m_currentModelView.GtoP(info.GetMercator()), false, false, info.GetID() });
+ m_lastTapEvent = MakeTapEvent(info.GetMercator(), info.GetID(), TapEvent::Source::Other);
}
void Framework::ShowTrack(Track const & track)
@@ -1366,7 +1366,7 @@ void Framework::ShowSearchResult(search::Result const & res)
UserMarkContainer::UserMarkForPoi()->SetPtOrg(center);
ActivateMapSelection(false, df::SelectionShape::OBJECT_POI, info);
- m_lastTapEvent.reset(new df::TapInfo { m_currentModelView.GtoP(center), false, false, info.GetID() });
+ m_lastTapEvent = MakeTapEvent(center, info.GetID(), TapEvent::Source::Search);
}
size_t Framework::ShowSearchResults(search::Results const & results)
@@ -1537,9 +1537,10 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory,
{
GetPlatform().RunOnGuiThread([this, screen](){ OnViewportChanged(screen); });
});
- m_drapeEngine->SetTapEventInfoListener([this](df::TapInfo const & tapInfo)
- {
- GetPlatform().RunOnGuiThread([this, tapInfo](){ OnTapEvent(tapInfo); });
+ m_drapeEngine->SetTapEventInfoListener([this](df::TapInfo const & tapInfo) {
+ GetPlatform().RunOnGuiThread([this, tapInfo]() {
+ OnTapEvent({tapInfo, TapEvent::Source::User});
+ });
});
m_drapeEngine->SetUserPositionListener([this](m2::PointD const & position)
{
@@ -1780,7 +1781,7 @@ bool Framework::ShowMapForURL(string const & url)
FillPointInfo(point, name, info);
ActivateMapSelection(false, df::SelectionShape::OBJECT_POI, info);
}
- m_lastTapEvent.reset(new df::TapInfo{ m_currentModelView.GtoP(info.GetMercator()), false, false, info.GetID() });
+ m_lastTapEvent = MakeTapEvent(info.GetMercator(), info.GetID(), TapEvent::Source::Other);
}
return true;
@@ -1946,16 +1947,18 @@ void Framework::InvalidateUserMarks()
}
}
-void Framework::OnTapEvent(df::TapInfo const & tapInfo)
+void Framework::OnTapEvent(TapEvent const & tapEvent)
{
+ auto const & tapInfo = tapEvent.m_info;
+
bool const somethingWasAlreadySelected = (m_lastTapEvent != nullptr);
place_page::Info info;
- df::SelectionShape::ESelectedObject const selection = OnTapEventImpl(tapInfo, info);
+ df::SelectionShape::ESelectedObject const selection = OnTapEventImpl(tapEvent, info);
if (selection != df::SelectionShape::OBJECT_EMPTY)
{
// Back up last tap event to recover selection in case of Drape reinitialization.
- m_lastTapEvent.reset(new df::TapInfo(tapInfo));
+ m_lastTapEvent = make_unique<TapEvent>(tapEvent);
{ // Log statistics event.
ms::LatLon const ll = info.GetLatLon();
@@ -2023,12 +2026,13 @@ FeatureID Framework::FindBuildingAtPoint(m2::PointD const & mercator) const
return featureId;
}
-df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(df::TapInfo const & tapInfo,
+df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(TapEvent const & tapEvent,
place_page::Info & outInfo) const
{
if (m_drapeEngine == nullptr)
return df::SelectionShape::OBJECT_EMPTY;
+ auto const & tapInfo = tapEvent.m_info;
m2::PointD const pxPoint2d = m_currentModelView.P3dtoP(tapInfo.m_pixelPoint);
if (tapInfo.m_isMyPositionTapped)
@@ -2085,7 +2089,7 @@ df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(df::TapInfo const
FillFeatureInfo(featureTapped, outInfo);
showMapSelection = true;
}
- else if (tapInfo.m_isLong)
+ else if (tapInfo.m_isLong || tapEvent.m_source == TapEvent::Source::Search)
{
FillPointInfo(m_currentModelView.PtoG(pxPoint2d), "", outInfo);
showMapSelection = true;
@@ -2100,6 +2104,14 @@ df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(df::TapInfo const
return df::SelectionShape::OBJECT_EMPTY;
}
+unique_ptr<Framework::TapEvent> Framework::MakeTapEvent(m2::PointD const & center,
+ FeatureID const & fid,
+ TapEvent::Source source) const
+{
+ return make_unique<TapEvent>(df::TapInfo{m_currentModelView.GtoP(center), false, false, fid},
+ source);
+}
+
void Framework::PredictLocation(double & lat, double & lon, double accuracy,
double bearing, double speed, double elapsedSeconds)
{
@@ -2812,7 +2824,7 @@ osm::Editor::SaveResult Framework::SaveEditedMapObject(osm::EditableMapObject em
if (!m_lastTapEvent)
{
// Automatically select newly created objects.
- m_lastTapEvent.reset(new df::TapInfo { m_currentModelView.GtoP(emo.GetMercator()), false, false, emo.GetID() });
+ m_lastTapEvent = MakeTapEvent(emo.GetMercator(), emo.GetID(), TapEvent::Source::Other);
}
auto & editor = osm::Editor::Instance();
diff --git a/map/framework.hpp b/map/framework.hpp
index 64511e7b6c..7d0e78fc19 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -340,12 +340,29 @@ public:
void SetCurrentCountryChangedListener(TCurrentCountryChanged const & listener);
private:
- unique_ptr<df::TapInfo> m_lastTapEvent;
+ struct TapEvent
+ {
+ enum class Source
+ {
+ User,
+ Search,
+ Other
+ };
+
+ TapEvent(df::TapInfo const & info, Source source) : m_info(info), m_source(source) {}
+
+ df::TapInfo const m_info;
+ Source const m_source;
+ };
+
+ unique_ptr<TapEvent> m_lastTapEvent;
- void OnTapEvent(df::TapInfo const & tapInfo);
+ void OnTapEvent(TapEvent const & tapEvent);
/// outInfo is valid only if return value is not df::SelectionShape::OBJECT_EMPTY.
- df::SelectionShape::ESelectedObject OnTapEventImpl(df::TapInfo const & tapInfo,
+ df::SelectionShape::ESelectedObject OnTapEventImpl(TapEvent const & tapEvent,
place_page::Info & outInfo) const;
+ unique_ptr<TapEvent> MakeTapEvent(m2::PointD const & center, FeatureID const & fid,
+ TapEvent::Source source) const;
FeatureID FindBuildingAtPoint(m2::PointD const & mercator) const;
void UpdateMinBuildingsTapZoom();