forked from organicmaps/organicmaps
refactored anim::Task and anim::Controller to distinguish between normal Task ending and cancellation.
This commit is contained in:
parent
80d3874ed0
commit
378ba050ee
4 changed files with 28 additions and 10 deletions
|
@ -60,14 +60,20 @@ namespace anim
|
|||
for (TTasks::const_iterator it = m_tasksList.begin(); it != m_tasksList.end(); ++it)
|
||||
{
|
||||
shared_ptr<Task> const & task = *it;
|
||||
if (task->State() == Task::EWaitStart)
|
||||
if (task->State() == Task::EStarted)
|
||||
task->OnStart(ts);
|
||||
if (task->State() == Task::EInProgress)
|
||||
task->OnStep(ts);
|
||||
if (task->State() == Task::EWaitEnd)
|
||||
task->OnEnd(ts);
|
||||
else
|
||||
|
||||
if (task->State() == Task::EInProgress)
|
||||
l.push_back(task);
|
||||
else
|
||||
{
|
||||
if (task->State() == Task::ECancelled)
|
||||
task->OnCancel(ts);
|
||||
if (task->State() == Task::EEnded)
|
||||
task->OnEnd(ts);
|
||||
}
|
||||
}
|
||||
|
||||
m_tasks.ProcessList(bind(&Controller::CopyTasks, this, ref(l), _1));
|
||||
|
|
|
@ -9,9 +9,10 @@ namespace anim
|
|||
|
||||
enum EState
|
||||
{
|
||||
EWaitStart,
|
||||
EStarted,
|
||||
EInProgress,
|
||||
EWaitEnd
|
||||
ECancelled,
|
||||
EEnded
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -32,8 +33,12 @@ namespace anim
|
|||
virtual void OnStart(double ts);
|
||||
virtual void OnStep(double ts);
|
||||
virtual void OnEnd(double ts);
|
||||
virtual void OnCancel(double ts);
|
||||
|
||||
void Finish();
|
||||
bool IsFinished() const;
|
||||
void Cancel();
|
||||
void End();
|
||||
|
||||
bool IsCancelled() const;
|
||||
bool IsEnded() const;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@ void RotateScreenTask::OnStep(double ts)
|
|||
{
|
||||
if (ts - m_startTime > m_interval)
|
||||
{
|
||||
Finish();
|
||||
End();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsFinished())
|
||||
if (IsEnded())
|
||||
return;
|
||||
|
||||
double elapsedSec = ts - m_startTime;
|
||||
|
@ -37,3 +37,9 @@ void RotateScreenTask::OnStep(double ts)
|
|||
m_framework->GetNavigator().Rotate(angle - m_curAngle);
|
||||
m_curAngle = angle;
|
||||
}
|
||||
|
||||
void RotateScreenTask::OnEnd(double ts)
|
||||
{
|
||||
/// ensuring that the final angle is reached
|
||||
m_framework->GetNavigator().SetAngle(m_endAngle);
|
||||
}
|
||||
|
|
|
@ -25,4 +25,5 @@ public:
|
|||
|
||||
void OnStart(double ts);
|
||||
void OnStep(double ts);
|
||||
void OnEnd(double ts);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue