Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kuznetsov <r.kuznetsow@gmail.com>2017-01-30 17:05:09 +0300
committerGitHub <noreply@github.com>2017-01-30 17:05:09 +0300
commitbd5307ca2a480112a4644802cd16cf72a80c9286 (patch)
tree54716dd465c39d1d51d458d199b9f1955fb9f8d6
parent2f8dad23b901c333a7ba8587b03538d660ceb7f9 (diff)
parentc6f260d65892ed6a0df64abac94da765fad9eb45 (diff)
Merge pull request #5305 from darina/animation-init-fixbeta-599beta-596
Save duration restrictions of animation during its initialization.
-rw-r--r--drape_frontend/animation/animation.cpp30
-rw-r--r--drape_frontend/animation/animation.hpp14
-rw-r--r--drape_frontend/animation/arrow_animation.cpp47
-rw-r--r--drape_frontend/animation/arrow_animation.hpp3
-rw-r--r--drape_frontend/animation/follow_animation.cpp46
-rw-r--r--drape_frontend/animation/follow_animation.hpp3
-rw-r--r--drape_frontend/animation/interpolators.cpp20
-rw-r--r--drape_frontend/animation/interpolators.hpp10
-rw-r--r--drape_frontend/animation/linear_animation.cpp53
-rw-r--r--drape_frontend/animation/linear_animation.hpp3
-rw-r--r--drape_frontend/animation/parallel_animation.cpp34
-rw-r--r--drape_frontend/animation/parallel_animation.hpp3
-rw-r--r--drape_frontend/animation/scale_animation.cpp21
-rw-r--r--drape_frontend/animation/scale_animation.hpp3
-rw-r--r--drape_frontend/animation/sequence_animation.cpp33
-rw-r--r--drape_frontend/animation/sequence_animation.hpp3
-rw-r--r--drape_frontend/kinetic_scroller.cpp4
-rw-r--r--drape_frontend/my_position_controller.cpp14
-rw-r--r--drape_frontend/my_position_controller.hpp2
-rw-r--r--drape_frontend/user_event_stream.cpp8
-rw-r--r--drape_frontend/user_event_stream.hpp2
21 files changed, 340 insertions, 16 deletions
diff --git a/drape_frontend/animation/animation.cpp b/drape_frontend/animation/animation.cpp
index 478fb6a660..a750cc2645 100644
--- a/drape_frontend/animation/animation.cpp
+++ b/drape_frontend/animation/animation.cpp
@@ -3,6 +3,7 @@
namespace df
{
+// static
bool Animation::GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property, PropertyValue & value)
{
auto const it = properties.find(make_pair(object, property));
@@ -14,6 +15,7 @@ bool Animation::GetCachedProperty(TPropertyCache const & properties, Object obje
return false;
}
+// static
void Animation::GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen, ScreenBase & currentScreen)
{
currentScreen = screen;
@@ -60,4 +62,32 @@ bool Animation::HasTargetProperty(Object object, ObjectProperty property) const
return HasProperty(object, property);
}
+// static
+bool Animation::GetMinDuration(Interpolator const & interpolator, double & minDuration)
+{
+ if (interpolator.IsActive())
+ {
+ double const duration = interpolator.GetMinDuration();
+ if (duration >= 0.0)
+ minDuration = minDuration >= 0.0 ? min(duration, minDuration) : duration;
+ else
+ return false;
+ }
+ return true;
+}
+
+// static
+bool Animation::GetMaxDuration(Interpolator const & interpolator, double & maxDuration)
+{
+ if (interpolator.IsActive())
+ {
+ double const duration = interpolator.GetMaxDuration();
+ if (duration >= 0.0)
+ maxDuration = maxDuration >= 0.0 ? max(duration, maxDuration) : duration;
+ else
+ return false;
+ }
+ return true;
+}
+
} // namespace df
diff --git a/drape_frontend/animation/animation.hpp b/drape_frontend/animation/animation.hpp
index 9bf2d847f2..24abec543a 100644
--- a/drape_frontend/animation/animation.hpp
+++ b/drape_frontend/animation/animation.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "drape_frontend/animation/interpolators.hpp"
+
#include "drape/pointers.hpp"
#include "geometry/point2d.hpp"
@@ -95,8 +97,13 @@ public:
virtual bool HasProperty(Object object, ObjectProperty property) const = 0;
virtual bool HasTargetProperty(Object object, ObjectProperty property) const;
+ static double constexpr kInvalidAnimationDuration = -1.0;
+
virtual void SetMaxDuration(double maxDuration) = 0;
+ virtual void SetMinDuration(double minDuration) = 0;
virtual double GetDuration() const = 0;
+ virtual double GetMaxDuration() const = 0;
+ virtual double GetMinDuration() const = 0;
virtual bool IsFinished() const = 0;
virtual void Advance(double elapsedSeconds) = 0;
@@ -123,8 +130,11 @@ public:
bool CouldBeRewinded() const { return m_couldBeRewinded; }
protected:
- void GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen, ScreenBase & currentScreen);
- bool GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property, PropertyValue & value);
+ static void GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen, ScreenBase & currentScreen);
+ static bool GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property, PropertyValue & value);
+
+ static bool GetMinDuration(Interpolator const & interpolator, double & minDuration);
+ static bool GetMaxDuration(Interpolator const & interpolator, double & maxDuration);
TAction m_onStartAction;
TAction m_onFinishAction;
diff --git a/drape_frontend/animation/arrow_animation.cpp b/drape_frontend/animation/arrow_animation.cpp
index 0854e42d85..7cdb580b96 100644
--- a/drape_frontend/animation/arrow_animation.cpp
+++ b/drape_frontend/animation/arrow_animation.cpp
@@ -19,18 +19,34 @@ ArrowAnimation::ArrowAnimation(m2::PointD const & startPos, m2::PointD const & e
void ArrowAnimation::Init(ScreenBase const & screen, TPropertyCache const & properties)
{
PropertyValue value;
+ double minDuration;
+ double maxDuration;
if (GetCachedProperty(properties, Animation::Object::MyPositionArrow, Animation::ObjectProperty::Position, value))
{
+ minDuration = m_positionInterpolator.GetMinDuration();
+ maxDuration = m_positionInterpolator.GetMaxDuration();
+
m_positionInterpolator = PositionInterpolator(m_positionInterpolator.GetDuration(),
0.0 /* delay */,
value.m_valuePointD,
m_positionInterpolator.GetTargetPosition());
+
+ m_positionInterpolator.SetMinDuration(minDuration);
+ m_positionInterpolator.SetMaxDuration(maxDuration);
+
if (m_positionInterpolator.IsActive())
m_properties.insert(Animation::ObjectProperty::Position);
}
if (GetCachedProperty(properties, Animation::Object::MyPositionArrow, Animation::ObjectProperty::Angle, value))
{
+ minDuration = m_angleInterpolator.GetMinDuration();
+ maxDuration = m_angleInterpolator.GetMaxDuration();
+
m_angleInterpolator = AngleInterpolator(value.m_valueD, m_angleInterpolator.GetTargetAngle());
+
+ m_angleInterpolator.SetMinDuration(minDuration);
+ m_angleInterpolator.SetMaxDuration(maxDuration);
+
if (m_angleInterpolator.IsActive())
m_properties.insert(Animation::ObjectProperty::Angle);
}
@@ -83,6 +99,15 @@ void ArrowAnimation::SetMaxDuration(double maxDuration)
m_angleInterpolator.SetMaxDuration(maxDuration);
}
+void ArrowAnimation::SetMinDuration(double minDuration)
+{
+ if (m_positionInterpolator.IsActive())
+ m_positionInterpolator.SetMinDuration(minDuration);
+
+ if (m_angleInterpolator.IsActive())
+ m_angleInterpolator.SetMinDuration(minDuration);
+}
+
double ArrowAnimation::GetDuration() const
{
double duration = 0.0;
@@ -93,6 +118,28 @@ double ArrowAnimation::GetDuration() const
return duration;
}
+double ArrowAnimation::GetMaxDuration() const
+{
+ double maxDuration = Animation::kInvalidAnimationDuration;
+
+ if (!Animation::GetMaxDuration(m_angleInterpolator, maxDuration) ||
+ !Animation::GetMaxDuration(m_positionInterpolator, maxDuration))
+ return Animation::kInvalidAnimationDuration;
+
+ return maxDuration;
+}
+
+double ArrowAnimation::GetMinDuration() const
+{
+ double minDuration = Animation::kInvalidAnimationDuration;
+
+ if (!Animation::GetMinDuration(m_angleInterpolator, minDuration) ||
+ !Animation::GetMinDuration(m_positionInterpolator, minDuration))
+ return Animation::kInvalidAnimationDuration;
+
+ return minDuration;
+}
+
bool ArrowAnimation::IsFinished() const
{
return m_positionInterpolator.IsFinished() && m_angleInterpolator.IsFinished();
diff --git a/drape_frontend/animation/arrow_animation.hpp b/drape_frontend/animation/arrow_animation.hpp
index e8385d1ea5..123e157880 100644
--- a/drape_frontend/animation/arrow_animation.hpp
+++ b/drape_frontend/animation/arrow_animation.hpp
@@ -22,7 +22,10 @@ public:
bool HasProperty(Object object, ObjectProperty property) const override;
void SetMaxDuration(double maxDuration) override;
+ void SetMinDuration(double minDuration) override;
double GetDuration() const override;
+ double GetMinDuration() const override;
+ double GetMaxDuration() const override;
bool IsFinished() const override;
void Advance(double elapsedSeconds) override;
diff --git a/drape_frontend/animation/follow_animation.cpp b/drape_frontend/animation/follow_animation.cpp
index e8f5f06206..745bbe5413 100644
--- a/drape_frontend/animation/follow_animation.cpp
+++ b/drape_frontend/animation/follow_animation.cpp
@@ -30,13 +30,24 @@ void MapFollowAnimation::Init(ScreenBase const & screen, TPropertyCache const &
ScreenBase currentScreen;
GetCurrentScreen(properties, screen, currentScreen);
+ double minDuration = m_offsetInterpolator.GetMinDuration();
+ double maxDuration = m_offsetInterpolator.GetMaxDuration();
+
m_offset = currentScreen.PtoG(currentScreen.P3dtoP(m_endPixelPosition)) - m_globalPosition;
double const averageScale = m_isAutoZoom ? currentScreen.GetScale() : (currentScreen.GetScale() + m_endScale) / 2.0;
double const moveDuration = PositionInterpolator::GetMoveDuration(m_offset.Length(), screen.PixelRectIn3d(), averageScale);
m_offsetInterpolator = PositionInterpolator(moveDuration, 0.0, m_offset, m2::PointD(0.0, 0.0));
+ m_offsetInterpolator.SetMinDuration(minDuration);
+ m_offsetInterpolator.SetMaxDuration(maxDuration);
+
+ maxDuration = m_scaleInterpolator.GetMaxDuration();
m_scaleInterpolator = ScaleInterpolator(currentScreen.GetScale(), m_endScale, m_isAutoZoom);
+ m_scaleInterpolator.SetMaxDuration(maxDuration);
+
+ maxDuration = m_angleInterpolator.GetMaxDuration();
m_angleInterpolator = AngleInterpolator(currentScreen.GetAngle(), m_endAngle);
+ m_angleInterpolator.SetMaxDuration(maxDuration);
double const duration = CalculateDuration();
@@ -104,11 +115,46 @@ void MapFollowAnimation::SetMaxDuration(double maxDuration)
m_offsetInterpolator.SetMaxDuration(maxDuration);
}
+void MapFollowAnimation::SetMinDuration(double minDuration)
+{
+ if (m_angleInterpolator.IsActive())
+ m_angleInterpolator.SetMinDuration(minDuration);
+ if (!m_isAutoZoom && m_scaleInterpolator.IsActive())
+ m_scaleInterpolator.SetMinDuration(minDuration);
+ if (m_offsetInterpolator.IsActive())
+ m_offsetInterpolator.SetMinDuration(minDuration);
+}
+
double MapFollowAnimation::GetDuration() const
{
return CalculateDuration();
}
+double MapFollowAnimation::GetMaxDuration() const
+{
+ double maxDuration = Animation::kInvalidAnimationDuration;
+
+ if (!Animation::GetMaxDuration(m_angleInterpolator, maxDuration) ||
+ (!m_isAutoZoom && !Animation::GetMaxDuration(m_scaleInterpolator, maxDuration)) ||
+ !Animation::GetMaxDuration(m_offsetInterpolator, maxDuration))
+ return Animation::kInvalidAnimationDuration;
+
+ return maxDuration;
+}
+
+double MapFollowAnimation::GetMinDuration() const
+{
+ double minDuration = Animation::kInvalidAnimationDuration;
+
+ if (!Animation::GetMinDuration(m_angleInterpolator, minDuration) ||
+ (!m_isAutoZoom && !Animation::GetMinDuration(m_scaleInterpolator, minDuration)) ||
+ !Animation::GetMinDuration(m_offsetInterpolator, minDuration))
+ return Animation::kInvalidAnimationDuration;
+
+ return minDuration;
+}
+
+
double MapFollowAnimation::CalculateDuration() const
{
double duration = max(m_angleInterpolator.GetDuration(), m_offsetInterpolator.GetDuration());
diff --git a/drape_frontend/animation/follow_animation.hpp b/drape_frontend/animation/follow_animation.hpp
index ef721fed9b..0769fe059f 100644
--- a/drape_frontend/animation/follow_animation.hpp
+++ b/drape_frontend/animation/follow_animation.hpp
@@ -36,7 +36,10 @@ public:
void Finish() override;
void SetMaxDuration(double maxDuration) override;
+ void SetMinDuration(double minDuration) override;
double GetDuration() const override;
+ double GetMinDuration() const override;
+ double GetMaxDuration() const override;
bool IsFinished() const override;
bool GetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
diff --git a/drape_frontend/animation/interpolators.cpp b/drape_frontend/animation/interpolators.cpp
index 57267b335e..93c78169d7 100644
--- a/drape_frontend/animation/interpolators.cpp
+++ b/drape_frontend/animation/interpolators.cpp
@@ -20,6 +20,8 @@ double CalcAnimSpeedDuration(double pxDiff, double pxSpeed)
Interpolator::Interpolator(double duration, double delay)
: m_elapsedTime(0.0)
, m_duration(duration)
+ , m_maxDuration(Interpolator::kInvalidDuration)
+ , m_minDuration(Interpolator::kInvalidDuration)
, m_delay(delay)
, m_isActive(false)
{
@@ -56,12 +58,26 @@ void Interpolator::SetActive(bool active)
void Interpolator::SetMaxDuration(double maxDuration)
{
- m_duration = min(m_duration, maxDuration);
+ m_maxDuration = maxDuration;
+ if (m_maxDuration >= 0.0)
+ m_duration = min(m_duration, m_maxDuration);
}
void Interpolator::SetMinDuration(double minDuration)
{
- m_duration = max(m_duration, minDuration);
+ m_minDuration = minDuration;
+ if (m_minDuration >= 0.0)
+ m_duration = max(m_duration, m_minDuration);
+}
+
+double Interpolator::GetMaxDuration() const
+{
+ return m_maxDuration;
+}
+
+double Interpolator::GetMinDuration() const
+{
+ return m_minDuration;
}
double Interpolator::GetT() const
diff --git a/drape_frontend/animation/interpolators.hpp b/drape_frontend/animation/interpolators.hpp
index d5a044c8eb..7041a4e9b3 100644
--- a/drape_frontend/animation/interpolators.hpp
+++ b/drape_frontend/animation/interpolators.hpp
@@ -18,8 +18,13 @@ public:
void SetActive(bool active);
bool IsFinished() const;
+
+ static double constexpr kInvalidDuration = -1.0;
void SetMaxDuration(double maxDuration);
- void SetMinDuration(double minDuration);
+ void SetMinDuration(double minDuration);
+ double GetMaxDuration() const;
+ double GetMinDuration() const;
+
double GetDuration() const;
protected:
@@ -29,6 +34,9 @@ protected:
private:
double m_elapsedTime;
double m_duration;
+ double m_maxDuration;
+ double m_minDuration;
+
double m_delay;
bool m_isActive;
};
diff --git a/drape_frontend/animation/linear_animation.cpp b/drape_frontend/animation/linear_animation.cpp
index 27ac9e94d9..1102d64e7b 100644
--- a/drape_frontend/animation/linear_animation.cpp
+++ b/drape_frontend/animation/linear_animation.cpp
@@ -36,9 +36,26 @@ void MapLinearAnimation::Init(ScreenBase const & screen, TPropertyCache const &
ScreenBase currentScreen;
GetCurrentScreen(properties, screen, currentScreen);
+ double minDuration = m_positionInterpolator.GetMinDuration();
+ double maxDuration = m_positionInterpolator.GetMaxDuration();
SetMove(currentScreen.GlobalRect().GlobalZero(), m_positionInterpolator.GetTargetPosition(), currentScreen);
+
+ m_positionInterpolator.SetMinDuration(minDuration);
+ m_positionInterpolator.SetMaxDuration(maxDuration);
+
+ minDuration = m_scaleInterpolator.GetMinDuration();
+ maxDuration = m_scaleInterpolator.GetMaxDuration();
SetScale(currentScreen.GetScale(), m_scaleInterpolator.GetTargetScale());
+
+ m_scaleInterpolator.SetMinDuration(minDuration);
+ m_scaleInterpolator.SetMaxDuration(maxDuration);
+
+ minDuration = m_angleInterpolator.GetMinDuration();
+ maxDuration = m_angleInterpolator.GetMaxDuration();
SetRotate(currentScreen.GetAngle(), m_angleInterpolator.GetTargetAngle());
+
+ m_angleInterpolator.SetMinDuration(minDuration);
+ m_angleInterpolator.SetMaxDuration(maxDuration);
}
void MapLinearAnimation::SetMove(m2::PointD const & startPos, m2::PointD const & endPos,
@@ -119,6 +136,18 @@ void MapLinearAnimation::SetMaxDuration(double maxDuration)
SetMaxScaleDuration(maxDuration);
}
+void MapLinearAnimation::SetMinDuration(double minDuration)
+{
+ if (m_angleInterpolator.IsActive())
+ m_angleInterpolator.SetMinDuration(minDuration);
+
+ if (m_positionInterpolator.IsActive())
+ m_positionInterpolator.SetMinDuration(minDuration);
+
+ if (m_scaleInterpolator.IsActive())
+ m_scaleInterpolator.SetMinDuration(minDuration);
+}
+
void MapLinearAnimation::SetMaxScaleDuration(double maxDuration)
{
if (m_scaleInterpolator.IsActive())
@@ -137,6 +166,30 @@ double MapLinearAnimation::GetDuration() const
return duration;
}
+double MapLinearAnimation::GetMaxDuration() const
+{
+ double maxDuration = Animation::kInvalidAnimationDuration;
+
+ if (!Animation::GetMaxDuration(m_angleInterpolator, maxDuration) ||
+ !Animation::GetMaxDuration(m_scaleInterpolator, maxDuration) ||
+ !Animation::GetMaxDuration(m_positionInterpolator, maxDuration))
+ return Animation::kInvalidAnimationDuration;
+
+ return maxDuration;
+}
+
+double MapLinearAnimation::GetMinDuration() const
+{
+ double minDuration = Animation::kInvalidAnimationDuration;
+
+ if (!Animation::GetMinDuration(m_angleInterpolator, minDuration) ||
+ !Animation::GetMinDuration(m_scaleInterpolator, minDuration) ||
+ !Animation::GetMinDuration(m_positionInterpolator, minDuration))
+ return Animation::kInvalidAnimationDuration;
+
+ return minDuration;
+}
+
bool MapLinearAnimation::IsFinished() const
{
return m_angleInterpolator.IsFinished() && m_scaleInterpolator.IsFinished() &&
diff --git a/drape_frontend/animation/linear_animation.hpp b/drape_frontend/animation/linear_animation.hpp
index a11c1ce84c..df3f9def49 100644
--- a/drape_frontend/animation/linear_animation.hpp
+++ b/drape_frontend/animation/linear_animation.hpp
@@ -40,7 +40,10 @@ public:
void Finish() override;
void SetMaxDuration(double maxDuration) override;
+ void SetMinDuration(double minDuration) override;
double GetDuration() const override;
+ double GetMaxDuration() const override;
+ double GetMinDuration() const override;
bool IsFinished() const override;
bool GetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
diff --git a/drape_frontend/animation/parallel_animation.cpp b/drape_frontend/animation/parallel_animation.cpp
index b59a34031c..01ca6ccde3 100644
--- a/drape_frontend/animation/parallel_animation.cpp
+++ b/drape_frontend/animation/parallel_animation.cpp
@@ -66,6 +66,12 @@ void ParallelAnimation::SetMaxDuration(double maxDuration)
anim->SetMaxDuration(maxDuration);
}
+void ParallelAnimation::SetMinDuration(double minDuration)
+{
+ for (auto const & anim : m_animations)
+ anim->SetMinDuration(minDuration);
+}
+
double ParallelAnimation::GetDuration() const
{
double duration = 0.0;
@@ -74,6 +80,34 @@ double ParallelAnimation::GetDuration() const
return duration;
}
+double ParallelAnimation::GetMaxDuration() const
+{
+ double maxDuration = Animation::kInvalidAnimationDuration;
+ double duration;
+ for (auto const & anim : m_animations)
+ {
+ duration = anim->GetMaxDuration();
+ if (duration < 0.0)
+ return Animation::kInvalidAnimationDuration;
+ maxDuration = maxDuration >= 0 ? max(duration, maxDuration) : duration;
+ }
+ return maxDuration;
+}
+
+double ParallelAnimation::GetMinDuration() const
+{
+ double minDuration = Animation::kInvalidAnimationDuration;
+ double duration;
+ for (auto const & anim : m_animations)
+ {
+ duration = anim->GetMinDuration();
+ if (duration < 0.0)
+ return Animation::kInvalidAnimationDuration;
+ minDuration = minDuration >= 0 ? min(duration, minDuration) : duration;
+ }
+ return minDuration;
+}
+
bool ParallelAnimation::IsFinished() const
{
return m_animations.empty();
diff --git a/drape_frontend/animation/parallel_animation.hpp b/drape_frontend/animation/parallel_animation.hpp
index 68a7404b3b..6091a75af1 100644
--- a/drape_frontend/animation/parallel_animation.hpp
+++ b/drape_frontend/animation/parallel_animation.hpp
@@ -34,7 +34,10 @@ public:
void OnFinish() override;
void SetMaxDuration(double maxDuration) override;
+ void SetMinDuration(double minDuration) override;
double GetDuration() const override;
+ double GetMaxDuration() const override;
+ double GetMinDuration() const override;
bool IsFinished() const override;
void Advance(double elapsedSeconds) override;
diff --git a/drape_frontend/animation/scale_animation.cpp b/drape_frontend/animation/scale_animation.cpp
index 2e39e78962..acb09f67cf 100644
--- a/drape_frontend/animation/scale_animation.cpp
+++ b/drape_frontend/animation/scale_animation.cpp
@@ -24,7 +24,13 @@ void MapScaleAnimation::Init(ScreenBase const & screen, TPropertyCache const & p
ScreenBase currentScreen;
GetCurrentScreen(properties, screen, currentScreen);
+ double const minDuration = m_scaleInterpolator.GetMinDuration();
+ double const maxDuration = m_scaleInterpolator.GetMaxDuration();
+
m_scaleInterpolator = ScaleInterpolator(currentScreen.GetScale(), m_scaleInterpolator.GetTargetScale(), false /* isAutoZoom */);
+
+ m_scaleInterpolator.SetMinDuration(minDuration);
+ m_scaleInterpolator.SetMaxDuration(maxDuration);
}
Animation::TObjectProperties const & MapScaleAnimation::GetProperties(Object object) const
@@ -54,11 +60,26 @@ void MapScaleAnimation::SetMaxDuration(double maxDuration)
m_scaleInterpolator.SetMaxDuration(maxDuration);
}
+void MapScaleAnimation::SetMinDuration(double minDuration)
+{
+ m_scaleInterpolator.SetMinDuration(minDuration);
+}
+
double MapScaleAnimation::GetDuration() const
{
return m_scaleInterpolator.GetDuration();
}
+double MapScaleAnimation::GetMaxDuration() const
+{
+ return m_scaleInterpolator.GetMaxDuration();
+}
+
+double MapScaleAnimation::GetMinDuration() const
+{
+ return m_scaleInterpolator.GetMinDuration();
+}
+
bool MapScaleAnimation::IsFinished() const
{
return m_scaleInterpolator.IsFinished();
diff --git a/drape_frontend/animation/scale_animation.hpp b/drape_frontend/animation/scale_animation.hpp
index 4bf5a0c750..9fcaf265b1 100644
--- a/drape_frontend/animation/scale_animation.hpp
+++ b/drape_frontend/animation/scale_animation.hpp
@@ -33,7 +33,10 @@ public:
void Finish() override;
void SetMaxDuration(double maxDuration) override;
+ void SetMinDuration(double minDuration) override;
double GetDuration() const override;
+ double GetMaxDuration() const override;
+ double GetMinDuration() const override;
bool IsFinished() const override;
bool GetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
diff --git a/drape_frontend/animation/sequence_animation.cpp b/drape_frontend/animation/sequence_animation.cpp
index 559c32fceb..18a6d354b4 100644
--- a/drape_frontend/animation/sequence_animation.cpp
+++ b/drape_frontend/animation/sequence_animation.cpp
@@ -69,6 +69,11 @@ void SequenceAnimation::SetMaxDuration(double maxDuration)
ASSERT(false, ("Not implemented"));
}
+void SequenceAnimation::SetMinDuration(double minDuration)
+{
+ ASSERT(false, ("Not implemented"));
+}
+
double SequenceAnimation::GetDuration() const
{
double duration = 0.0;
@@ -77,6 +82,34 @@ double SequenceAnimation::GetDuration() const
return duration;
}
+double SequenceAnimation::GetMaxDuration() const
+{
+ double maxDuration = 0.0;
+ double duration;
+ for (auto const & anim : m_animations)
+ {
+ duration = anim->GetMaxDuration();
+ if (duration < 0.0)
+ return Animation::kInvalidAnimationDuration;
+ maxDuration += duration;
+ }
+ return maxDuration;
+}
+
+double SequenceAnimation::GetMinDuration() const
+{
+ double minDuration = 0.0;
+ double duration;
+ for (auto const & anim : m_animations)
+ {
+ duration = anim->GetMinDuration();
+ if (duration < 0.0)
+ return Animation::kInvalidAnimationDuration;
+ minDuration += duration;
+ }
+ return minDuration;
+}
+
bool SequenceAnimation::IsFinished() const
{
return m_animations.empty();
diff --git a/drape_frontend/animation/sequence_animation.hpp b/drape_frontend/animation/sequence_animation.hpp
index 33077eb8be..835e29b0dc 100644
--- a/drape_frontend/animation/sequence_animation.hpp
+++ b/drape_frontend/animation/sequence_animation.hpp
@@ -27,7 +27,10 @@ public:
void SetCustomType(string const & type);
void SetMaxDuration(double maxDuration) override;
+ void SetMinDuration(double minDuration) override;
double GetDuration() const override;
+ double GetMaxDuration() const override;
+ double GetMinDuration() const override;
bool IsFinished() const override;
bool GetProperty(Object object, ObjectProperty property, PropertyValue &value) const override;
diff --git a/drape_frontend/kinetic_scroller.cpp b/drape_frontend/kinetic_scroller.cpp
index 13dddc929f..ea532c9966 100644
--- a/drape_frontend/kinetic_scroller.cpp
+++ b/drape_frontend/kinetic_scroller.cpp
@@ -67,6 +67,10 @@ public:
m_duration = maxDuration;
}
+ void SetMinDuration(double minDuration) override {}
+ double GetMaxDuration() const override { return Animation::kInvalidAnimationDuration; }
+ double GetMinDuration() const override { return Animation::kInvalidAnimationDuration; }
+
double GetDuration() const override { return m_duration; }
bool IsFinished() const override { return m_elapsedTime >= m_duration; }
diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp
index 088adb2f83..f8b44c7317 100644
--- a/drape_frontend/my_position_controller.cpp
+++ b/drape_frontend/my_position_controller.cpp
@@ -759,11 +759,17 @@ void MyPositionController::CreateAnim(m2::PointD const & oldPos, double oldAzimu
{
if (IsModeChangeViewport())
{
- m_animCreator = [this, moveDuration](double correctedDuration) -> drape_ptr<Animation>
+ m_animCreator = [this, moveDuration](ref_ptr<Animation> syncAnim) -> drape_ptr<Animation>
{
- return make_unique_dp<ArrowAnimation>(GetDrawablePosition(), m_position,
- correctedDuration > 0.0 ? correctedDuration : moveDuration,
- GetDrawableAzimut(), m_drawDirection);
+ drape_ptr<Animation> anim = make_unique_dp<ArrowAnimation>(GetDrawablePosition(), m_position,
+ syncAnim == nullptr ? moveDuration : syncAnim->GetDuration(),
+ GetDrawableAzimut(), m_drawDirection);
+ if (syncAnim != nullptr)
+ {
+ anim->SetMaxDuration(syncAnim->GetMaxDuration());
+ anim->SetMinDuration(syncAnim->GetMinDuration());
+ }
+ return anim;
};
m_oldPosition = oldPos;
m_oldDrawDirection = oldAzimut;
diff --git a/drape_frontend/my_position_controller.hpp b/drape_frontend/my_position_controller.hpp
index 1f11c1e7b7..0174eaaaa7 100644
--- a/drape_frontend/my_position_controller.hpp
+++ b/drape_frontend/my_position_controller.hpp
@@ -17,7 +17,7 @@ namespace df
{
class Animation;
-using TAnimationCreator = function<drape_ptr<Animation>(double)>;
+using TAnimationCreator = function<drape_ptr<Animation>(ref_ptr<Animation>)>;
class MyPositionController
{
diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp
index 4dda6ff207..270a4cc379 100644
--- a/drape_frontend/user_event_stream.cpp
+++ b/drape_frontend/user_event_stream.cpp
@@ -38,8 +38,6 @@ uint64_t const kKineticDelayMs = 500;
float const kForceTapThreshold = 0.75;
-double const kDoNotChangeDuration = -1.0;
-
size_t GetValidTouchesCount(array<Touch, 2> const & touches)
{
size_t result = 0;
@@ -460,7 +458,7 @@ bool UserEventStream::SetScreen(ScreenBase const & endScreen, bool isAnim, TAnim
{
drape_ptr<ParallelAnimation> parallelAnim = make_unique_dp<ParallelAnimation>();
parallelAnim->SetCustomType(kParallelLinearAnim);
- parallelAnim->AddAnimation(parallelAnimCreator(kDoNotChangeDuration));
+ parallelAnim->AddAnimation(parallelAnimCreator(nullptr /* syncAnim */));
parallelAnim->AddAnimation(move(anim));
m_animationSystem.CombineAnimation(move(parallelAnim));
}
@@ -551,8 +549,8 @@ bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD
{
drape_ptr<ParallelAnimation> parallelAnim = make_unique_dp<ParallelAnimation>();
parallelAnim->SetCustomType(kParallelFollowAnim);
- parallelAnim->AddAnimation(parallelAnimCreator(anim->GetType() == Animation::Type::MapFollow ? anim->GetDuration()
- : kDoNotChangeDuration));
+ parallelAnim->AddAnimation(parallelAnimCreator(anim->GetType() == Animation::Type::MapFollow ? make_ref(anim)
+ : nullptr));
parallelAnim->AddAnimation(move(anim));
m_animationSystem.CombineAnimation(move(parallelAnim));
}
diff --git a/drape_frontend/user_event_stream.hpp b/drape_frontend/user_event_stream.hpp
index c7e7598ea7..58be5dfdf7 100644
--- a/drape_frontend/user_event_stream.hpp
+++ b/drape_frontend/user_event_stream.hpp
@@ -23,7 +23,7 @@ namespace df
int const kDoNotChangeZoom = -1;
double const kDoNotAutoZoom = -1.0;
-using TAnimationCreator = function<drape_ptr<Animation>(double)>;
+using TAnimationCreator = function<drape_ptr<Animation>(ref_ptr<Animation>)>;
class UserEvent
{