diff --git a/map/framework.cpp b/map/framework.cpp index 9aba3fbbd9..a1e97ab614 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1587,7 +1587,7 @@ void Framework::CreateDrapeEngine(ref_ptr contextFac LoadViewport(); if (m_connectToGpsTrack) - GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2)); + GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2, _3)); GetBookmarkManager().SetDrapeEngine(make_ref(m_drapeEngine)); m_drapeApi.SetDrapeEngine(make_ref(m_drapeEngine)); @@ -1699,7 +1699,7 @@ void Framework::ConnectToGpsTracker() if (m_drapeEngine) { m_drapeEngine->ClearGpsTrackPoints(); - GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2)); + GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2, _3)); } } @@ -1720,10 +1720,17 @@ void Framework::StartTrackRecording() if (m_drapeEngine) { m_drapeEngine->ClearGpsTrackPoints(); - tracker.Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2)); + tracker.Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2, _3)); } } +void Framework::SetTrackRecordingUpdateHandler(TrackRecordingUpdateHandler && trackRecordingDidUpdate) +{ + m_trackRecordingUpdateHandler = std::move(trackRecordingDidUpdate); + if (m_trackRecordingUpdateHandler) + m_trackRecordingUpdateHandler(std::move(GpsTracker::Instance().GetTrackInfo())); +} + void Framework::StopTrackRecording() { m_connectToGpsTrack = false; @@ -1752,7 +1759,8 @@ bool Framework::IsTrackRecordingEnabled() const } void Framework::OnUpdateGpsTrackPointsCallback(vector> && toAdd, - pair const & toRemove) + pair const & toRemove, + GpsTrackInfo const & trackInfo) { ASSERT(m_drapeEngine.get() != nullptr, ()); @@ -1779,6 +1787,9 @@ void Framework::OnUpdateGpsTrackPointsCallback(vectorUpdateGpsTrackPoints(std::move(pointsAdd), std::move(indicesRemove)); + + if (m_trackRecordingUpdateHandler) + m_trackRecordingUpdateHandler(std::move(trackInfo)); } void Framework::MarkMapStyle(MapStyle mapStyle) diff --git a/map/framework.hpp b/map/framework.hpp index 4276bab57b..9fb29750aa 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -17,6 +17,7 @@ #include "map/track.hpp" #include "map/traffic_manager.hpp" #include "map/transit/transit_reader.hpp" +#include "map/gps_track_collection.hpp" #include "drape_frontend/gui/skin.hpp" #include "drape_frontend/drape_api.hpp" @@ -435,7 +436,9 @@ public: void ConnectToGpsTracker(); void DisconnectFromGpsTracker(); + using TrackRecordingUpdateHandler = platform::SafeCallback; void StartTrackRecording(); + void SetTrackRecordingUpdateHandler(TrackRecordingUpdateHandler && trackRecordingDidUpdate); void StopTrackRecording(); void SaveTrackRecordingWithName(std::string const & name); bool IsTrackRecordingEmpty() const; @@ -463,7 +466,10 @@ private: TCurrentCountryChanged m_currentCountryChanged; void OnUpdateGpsTrackPointsCallback(std::vector> && toAdd, - std::pair const & toRemove); + std::pair const & toRemove, + GpsTrackInfo const & trackInfo); + + TrackRecordingUpdateHandler m_trackRecordingUpdateHandler; CachingRankTableLoader m_popularityLoader; diff --git a/map/gps_track.cpp b/map/gps_track.cpp index 9988b6fd21..4164af33eb 100644 --- a/map/gps_track.cpp +++ b/map/gps_track.cpp @@ -303,7 +303,7 @@ void GpsTrack::NotifyCallback(pair const & addedIds, pairGetTrackInfo())); } else { @@ -324,6 +324,6 @@ void GpsTrack::NotifyCallback(pair const & addedIds, pairGetTrackInfo())); } } diff --git a/map/gps_track.hpp b/map/gps_track.hpp index 94d37b2c42..6ba0ba138f 100644 --- a/map/gps_track.hpp +++ b/map/gps_track.hpp @@ -46,7 +46,8 @@ public: /// @note Calling of a GpsTrack.SetCallback function from the callback causes deadlock. using TGpsTrackDiffCallback = std::function> && toAdd, - std::pair const & toRemove)>; + std::pair const & toRemove, + GpsTrackInfo const & trackInfo)>; /// Sets callback on change of gps track. /// @param callback - callback callable object diff --git a/map/gps_tracker.hpp b/map/gps_tracker.hpp index 8a0de6a3d5..38ff7915c2 100644 --- a/map/gps_tracker.hpp +++ b/map/gps_tracker.hpp @@ -21,7 +21,8 @@ public: using TGpsTrackDiffCallback = std::function> && toAdd, - std::pair const & toRemove)>; + std::pair const & toRemove, + GpsTrackInfo const & trackInfo)>; void Connect(TGpsTrackDiffCallback const & fn); void Disconnect();