Fixed positioning on a search result or a bookmark in perspective mode.

This commit is contained in:
Daria Volvenkova 2016-05-10 11:49:01 +03:00 committed by Vladimir Byko-Ianko
parent 1ff414a46d
commit b5b43f157f
5 changed files with 40 additions and 26 deletions

View file

@ -673,7 +673,7 @@ bool MapFollowAnimation::HasScale() const
}
PerspectiveSwitchAnimation::PerspectiveSwitchAnimation(double startAngle, double endAngle, double angleFOV)
: Animation(false /* couldBeInterrupted */, true /* couldBeBlended */)
: Animation(false /* couldBeInterrupted */, false /* couldBeBlended */)
, m_angleInterpolator(GetRotateDuration(startAngle, endAngle), startAngle, endAngle)
, m_startAngle(startAngle)
, m_endAngle(endAngle)
@ -924,8 +924,10 @@ void SequenceAnimation::Advance(double elapsedSeconds)
void SequenceAnimation::Finish()
{
for (auto & anim : m_animations)
{
anim->Finish();
AnimationSystem::Instance().SaveAnimationResult(*m_animations.back());
AnimationSystem::Instance().SaveAnimationResult(*anim);
}
m_animations.clear();
ObtainObjectProperties();
Animation::Finish();

View file

@ -1410,6 +1410,12 @@ void FrontendRenderer::OnAnimationStarted(ref_ptr<Animation> anim)
m_myPositionController->AnimationStarted(anim);
}
void FrontendRenderer::OnPerspectiveSwitchRejected()
{
if (m_perspectiveDiscarded)
m_perspectiveDiscarded = false;
}
TTilesCollection FrontendRenderer::ResolveTileKeys(ScreenBase const & screen)
{
m2::RectD const & rect = screen.ClipRect();

View file

@ -194,6 +194,7 @@ private:
void CorrectGlobalScalePoint(m2::PointD & pt) const override;
void OnScaleEnded() override;
void OnAnimationStarted(ref_ptr<Animation> anim) override;
void OnPerspectiveSwitchRejected() override;
class Routine : public threads::IRoutine
{

View file

@ -169,11 +169,8 @@ void UserEventStream::AddEvent(UserEvent const & event)
m_events.push_back(event);
}
ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & viewportChanged)
ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChanged, bool & viewportChanged)
{
modelViewChange = false;
viewportChanged = false;
list<UserEvent> events;
{
@ -182,7 +179,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool &
swap(m_events, events);
}
modelViewChange = !events.empty() || m_state == STATE_SCALE || m_state == STATE_DRAG;
m_modelViewChanged = !events.empty() || m_state == STATE_SCALE || m_state == STATE_DRAG;
for (UserEvent const & e : events)
{
if (m_perspectiveAnimation && FilterEventWhile3dAnimation(e.m_type))
@ -198,7 +195,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool &
break;
case UserEvent::EVENT_RESIZE:
m_navigator.OnSize(e.m_resize.m_width, e.m_resize.m_height);
viewportChanged = true;
m_viewportChanged = true;
breakAnim = true;
TouchCancel(m_touches);
if (m_state == STATE_DOUBLE_TAP_HOLD)
@ -274,10 +271,10 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool &
}
if (breakAnim)
modelViewChange = true;
m_modelViewChanged = true;
}
ApplyAnimations(modelViewChange, viewportChanged);
ApplyAnimations();
if (m_perspectiveAnimation)
{
@ -290,7 +287,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool &
SetRect(m_pendingEvent->m_rectEvent.m_rect, m_pendingEvent->m_rectEvent.m_zoom,
m_pendingEvent->m_rectEvent.m_applyRotation, m_pendingEvent->m_rectEvent.m_isAnim);
m_pendingEvent.reset();
modelViewChange = true;
m_modelViewChanged = true;
}
}
@ -302,10 +299,15 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool &
DetectLongTap(m_touches[0]);
}
modelViewChanged = m_modelViewChanged;
viewportChanged = m_viewportChanged;
m_modelViewChanged = false;
m_viewportChanged = false;
return m_navigator.Screen();
}
void UserEventStream::ApplyAnimations(bool & modelViewChanged, bool & viewportChanged)
void UserEventStream::ApplyAnimations()
{
if (m_animationSystem.AnimationExists(Animation::MapPlane))
{
@ -325,7 +327,7 @@ void UserEventStream::ApplyAnimations(bool & modelViewChanged, bool & viewportCh
{
m_navigator.Disable3dMode();
}
viewportChanged = true;
m_viewportChanged = true;
}
double perspectiveAngle;
@ -335,7 +337,7 @@ void UserEventStream::ApplyAnimations(bool & modelViewChanged, bool & viewportCh
m_navigator.SetRotationIn3dMode(perspectiveAngle);
}
modelViewChanged = true;
m_modelViewChanged = true;
}
}
@ -634,6 +636,12 @@ void UserEventStream::SetEnable3dMode(double maxRotationAngle, double angleFOV,
void UserEventStream::SetDisable3dModeAnimation()
{
ResetAnimationsBeforeSwitch3D();
if (m_discardedFOV > 0.0 && IsScaleAllowableIn3d(GetDrawTileScale(GetCurrentScreen())))
{
m_discardedFOV = m_discardedAngle = 0.0;
m_listener->OnPerspectiveSwitchRejected();
return;
}
double const startAngle = m_navigator.Screen().GetRotationAngle();
double const endAngle = 0.0;
@ -655,11 +663,7 @@ void UserEventStream::ResetAnimations(Animation::Type animType, bool finishAll)
bool const hasAnimations = m_animationSystem.HasAnimations();
m_animationSystem.FinishAnimations(animType, true /* rewind */, finishAll);
if (hasAnimations)
{
m2::AnyRectD rect;
if (m_animationSystem.GetRect(GetCurrentScreen(), rect))
m_navigator.SetFromRect(rect);
}
ApplyAnimations();
}
void UserEventStream::ResetMapPlaneAnimations()
@ -667,17 +671,14 @@ void UserEventStream::ResetMapPlaneAnimations()
bool const hasAnimations = m_animationSystem.HasAnimations();
m_animationSystem.FinishObjectAnimations(Animation::MapPlane, false /* rewind */, false /* finishAll */);
if (hasAnimations)
{
m2::AnyRectD rect;
if (m_animationSystem.GetRect(GetCurrentScreen(), rect))
m_navigator.SetFromRect(rect);
}
ApplyAnimations();
}
void UserEventStream::ResetAnimationsBeforeSwitch3D()
{
ResetAnimations(Animation::MapLinear);
ResetAnimations(Animation::MapScale);
ResetAnimations(Animation::Sequence);
ResetAnimations(Animation::MapPerspective, true /* finishAll */);
}

