MCPcopy Create free account
hub / github.com/comaps/comaps / OnSetScale

Method OnSetScale

libs/drape_frontend/user_event_stream.cpp:335–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335bool 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
390bool UserEventStream::OnMove(ref_ptr<MoveEvent> moveEvent)
391{

Callers

nothing calls this directly

Calls 14

GetScaleAnimationFunction · 0.85
GetFactorMethod · 0.80
HasScaleMethod · 0.80
HasPixelOffsetMethod · 0.80
IsAutoZoomMethod · 0.80
SetOnFinishActionMethod · 0.80
CombineAnimationMethod · 0.80
CorrectScalePointMethod · 0.45
IsAnimMethod · 0.45
PtoGMethod · 0.45
P3dtoPMethod · 0.45

Tested by

no test coverage detected