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
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2016-02-07 12:34:10 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:16:53 +0300
commitb7b08920aa17ddb2514fc7dc83a794d7ef11a193 (patch)
treea9eab58cc6106ff1f3e7e752f1ace1cd3638bfa9
parentddb15b90597e15a8ea3602582f630722ec8d9498 (diff)
Minor tapEvent refactoring: reused already defined struct.
-rw-r--r--drape_frontend/drape_engine.cpp6
-rw-r--r--drape_frontend/drape_engine.hpp2
-rwxr-xr-xdrape_frontend/frontend_renderer.cpp2
-rwxr-xr-xdrape_frontend/frontend_renderer.hpp9
-rw-r--r--map/framework.cpp46
-rw-r--r--map/framework.hpp15
6 files changed, 37 insertions, 43 deletions
diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp
index c305b20a9e..1d75e681e6 100644
--- a/drape_frontend/drape_engine.cpp
+++ b/drape_frontend/drape_engine.cpp
@@ -59,7 +59,7 @@ DrapeEngine::DrapeEngine(Params && params)
make_ref(m_textureManager), m_viewport,
bind(&DrapeEngine::ModelViewChanged, this, _1),
params.m_model.GetIsCountryLoadedFn(),
- bind(&DrapeEngine::TapEvent, this, _1, _2, _3, _4),
+ bind(&DrapeEngine::TapEvent, this, _1),
bind(&DrapeEngine::UserPositionChanged, this, _1),
bind(&DrapeEngine::MyPositionModeChanged, this, _1),
mode, make_ref(m_requestedTiles), params.m_allow3dBuildings);
@@ -235,12 +235,12 @@ void DrapeEngine::MyPositionModeChanged(location::EMyPositionMode mode)
});
}
-void DrapeEngine::TapEvent(m2::PointD const & pxPoint, bool isLong, bool isMyPosition, FeatureID const & feature)
+void DrapeEngine::TapEvent(TapInfo const & tapInfo)
{
GetPlatform().RunOnGuiThread([=]()
{
if (m_tapListener)
- m_tapListener(pxPoint, isLong, isMyPosition, feature);
+ m_tapListener(tapInfo);
});
}
diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp
index 05691ce3a7..4627cd5baf 100644
--- a/drape_frontend/drape_engine.hpp
+++ b/drape_frontend/drape_engine.hpp
@@ -131,7 +131,7 @@ private:
void ModelViewChangedGuiThread(ScreenBase const & screen);
void MyPositionModeChanged(location::EMyPositionMode mode);
- void TapEvent(m2::PointD const & pxPoint, bool isLong, bool isMyPosition, FeatureID const & feature);
+ void TapEvent(TapInfo const & tapInfo);
void UserPositionChanged(m2::PointD const & position);
void ResizeImpl(int w, int h);
diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp
index 6b02ab7286..e6c51bc50a 100755
--- a/drape_frontend/frontend_renderer.cpp
+++ b/drape_frontend/frontend_renderer.cpp
@@ -1211,7 +1211,7 @@ void FrontendRenderer::OnTap(m2::PointD const & pt, bool isLongTap)
isMyPosition = selectRect.IsPointInside(pt);
}
- m_tapEventInfoFn(pt, isLongTap, isMyPosition, GetVisiblePOI(selectRect));
+ m_tapEventInfoFn({pt, isLongTap, isMyPosition, GetVisiblePOI(selectRect)});
}
void FrontendRenderer::OnForceTap(m2::PointD const & pt)
diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp
index 9761c77aaa..b4053cffcf 100755
--- a/drape_frontend/frontend_renderer.hpp
+++ b/drape_frontend/frontend_renderer.hpp
@@ -54,10 +54,9 @@ class TransparentLayer;
struct TapInfo
{
m2::PointD const m_pixelPoint;
- bool m_isLong;
-
- bool m_isMyPositionTapped;
- FeatureID m_featureTapped;
+ bool const m_isLong;
+ bool const m_isMyPositionTapped;
+ FeatureID const m_featureTapped;
};
class FrontendRenderer : public BaseRenderer
@@ -67,7 +66,7 @@ class FrontendRenderer : public BaseRenderer
public:
using TModelViewChanged = function<void (ScreenBase const & screen)>;
using TIsCountryLoaded = TIsCountryLoaded;
- using TTapEventInfoFn = function<void (m2::PointD const & pxPoint, bool isLong, bool isMyPosition, FeatureID const & id)>;
+ using TTapEventInfoFn = function<void (TapInfo const &)>;
using TUserPositionChangedFn = function<void (m2::PointD const & pt)>;
struct Params : BaseRenderer::Params
diff --git a/map/framework.cpp b/map/framework.cpp
index 563f835509..14d7f9bec2 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -1439,7 +1439,7 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory,
if (GetDrawScale() <= scales::GetUpperWorldScale())
m_autoDownloadingOn = true;
});
- m_drapeEngine->SetTapEventInfoListener(bind(&Framework::OnTapEvent, this, _1, _2, _3, _4));
+ m_drapeEngine->SetTapEventInfoListener(bind(&Framework::OnTapEvent, this, _1));
m_drapeEngine->SetUserPositionListener(bind(&Framework::OnUserPositionChanged, this, _1));
OnSize(params.m_surfaceWidth, params.m_surfaceHeight);
@@ -1448,15 +1448,6 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory,
InvalidateUserMarks();
- // In case of the engine reinitialization simulate the last tap to show selection mark.
- if (m_lastTapEvent != nullptr)
- {
- UserMark const * mark = OnTapEventImpl(m_lastTapEvent->m_pxPoint, m_lastTapEvent->m_isLong,
- m_lastTapEvent->m_isMyPosition, m_lastTapEvent->m_feature);
- if (mark != nullptr)
- ActivateUserMark(mark, true);
- }
-
#ifdef OMIM_OS_ANDROID
// In case of the engine reinitialization recover compass and location data
// for correct my position state.
@@ -1478,6 +1469,19 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory,
if (m_connectToGpsTrack)
GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2));
+
+ // In case of the engine reinitialization simulate the last tap to show selection mark.
+ SimulateLastTapEventIfNeeded();
+}
+
+void Framework::SimulateLastTapEventIfNeeded()
+{
+ if (m_lastTapEvent)
+ {
+ UserMark const * mark = OnTapEventImpl(*m_lastTapEvent);
+ if (mark)
+ ActivateUserMark(mark, true);
+ }
}
ref_ptr<df::DrapeEngine> Framework::GetDrapeEngine()
@@ -1890,20 +1894,15 @@ void Framework::InvalidateUserMarks()
}
}
-void Framework::OnTapEvent(m2::PointD pxPoint, bool isLong, bool isMyPosition, FeatureID const & fid)
+void Framework::OnTapEvent(df::TapInfo const & tapInfo)
{
// Back up last tap event to recover selection in case of Drape reinitialization.
- if (!m_lastTapEvent)
- m_lastTapEvent = make_unique<TapEventData>();
- m_lastTapEvent->m_pxPoint = pxPoint;
- m_lastTapEvent->m_isLong = isLong;
- m_lastTapEvent->m_isMyPosition = isMyPosition;
- m_lastTapEvent->m_feature = fid;
+ m_lastTapEvent.reset(new df::TapInfo(tapInfo));
- UserMark const * mark = OnTapEventImpl(pxPoint, isLong, isMyPosition, fid);
+ UserMark const * mark = OnTapEventImpl(tapInfo);
{
- alohalytics::TStringMap details {{"isLongPress", isLong ? "1" : "0"}};
+ alohalytics::TStringMap details {{"isLongPress", tapInfo.m_isLong ? "1" : "0"}};
if (mark)
mark->FillLogEvent(details);
alohalytics::Stats::Instance().LogEvent("$GetUserMark", details);
@@ -1918,11 +1917,11 @@ void Framework::InvalidateRendering()
m_drapeEngine->Invalidate();
}
-UserMark const * Framework::OnTapEventImpl(m2::PointD pxPoint, bool isLong, bool isMyPosition, FeatureID const & fid)
+UserMark const * Framework::OnTapEventImpl(const df::TapInfo & tapInfo)
{
- m2::PointD const pxPoint2d = m_currentModelView.P3dtoP(pxPoint);
+ m2::PointD const pxPoint2d = m_currentModelView.P3dtoP(tapInfo.m_pixelPoint);
- if (isMyPosition)
+ if (tapInfo.m_isMyPositionTapped)
return UserMarkContainer::UserMarkForMyPostion();
df::VisualParams const & vp = df::VisualParams::Instance();
@@ -1943,6 +1942,7 @@ UserMark const * Framework::OnTapEventImpl(m2::PointD pxPoint, bool isLong, bool
return (type == UserMarkType::BOOKMARK_MARK ? bmSearchRect : rect);
});
+ FeatureID const & fid = tapInfo.m_featureTapped;
if (mark != nullptr)
{
// TODO(AlexZ): Refactor out together with UserMarks.
@@ -1966,7 +1966,7 @@ UserMark const * Framework::OnTapEventImpl(m2::PointD pxPoint, bool isLong, bool
mercatorPivot = feature::GetCenter(*feature);
needMark = true;
}
- else if (isLong)
+ else if (tapInfo.m_isLong)
{
mercatorPivot = m_currentModelView.PtoG(pxPoint2d);
// TODO(AlexZ): Should we change mercatorPivot to found feature's center?
diff --git a/map/framework.hpp b/map/framework.hpp
index a9ee3e993d..2370f6ffa3 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -283,21 +283,16 @@ public:
void InvalidateRendering();
private:
- struct TapEventData
- {
- m2::PointD m_pxPoint;
- bool m_isLong;
- bool m_isMyPosition;
- FeatureID m_feature;
- };
- unique_ptr<TapEventData> m_lastTapEvent;
+ /// UI callback is called when tap event is "restored" after Drape engine restart.
+ void SimulateLastTapEventIfNeeded();
+ unique_ptr<df::TapInfo> m_lastTapEvent;
#ifdef OMIM_OS_ANDROID
unique_ptr<location::CompassInfo> m_lastCompassInfo;
unique_ptr<location::GpsInfo> m_lastGPSInfo;
#endif
- void OnTapEvent(m2::PointD pxPoint, bool isLong, bool isMyPosition, FeatureID const & feature);
- UserMark const * OnTapEventImpl(m2::PointD pxPoint, bool isLong, bool isMyPosition, FeatureID const & feature);
+ void OnTapEvent(df::TapInfo const & tapInfo);
+ UserMark const * OnTapEventImpl(df::TapInfo const & tapInfo);
//@}
TActivateCallbackFn m_activateUserMarkFn;