| 333 | } |
| 334 | |
| 335 | bool UserEventStream::OnSetScale(ref_ptr<ScaleEvent> scaleEvent) |
| 336 | { |
| 337 | double factor = scaleEvent->GetFactor(); |
| 338 | |
| 339 | m2::PointD scaleCenter = scaleEvent->GetPxPoint(); |
| 340 | if (m_listener) |
| 341 | m_listener->CorrectScalePoint(scaleCenter); |
| 342 | |
| 343 | if (scaleEvent->IsAnim()) |
| 344 | { |
| 345 | auto followAnim = m_animationSystem.FindAnimation<MapFollowAnimation>(Animation::Type::MapFollow); |
| 346 | if (followAnim == nullptr) |
| 347 | { |
| 348 | auto const parallelAnim = |
| 349 | m_animationSystem.FindAnimation<ParallelAnimation>(Animation::Type::Parallel, kParallelFollowAnim.c_str()); |
| 350 | if (parallelAnim != nullptr) |
| 351 | followAnim = parallelAnim->FindAnimation<MapFollowAnimation>(Animation::Type::MapFollow); |
| 352 | } |
| 353 | if (followAnim != nullptr && followAnim->HasScale()) |
| 354 | { |
| 355 | // Scaling is not possible if current follow animation does pixel offset. |
| 356 | if (followAnim->HasPixelOffset() && !followAnim->IsAutoZoom()) |
| 357 | return false; |
| 358 | |
| 359 | // Reset follow animation with scaling if we apply scale explicitly. |
| 360 | ResetAnimations(Animation::Type::MapFollow); |
| 361 | ResetAnimations(Animation::Type::Parallel, kParallelFollowAnim); |
| 362 | } |
| 363 | |
| 364 | m2::PointD glbScaleCenter = m_navigator.PtoG(m_navigator.P3dtoP(scaleCenter)); |
| 365 | if (m_listener) |
| 366 | m_listener->CorrectGlobalScalePoint(glbScaleCenter); |
| 367 | |
| 368 | ScreenBase const & startScreen = GetCurrentScreen(); |
| 369 | |
| 370 | auto anim = GetScaleAnimation(startScreen, scaleCenter, glbScaleCenter, factor); |
| 371 | anim->SetOnFinishAction([this](ref_ptr<Animation> animation) |
| 372 | { |
| 373 | if (m_listener) |
| 374 | m_listener->OnAnimatedScaleEnded(); |
| 375 | }); |
| 376 | |
| 377 | m_animationSystem.CombineAnimation(std::move(anim)); |
| 378 | return false; |
| 379 | } |
| 380 | |
| 381 | ResetMapPlaneAnimations(); |
| 382 | |
| 383 | m_navigator.Scale(scaleCenter, factor); |
| 384 | if (m_listener) |
| 385 | m_listener->OnAnimatedScaleEnded(); |
| 386 | |
| 387 | return true; |
| 388 | } |
| 389 | |
| 390 | bool UserEventStream::OnMove(ref_ptr<MoveEvent> moveEvent) |
| 391 | { |
nothing calls this directly
no test coverage detected