View file

@ -258,11 +258,12 @@ public:
virtual void OnScaleEnded() = 0;
virtual void OnAnimationStarted(ref_ptr<Animation> anim) = 0;
virtual void OnPerspectiveSwitchRejected() = 0;
};
UserEventStream();
void AddEvent(UserEvent const & event);
ScreenBase const & ProcessEvents(bool & modelViewChange, bool & viewportChanged);
ScreenBase const & ProcessEvents(bool & modelViewChanged, bool & viewportChanged);
ScreenBase const & GetCurrentScreen() const;
m2::AnyRectD GetTargetRect() const;
@ -351,7 +352,7 @@ private:
void EndFilter(Touch const & t);
void CancelFilter(Touch const & t);
void ApplyAnimations(bool & modelViewChanged, bool & viewportChanged);
void ApplyAnimations();
void ResetAnimations(Animation::Type animType, bool finishAll = false);
void ResetMapPlaneAnimations();
void ResetAnimationsBeforeSwitch3D();
@ -378,6 +379,9 @@ private:
AnimationSystem & m_animationSystem;
bool m_modelViewChanged = false;
bool m_viewportChanged = false;
bool m_perspectiveAnimation = false;
unique_ptr<UserEvent> m_pendingEvent;
double m_discardedFOV = 0.0;