| 613 | } |
| 614 | |
| 615 | bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD const & pixelPos, double azimuth, |
| 616 | int preferredZoomLevel, double autoScale, bool isAnim, bool isAutoScale, |
| 617 | Animation::TAction const & onFinishAction, |
| 618 | TAnimationCreator const & parallelAnimCreator) |
| 619 | { |
| 620 | // Reset current follow-and-rotate animation if possible. |
| 621 | if (isAnim && !InterruptFollowAnimations(false /* force */)) |
| 622 | return false; |
| 623 | |
| 624 | ScreenBase const & currentScreen = GetCurrentScreen(); |
| 625 | ScreenBase screen = currentScreen; |
| 626 | |
| 627 | if (preferredZoomLevel == kDoNotChangeZoom && !isAutoScale) |
| 628 | { |
| 629 | GetTargetScreen(screen); |
| 630 | screen.SetAngle(-azimuth); |
| 631 | } |
| 632 | else |
| 633 | { |
| 634 | screen.SetFromParams(userPos, -azimuth, isAutoScale ? autoScale : GetScreenScale(preferredZoomLevel)); |
| 635 | } |
| 636 | screen.MatchGandP3d(userPos, pixelPos); |
| 637 | |
| 638 | ShrinkAndScaleInto(screen, df::GetWorldRect()); |
| 639 | |
| 640 | if (isAnim) |
| 641 | { |
| 642 | drape_ptr<Animation> anim; |
| 643 | double const moveDuration = |
| 644 | PositionInterpolator::GetMoveDuration(currentScreen.GetOrg(), screen.GetOrg(), currentScreen.PixelRectIn3d(), |
| 645 | (currentScreen.GetScale() + screen.GetScale()) / 2.0); |
| 646 | if (moveDuration > kMaxAnimationTimeSec) |
| 647 | { |
| 648 | // Run pretty move animation if we are far from userPos. |
| 649 | anim = GetPrettyFollowAnimation(currentScreen, userPos, screen.GetScale(), -azimuth, pixelPos); |
| 650 | } |
| 651 | else |
| 652 | { |
| 653 | // Run follow-and-rotate animation. |
| 654 | anim = GetFollowAnimation(currentScreen, userPos, screen.GetScale(), -azimuth, pixelPos, isAutoScale); |
| 655 | } |
| 656 | |
| 657 | if (preferredZoomLevel != kDoNotChangeZoom) |
| 658 | { |
| 659 | anim->SetCouldBeInterrupted(false); |
| 660 | anim->SetCouldBeBlended(false); |
| 661 | } |
| 662 | |
| 663 | anim->SetOnFinishAction(onFinishAction); |
| 664 | |
| 665 | if (parallelAnimCreator != nullptr) |
| 666 | { |
| 667 | drape_ptr<ParallelAnimation> parallelAnim = make_unique_dp<ParallelAnimation>(); |
| 668 | parallelAnim->SetCustomType(kParallelFollowAnim); |
| 669 | parallelAnim->AddAnimation( |
| 670 | parallelAnimCreator(anim->GetType() == Animation::Type::MapFollow ? make_ref(anim) : nullptr)); |
| 671 | parallelAnim->AddAnimation(std::move(anim)); |
| 672 | m_animationSystem.CombineAnimation(std::move(parallelAnim)); |
nothing calls this directly
no test coverage detected