Adding Progress notification to Animation
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / scene-graph-animation.h
index 2b01ff8..4f2095e 100644 (file)
@@ -92,6 +92,12 @@ public:
   void SetDuration(float durationSeconds);
 
   /**
+   * Set the progress marker to trigger notification
+   * @param[in] progress percent of progress to trigger notification, 0.0f < progress <= 1.0f
+   */
+  void SetProgressNotification( float progress );
+
+  /**
    * Retrieve the duration of the animation.
    * @return The duration in seconds.
    */
@@ -274,8 +280,9 @@ public:
    * @param[in] elapsedSeconds The time elapsed since the previous frame.
    * @param[out] looped True if the animation looped
    * @param[out] finished True if the animation has finished.
+   * @param[out] progressReached True if progress marker reached
    */
-  void Update(BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished );
+  void Update(BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished, bool& progressReached );
 
 
 protected:
@@ -331,6 +338,10 @@ protected:
   int mCurrentLoop;              // Current loop number
 
   Vector2 mPlayRange;
+
+  float mProgressMarker;                // Progress marker to trigger a notification
+  bool mProgressReachedSignalRequired;  // Flag to indicate the progress marker was hit
+
   AnimatorContainer mAnimators;
 };
 
@@ -355,6 +366,18 @@ inline void SetDurationMessage( EventThreadServices& eventThreadServices, const
   new (slot) LocalType( &animation, &Animation::SetDuration, durationSeconds );
 }
 
+inline void SetProgressNotificationMessage( EventThreadServices& eventThreadServices, const Animation& animation, float progress )
+{
+  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::SetProgressNotification, progress );
+}
+
+
 inline void SetLoopingMessage( EventThreadServices& eventThreadServices, const Animation& animation, int loopCount )
 {
   typedef MessageValue1< Animation, int > LocalType;