diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-07-19 13:17:40 +0300 |
---|---|---|
committer | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-07-19 13:20:04 +0300 |
commit | 441eac21951706bdd4bb0d2ef93b0650048b2c28 (patch) | |
tree | 33b90e6937a67d8ecd1309db2ba2256982c0c98d /drape_frontend | |
parent | 92923578ab399e9a78257ffcebdb2c489c32c28d (diff) |
Pretty follow animation fixed on max zoom level.
Diffstat (limited to 'drape_frontend')
-rw-r--r-- | drape_frontend/screen_animations.cpp | 30 | ||||
-rw-r--r-- | drape_frontend/user_event_stream.cpp | 19 | ||||
-rw-r--r-- | drape_frontend/user_event_stream.hpp | 5 |
3 files changed, 33 insertions, 21 deletions
diff --git a/drape_frontend/screen_animations.cpp b/drape_frontend/screen_animations.cpp index b1d06014a9..b896fa2445 100644 --- a/drape_frontend/screen_animations.cpp +++ b/drape_frontend/screen_animations.cpp @@ -32,6 +32,8 @@ drape_ptr<SequenceAnimation> GetPrettyMoveAnimation(ScreenBase const & screen, d m2::PointD const & startPt, m2::PointD const & endPt) { double const moveDuration = PositionInterpolator::GetMoveDuration(startPt, endPt, screen.PixelRectIn3d(), startScale); + ASSERT_GREATER(moveDuration, 0.0, ()); + double const scaleFactor = moveDuration / kMaxAnimationTimeSec * 2.0; auto sequenceAnim = make_unique_dp<SequenceAnimation>(); @@ -65,32 +67,38 @@ drape_ptr<SequenceAnimation> GetPrettyFollowAnimation(ScreenBase const & startSc m2::RectD const viewportRect = startScreen.PixelRectIn3d(); ScreenBase tmp = startScreen; + tmp.SetAngle(targetAngle); tmp.MatchGandP3d(userPos, viewportRect.Center()); double const moveDuration = PositionInterpolator::GetMoveDuration(startScreen.GetOrg(), tmp.GetOrg(), startScreen); + ASSERT_GREATER(moveDuration, 0.0, ()); + double const scaleFactor = moveDuration / kMaxAnimationTimeSec * 2.0; tmp = startScreen; - tmp.SetScale(startScreen.GetScale() * scaleFactor); - auto zoomOutAnim = make_unique_dp<MapLinearAnimation>(); - zoomOutAnim->SetScale(startScreen.GetScale(), tmp.GetScale()); - zoomOutAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5); + if (moveDuration > 0.0) + { + tmp.SetScale(startScreen.GetScale() * scaleFactor); - tmp.MatchGandP3d(userPos, viewportRect.Center()); + auto zoomOutAnim = make_unique_dp<MapLinearAnimation>(); + zoomOutAnim->SetScale(startScreen.GetScale(), tmp.GetScale()); + zoomOutAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5); + sequenceAnim->AddAnimation(move(zoomOutAnim)); - auto moveAnim = make_unique_dp<MapLinearAnimation>(); - moveAnim->SetMove(startScreen.GetOrg(), tmp.GetOrg(), viewportRect, tmp.GetScale()); - moveAnim->SetMaxDuration(kMaxAnimationTimeSec); + tmp.MatchGandP3d(userPos, viewportRect.Center()); + + auto moveAnim = make_unique_dp<MapLinearAnimation>(); + moveAnim->SetMove(startScreen.GetOrg(), tmp.GetOrg(), viewportRect, tmp.GetScale()); + moveAnim->SetMaxDuration(kMaxAnimationTimeSec); + sequenceAnim->AddAnimation(move(moveAnim)); + } auto followAnim = make_unique_dp<MapFollowAnimation>(tmp, userPos, endPixelPos, tmp.GetScale(), targetScale, tmp.GetAngle(), targetAngle, false /* isAutoZoom */); followAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5); - - sequenceAnim->AddAnimation(move(zoomOutAnim)); - sequenceAnim->AddAnimation(move(moveAnim)); sequenceAnim->AddAnimation(move(followAnim)); return sequenceAnim; } diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index ea9c49467d..63572d3a52 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -399,6 +399,10 @@ bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD double azimuth, int preferredZoomLevel, double autoScale, bool isAnim, bool isAutoScale) { + // Reset current follow-and-rotate animation if possible. + if (isAnim && !InterruptFollowAnimations(false /* force */)) + return false; + ScreenBase const & currentScreen = GetCurrentScreen(); ScreenBase screen = currentScreen; @@ -417,10 +421,6 @@ bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD if (isAnim) { - // Reset current follow-and-rotate animation if possible. - if (!InterruptFollowAnimations(false /* force */)) - return false; - auto onStartHandler = [this](ref_ptr<Animation> animation) { if (m_listener) @@ -497,15 +497,18 @@ m2::AnyRectD UserEventStream::GetCurrentRect() const return m_navigator.Screen().GlobalRect(); } -void UserEventStream::GetTargetScreen(ScreenBase & screen) const +void UserEventStream::GetTargetScreen(ScreenBase & screen) { - m_animationSystem.GetTargetScreen(m_navigator.Screen(), screen); + m_animationSystem.FinishAnimations(Animation::KineticScroll, false /* rewind */, false /* finishAll */); + ApplyAnimations(); + + m_animationSystem.GetTargetScreen(m_navigator.Screen(), screen); } -m2::AnyRectD UserEventStream::GetTargetRect() const +m2::AnyRectD UserEventStream::GetTargetRect() { ScreenBase targetScreen; - m_animationSystem.GetTargetScreen(m_navigator.Screen(), targetScreen); + GetTargetScreen(targetScreen); return targetScreen.GlobalRect(); } diff --git a/drape_frontend/user_event_stream.hpp b/drape_frontend/user_event_stream.hpp index 0929bd0c06..0e1be71778 100644 --- a/drape_frontend/user_event_stream.hpp +++ b/drape_frontend/user_event_stream.hpp @@ -260,8 +260,9 @@ public: ScreenBase const & ProcessEvents(bool & modelViewChanged, bool & viewportChanged); ScreenBase const & GetCurrentScreen() const; - void GetTargetScreen(ScreenBase & screen) const; - m2::AnyRectD GetTargetRect() const; + void GetTargetScreen(ScreenBase & screen); + m2::AnyRectD GetTargetRect(); + bool IsInUserAction() const; bool IsWaitingForActionCompletion() const; |