Implement Animation PlayAfter() API
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / scene-graph-animation.h
index 4f2095e..3e27055 100644 (file)
@@ -204,13 +204,19 @@ public:
    */
   void Play();
 
-  /*
+  /**
    * Play the animation from a given point
    * @param[in] progress A value between [0,1] form where the animation should start playing
    */
   void PlayFrom( float progress );
 
   /**
+   * @brief Play the animation after a given delay time.
+   * @param[in] delaySeconds The delay time
+   */
+  void PlayAfter( float delaySeconds );
+
+  /**
    * Pause the animation.
    */
   void Pause();
@@ -325,24 +331,27 @@ private:
 
 protected:
 
+  AnimatorContainer mAnimators;
+
+  Vector2 mPlayRange;
+
   float mDurationSeconds;
+  float mDelaySeconds;
+  float mElapsedSeconds;
   float mSpeedFactor;
-  EndAction mEndAction;
-  EndAction mDisconnectAction;
+  float mProgressMarker;         // Progress marker to trigger a notification
 
-  State mState;
-  float mElapsedSeconds;
   int mPlayedCount;              // Incremented at end of animation or completion of all loops
                                  // Never incremented when looping forever. Event thread tracks to signal end.
   int mLoopCount;                // N loop setting
   int mCurrentLoop;              // Current loop number
 
-  Vector2 mPlayRange;
+  EndAction mEndAction;
+  EndAction mDisconnectAction;
 
-  float mProgressMarker;                // Progress marker to trigger a notification
-  bool mProgressReachedSignalRequired;  // Flag to indicate the progress marker was hit
+  State mState;
 
-  AnimatorContainer mAnimators;
+  bool mProgressReachedSignalRequired;  // Flag to indicate the progress marker was hit
 };
 
 }; //namespace SceneGraph
@@ -489,6 +498,16 @@ inline void AddAnimatorMessage( EventThreadServices& eventThreadServices, const
   new (slot) LocalType( &animation, &Animation::AddAnimator, parameter );
 }
 
+inline void PlayAfterMessage( EventThreadServices& eventThreadServices, const Animation& animation, float delaySeconds )
+{
+  typedef MessageValue1< Animation, float > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &animation, &Animation::PlayAfter, delaySeconds );
+}
 
 } // namespace SceneGraph