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/user_mark_container.cpp
parente9f7e1d796d22ba2fab598ab2cd7e3d18d34f010 (diff)
[core] create new bookmark animation
Diffstat (limited to 'map/user_mark_container.cpp')
-rw-r--r--map/user_mark_container.cpp80
1 files changed, 11 insertions, 69 deletions
diff --git a/map/user_mark_container.cpp b/map/user_mark_container.cpp
index 3b8c847a0f..cf4fec6976 100644
--- a/map/user_mark_container.cpp
+++ b/map/user_mark_container.cpp
@@ -2,6 +2,7 @@
#include "drawer.hpp"
#include "framework.hpp"
+#include "anim_phase_chain.hpp"
#include "../graphics/display_list.hpp"
#include "../graphics/screen.hpp"
@@ -17,65 +18,17 @@
#include "../std/scoped_ptr.hpp"
#include "../std/algorithm.hpp"
+////////////////////////////////////////////////////////////////////////
+
namespace
{
- struct AnimPhase
- {
- AnimPhase(double endScale, double timeInterval)
- : m_endScale(endScale)
- , m_timeInterval(timeInterval)
- {
- }
-
- double m_endScale;
- double m_timeInterval;
- };
-
- class PinAnimation : public anim::Task
+ class PinAnimation : public AnimPhaseChain
{
public:
PinAnimation(Framework & f)
- : m_f(f)
- , m_scale(0.0)
+ : AnimPhaseChain(f, m_scale)
{
- }
-
- void AddAnimPhase(AnimPhase const & phase)
- {
- m_animPhases.push_back(phase);
- }
-
- virtual void OnStart(double ts)
- {
- m_startTime = ts;
- m_startScale = m_scale;
- m_phaseIndex = 0;
- }
-
- virtual void 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();
+ InitDefaultPinAnim(this);
}
double GetScale() const
@@ -84,19 +37,9 @@ namespace
}
private:
- Framework & m_f;
- vector<AnimPhase> m_animPhases;
- size_t m_phaseIndex;
double m_scale;
- double m_startTime;
- double m_startScale;
};
-}
-
-////////////////////////////////////////////////////////////////////////
-namespace
-{
class FindMarkFunctor
{
public:
@@ -158,7 +101,10 @@ namespace
UserMark const * mark)
{
if (mark->IsCustomDrawable())
- DrawUserMarkImpl(scale, event, static_cast<ICustomDrawable const *>(mark)->GetDisplayList(cache), mark);
+ {
+ ICustomDrawable const * drawable = static_cast<ICustomDrawable const *>(mark);
+ DrawUserMarkImpl(drawable->GetAnimScaleFactor(), event, drawable->GetDisplayList(cache), mark);
+ }
else
DefaultDrawUserMark(scale, event, cache, defaultKey, mark);
}
@@ -298,11 +244,7 @@ void UserMarkContainer::DeleteUserMark(UserMark const * mark)
void UserMarkContainer::StartActivationAnim()
{
- PinAnimation * anim = new PinAnimation(m_framework);
- anim->AddAnimPhase(AnimPhase(1.2, 0.15));
- anim->AddAnimPhase(AnimPhase(0.8, 0.08));
- anim->AddAnimPhase(AnimPhase(1, 0.05));
- m_animTask.reset(anim);
+ m_animTask.reset(new PinAnimation(m_framework));
m_framework.GetAnimController()->AddTask(m_animTask);
}