[core] animations fix

This commit is contained in:
ExMix 2014-09-30 11:41:44 +03:00 committed by Alex Zolotarev
parent c89fb09d14
commit 376420445b
6 changed files with 36 additions and 16 deletions

View file

@ -943,7 +943,9 @@ void Framework::StopDrag(DragEvent const & e)
void Framework::StartRotate(RotateEvent const & e)
{
if (m_renderPolicy && m_renderPolicy->DoSupportRotation())
if (m_renderPolicy &&
m_renderPolicy->DoSupportRotation() &&
GetLocationState()->IsRotationAllowed())
{
m_navigator.StartRotate(e.Angle(), ElapsedSeconds());
m_renderPolicy->StartRotate(e.Angle(), ElapsedSeconds());
@ -952,7 +954,9 @@ void Framework::StartRotate(RotateEvent const & e)
void Framework::DoRotate(RotateEvent const & e)
{
if (m_renderPolicy && m_renderPolicy->DoSupportRotation())
if (m_renderPolicy &&
m_renderPolicy->DoSupportRotation() &&
GetLocationState()->IsRotationAllowed())
{
m_navigator.DoRotate(e.Angle(), ElapsedSeconds());
m_renderPolicy->DoRotate(e.Angle(), ElapsedSeconds());
@ -961,10 +965,12 @@ void Framework::DoRotate(RotateEvent const & e)
void Framework::StopRotate(RotateEvent const & e)
{
if (m_renderPolicy && m_renderPolicy->DoSupportRotation())
if (m_renderPolicy &&
m_renderPolicy->DoSupportRotation() &&
GetLocationState()->IsRotationAllowed())
{
m_navigator.StopRotate(e.Angle(), ElapsedSeconds());
m_informationDisplay.locationState()->Rotated();
GetLocationState()->Rotated();
m_renderPolicy->StopRotate(e.Angle(), ElapsedSeconds());
UpdateUserViewportChanged();
@ -1023,7 +1029,7 @@ void Framework::StartScale(ScaleEvent const & e)
m2::PointD pt1, pt2;
CalcScalePoints(e, pt1, pt2);
m_navigator.StartScale(pt1, pt2, ElapsedSeconds());
m_navigator.StartScale(pt1, pt2, ElapsedSeconds(), GetLocationState()->IsRotationAllowed());
if (m_renderPolicy)
m_renderPolicy->StartScale();
}
@ -1038,7 +1044,7 @@ void Framework::DoScale(ScaleEvent const & e)
m_renderPolicy->DoScale();
if (m_navigator.IsRotatingDuringScale())
m_informationDisplay.locationState()->Rotated();
GetLocationState()->Rotated();
}
void Framework::StopScale(ScaleEvent const & e)

View file

@ -283,6 +283,7 @@ void State::StartRoutingMode()
void State::StopRoutingMode()
{
SetModeInfo(ExcludeModeBit(m_modeInfo, RoutingSessionBit));
SetCurrentPixelBinding(GetModeDefaultPixelBinding(GetMode()));
}
void State::TurnOff()
@ -615,12 +616,15 @@ m2::PointD const State::GetRaFModeDefaultPxBind() const
pixelRect.maxY() - POSITION_Y_OFFSET * visualScale());
}
void State::StopCompassFollowing(Mode mode)
void State::StopCompassFollowing(Mode mode, bool resetPxBinding)
{
if (GetMode() != RotateAndFollow)
return;
EndAnimation();
SetModeInfo(ChangeMode(m_modeInfo, mode));
if (resetPxBinding)
SetCurrentPixelBinding(GetModeDefaultPixelBinding(GetMode()));
m_framework->GetAnimator().StopRotation();
m_framework->GetAnimator().StopChangeViewport();
@ -631,7 +635,10 @@ void State::StopLocationFollow()
{
StopCompassFollowing();
if (GetMode() > NotFollow)
{
SetModeInfo(ChangeMode(m_modeInfo, NotFollow));
SetCurrentPixelBinding(GetModeDefaultPixelBinding(GetMode()));
}
}
void State::DragStarted()
@ -645,7 +652,7 @@ void State::Draged()
if (!IsModeChangeViewport())
return;
StopCompassFollowing();
StopCompassFollowing(NotFollow, false);
SetModeInfo(ChangeMode(m_modeInfo, NotFollow));
}
@ -674,13 +681,13 @@ void State::DragEnded()
void State::ScaleCorrection(m2::PointD & pt)
{
if (IsModeChangeViewport())
if (GetMode() == Follow)
pt = m_framework->GetPixelCenter();
}
void State::ScaleCorrection(m2::PointD & pt1, m2::PointD & pt2)
{
if (IsModeChangeViewport())
if (GetMode() == Follow)
{
m2::PointD const ptC = (pt1 + pt2) / 2;
m2::PointD const ptDiff = m_framework->GetPixelCenter() - ptC;
@ -689,10 +696,16 @@ void State::ScaleCorrection(m2::PointD & pt1, m2::PointD & pt2)
}
}
bool State::IsRotationAllowed() const
{
return !(IsInRouting() && GetMode() == RotateAndFollow);
}
void State::Rotated()
{
m_afterPendingMode = NotFollow;
StopCompassFollowing(IsInRouting() ? NotFollow : Follow);
ASSERT(!IsInRouting() || GetMode() != RotateAndFollow, ());
StopCompassFollowing(NotFollow);
}
void State::OnSize(m2::RectD const & oldPixelRect)

View file

@ -71,7 +71,7 @@ namespace location
void InvalidatePosition();
void TurnOff();
void StopCompassFollowing(Mode mode = Follow);
void StopCompassFollowing(Mode mode = Follow, bool resetPxBinding = true);
void StopLocationFollow();
/// @name User input notification block
@ -83,6 +83,7 @@ namespace location
void ScaleCorrection(m2::PointD & pt);
void ScaleCorrection(m2::PointD & pt1, m2::PointD & pt2);
bool IsRotationAllowed() const;
void Rotated();
//@}

View file

@ -40,7 +40,7 @@ UNIT_TEST(Navigator_Scale2Points)
TEST_EQUAL(screen.ClipRect(), m2::RectD(0, 0, 8, 4), ());
navigator.StartScale(screen.GtoP(m2::PointD(1, 1)),
screen.GtoP(m2::PointD(7, 1)), 0);
screen.GtoP(m2::PointD(7, 1)), 0, true);
navigator.StopScale(screen.GtoP(m2::PointD(1, 1)),
screen.GtoP(m2::PointD(4, 1)), 1);
TEST_EQUAL(screen.ClipRect(), m2::RectD(-1, -1, 15, 7), ());

View file

@ -385,13 +385,13 @@ bool Navigator::InAction() const
return m_InAction;
}
void Navigator::StartScale(m2::PointD const & pt1, m2::PointD const & pt2, double /*timeInSec*/)
void Navigator::StartScale(m2::PointD const & pt1, m2::PointD const & pt2, double /*timeInSec*/, bool isRotationAllowed)
{
m_StartScreen = m_Screen;
m_StartPt1 = m_LastPt1 = pt1;
m_StartPt2 = m_LastPt2 = pt2;
m_DoCheckRotationThreshold = m_DoSupportRotation;
m_DoCheckRotationThreshold = m_DoSupportRotation && isRotationAllowed;
m_IsRotatingDuringScale = false;
m_InAction = true;
}

View file

@ -47,7 +47,7 @@ public:
void DoRotate(double Angle, double timeInSec);
void StopRotate(double Angle, double timeInSec);
void StartScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec);
void StartScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec, bool isRotationAllowed);
void DoScale(m2::PointD const & org, m2::PointD const & p1, m2::PointD const & p2);
void DoScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec);
void StopScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec);