From 4aba5f361266d4a4d1ca266ab3f9590a2d2d99eb Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Tue, 16 Jan 2018 17:01:36 +0300 Subject: [PATCH] Fixed positioning of the arrow after starting of route following. --- drape_frontend/frontend_renderer.cpp | 8 ++++---- drape_frontend/frontend_renderer.hpp | 5 ++--- drape_frontend/my_position_controller.cpp | 14 ++++++++++---- drape_frontend/my_position_controller.hpp | 8 +++++--- drape_frontend/user_event_stream.cpp | 8 ++++++-- drape_frontend/user_event_stream.hpp | 12 +++++++++--- 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 0d9258b786..096fc52a96 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -2030,18 +2030,18 @@ void FrontendRenderer::ChangeModelView(m2::RectD const & rect, void FrontendRenderer::ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, int preferredZoomLevel, + Animation::TAction const & onFinishAction, TAnimationCreator const & parallelAnimCreator) { AddUserEvent(make_unique_dp(userPos, pxZero, azimuth, preferredZoomLevel, - true, parallelAnimCreator)); + true, onFinishAction, parallelAnimCreator)); } void FrontendRenderer::ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, - m2::PointD const & pxZero, - TAnimationCreator const & parallelAnimCreator) + m2::PointD const & pxZero, TAnimationCreator const & parallelAnimCreator) { AddUserEvent(make_unique_dp(userPos, pxZero, azimuth, autoScale, - parallelAnimCreator)); + nullptr, parallelAnimCreator)); } ScreenBase const & FrontendRenderer::ProcessEvents(bool & modelViewChanged, bool & viewportChanged) diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index af4b974b89..14b3201a8f 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -124,11 +124,10 @@ public: void ChangeModelView(m2::RectD const & rect, TAnimationCreator const & parallelAnimCreator) override; void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, - int preferredZoomLevel, + int preferredZoomLevel, Animation::TAction const & onFinishAction, TAnimationCreator const & parallelAnimCreator) override; void ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, - m2::PointD const & pxZero, - TAnimationCreator const & parallelAnimCreator) override; + m2::PointD const & pxZero, TAnimationCreator const & parallelAnimCreator) override; drape_ptr const & GetScenarioManager() const; diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp index 01002d166f..f09bee1d32 100644 --- a/drape_frontend/my_position_controller.cpp +++ b/drape_frontend/my_position_controller.cpp @@ -689,14 +689,16 @@ void MyPositionController::ChangeModelView(m2::RectD const & rect) } void MyPositionController::ChangeModelView(m2::PointD const & userPos, double azimuth, - m2::PointD const & pxZero, int zoomLevel) + m2::PointD const & pxZero, int zoomLevel, + Animation::TAction const & onFinishAction) { if (m_listener) - m_listener->ChangeModelView(userPos, azimuth, pxZero, zoomLevel, m_animCreator); + m_listener->ChangeModelView(userPos, azimuth, pxZero, zoomLevel, onFinishAction, m_animCreator); m_animCreator = nullptr; } -void MyPositionController::ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero) +void MyPositionController::ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, + m2::PointD const & pxZero) { if (m_listener) m_listener->ChangeModelView(autoScale, userPos, azimuth, pxZero, m_animCreator); @@ -818,7 +820,11 @@ void MyPositionController::ActivateRouting(int zoomLevel, bool enableAutoZoom) ChangeMode(location::FollowAndRotate); ChangeModelView(m_position, m_isDirectionAssigned ? m_drawDirection : 0.0, - GetRoutingRotationPixelCenter(), zoomLevel); + GetRoutingRotationPixelCenter(), zoomLevel, + [this](ref_ptr anim) + { + UpdateViewport(kDoNotChangeZoom); + }); } } diff --git a/drape_frontend/my_position_controller.hpp b/drape_frontend/my_position_controller.hpp index ed5bfdae9a..7851065284 100644 --- a/drape_frontend/my_position_controller.hpp +++ b/drape_frontend/my_position_controller.hpp @@ -1,5 +1,6 @@ #pragma once +#include "drape_frontend/animation/animation.hpp" #include "drape_frontend/drape_hints.hpp" #include "drape_frontend/my_position.hpp" @@ -17,7 +18,6 @@ namespace df { -class Animation; using TAnimationCreator = function(ref_ptr)>; class MyPositionController @@ -36,7 +36,8 @@ public: virtual void ChangeModelView(m2::RectD const & rect, TAnimationCreator const & parallelAnimCreator) = 0; /// Show map where "usePos" (mercator) placed in "pxZero" on screen and map rotated around "userPos" virtual void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, - int zoomLevel, TAnimationCreator const & parallelAnimCreator) = 0; + int zoomLevel, Animation::TAction const & onFinishAction, + TAnimationCreator const & parallelAnimCreator) = 0; virtual void ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, TAnimationCreator const & parallelAnimCreator) = 0; }; @@ -139,7 +140,8 @@ private: void ChangeModelView(m2::PointD const & center, int zoomLevel); void ChangeModelView(double azimuth); void ChangeModelView(m2::RectD const & rect); - void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, int zoomLevel); + void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, int zoomLevel, + Animation::TAction const & onFinishAction = nullptr); void ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero); void UpdateViewport(int zoomLevel); diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index d922fe3b6c..ff4d87bc30 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -234,7 +234,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChanged, bool breakAnim = SetFollowAndRotate(followEvent->GetUserPos(), followEvent->GetPixelZero(), followEvent->GetAzimuth(), followEvent->GetPreferredZoomLelel(), followEvent->GetAutoScale(), followEvent->IsAnim(), followEvent->IsAutoScale(), - followEvent->GetParallelAnimCreator()); + followEvent->GetOnFinishAction(), followEvent->GetParallelAnimCreator()); } break; case UserEvent::EventType::AutoPerspective: @@ -437,6 +437,7 @@ bool UserEventStream::SetAngle(double azimuth, TAnimationCreator const & paralle return SetFollowAndRotate(gPt, pt, azimuth, kDoNotChangeZoom, kDoNotAutoZoom, true /* isAnim */, false /* isAutoScale */, + nullptr /* onFinishAction */, parallelAnimCreator); } @@ -530,7 +531,8 @@ bool UserEventStream::InterruptFollowAnimations(bool force) bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD const & pixelPos, double azimuth, int preferredZoomLevel, double autoScale, - bool isAnim, bool isAutoScale, TAnimationCreator const & parallelAnimCreator) + bool isAnim, bool isAutoScale, Animation::TAction const & onFinishAction, + TAnimationCreator const & parallelAnimCreator) { // Reset current follow-and-rotate animation if possible. if (isAnim && !InterruptFollowAnimations(false /* force */)) @@ -575,6 +577,8 @@ bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD anim->SetCouldBeBlended(false); } + anim->SetOnFinishAction(onFinishAction); + if (parallelAnimCreator != nullptr) { drape_ptr parallelAnim = make_unique_dp(); diff --git a/drape_frontend/user_event_stream.hpp b/drape_frontend/user_event_stream.hpp index 64dc1fbeb7..75c6144156 100644 --- a/drape_frontend/user_event_stream.hpp +++ b/drape_frontend/user_event_stream.hpp @@ -216,7 +216,8 @@ class FollowAndRotateEvent : public UserEvent { public: FollowAndRotateEvent(m2::PointD const & userPos, m2::PointD const & pixelZero, - double azimuth, double autoScale, TAnimationCreator const & parallelAnimCreator = nullptr) + double azimuth, double autoScale, + TAnimationCreator const & parallelAnimCreator = nullptr) : m_userPos(userPos) , m_pixelZero(pixelZero) , m_azimuth(azimuth) @@ -224,13 +225,15 @@ public: , m_autoScale(autoScale) , m_isAutoScale(true) , m_isAnim(true) + , m_onFinishAction(nullptr) , m_parallelAnimCreator(parallelAnimCreator) { } FollowAndRotateEvent(m2::PointD const & userPos, m2::PointD const & pixelZero, double azimuth, int preferredZoomLevel, - bool isAnim, TAnimationCreator const & parallelAnimCreator = nullptr) + bool isAnim, Animation::TAction const & onFinishAction = nullptr, + TAnimationCreator const & parallelAnimCreator = nullptr) : m_userPos(userPos) , m_pixelZero(pixelZero) , m_azimuth(azimuth) @@ -238,6 +241,7 @@ public: , m_autoScale(kDoNotAutoZoom) , m_isAutoScale(false) , m_isAnim(isAnim) + , m_onFinishAction(onFinishAction) , m_parallelAnimCreator(parallelAnimCreator) {} @@ -251,6 +255,7 @@ public: bool IsAutoScale() const { return m_isAutoScale; } bool IsAnim() const { return m_isAnim; } TAnimationCreator const & GetParallelAnimCreator() const { return m_parallelAnimCreator; } + Animation::TAction const & GetOnFinishAction() const { return m_onFinishAction; } private: m2::PointD m_userPos; @@ -260,6 +265,7 @@ private: double m_autoScale; bool m_isAutoScale; bool m_isAnim; + Animation::TAction m_onFinishAction; TAnimationCreator m_parallelAnimCreator; }; @@ -412,7 +418,7 @@ private: TAnimationCreator const & parallelAnimCreator = nullptr); bool SetFollowAndRotate(m2::PointD const & userPos, m2::PointD const & pixelPos, double azimuth, int preferredZoomLevel, double autoScale, - bool isAnim, bool isAutoScale, + bool isAnim, bool isAutoScale, Animation::TAction const & onFinishAction = nullptr, TAnimationCreator const & parallelAnimCreator = nullptr); void SetAutoPerspective(bool isAutoPerspective); void CheckAutoRotate();