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:
authorExMix <rahuba.youri@mapswithme.com>2014-05-16 17:31:39 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:15:41 +0300
commit751657cf725436fd5ed74b5f70a6afa80be436c1 (patch)
tree55497beb3776f42c8e0eda9aa859959f41482953 /map/anim_phase_chain.cpp
parente9f7e1d796d22ba2fab598ab2cd7e3d18d34f010 (diff)
[core] create new bookmark animation
Diffstat (limited to 'map/anim_phase_chain.cpp')
-rw-r--r--map/anim_phase_chain.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/map/anim_phase_chain.cpp b/map/anim_phase_chain.cpp
new file mode 100644
index 0000000000..e37cc54ab2
--- /dev/null
+++ b/map/anim_phase_chain.cpp
@@ -0,0 +1,69 @@
+#include "anim_phase_chain.hpp"
+
+#include "framework.hpp"
+
+AnimPhase::AnimPhase(double endScale, double timeInterval)
+ : m_endScale(endScale)
+ , m_timeInterval(timeInterval)
+{
+}
+
+AnimPhaseChain::AnimPhaseChain(Framework & f, double & scale)
+ : m_f(f)
+ , m_scale(scale)
+{
+}
+
+void AnimPhaseChain::AddAnimPhase(AnimPhase const & phase)
+{
+ m_animPhases.push_back(phase);
+}
+
+void AnimPhaseChain::OnStart(double ts)
+{
+ m_startTime = ts;
+ m_startScale = m_scale;
+ m_phaseIndex = 0;
+}
+
+void AnimPhaseChain::OnStep(double ts)
+{
+ ASSERT(m_phaseIndex < m_animPhases.size(), ());
+
+ AnimPhase const * phase = &m_animPhases[m_phaseIndex];
+ double elapsedTime = ts - m_startTime;
+ if (elapsedTime > phase->m_timeInterval)
+ {
+ m_startTime = ts;
+ m_scale = phase->m_endScale;
+ m_startScale = m_scale;
+ m_phaseIndex++;
+ if (m_phaseIndex >= m_animPhases.size())
+ {
+ End();
+ return;
+ }
+ }
+
+ elapsedTime = ts - m_startTime;
+ double t = elapsedTime / phase->m_timeInterval;
+ m_scale = m_startScale + t * (phase->m_endScale - m_startScale);
+
+ m_f.Invalidate();
+}
+
+void InitDefaultPinAnim(AnimPhaseChain * chain)
+{
+ chain->AddAnimPhase(AnimPhase(1.2, 0.15));
+ chain->AddAnimPhase(AnimPhase(0.8, 0.08));
+ chain->AddAnimPhase(AnimPhase(1, 0.05));
+}
+
+shared_ptr<anim::Task> CreateDefaultPinAnim(Framework & f, double & scale)
+{
+ AnimPhaseChain * anim = new AnimPhaseChain(f, scale);
+ InitDefaultPinAnim(anim);
+
+ return make_shared_ptr<anim::Task>(anim);
+}
+