569bcb000a7d16c30f29473d8942a1a9a4826be5
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / animation-playlist.h
1 #ifndef __DALI_INTERNAL_ANIMATION_PLAYLIST_H__
2 #define __DALI_INTERNAL_ANIMATION_PLAYLIST_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 // EXTERNAL INCLUDES
21 #include <set>
22
23 // INTERNAL INCLUDES
24 #include <dali/internal/common/message.h>
25 #include <dali/internal/event/animation/animation-finished-notifier.h>
26 #include <dali/public-api/animation/animation.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 class Animation;
35
36 /**
37  * AnimationPlaylist provides notifications to applications when animations are finished.
38  * It reference-counts playing animations, to allow "fire and forget" behaviour.
39  */
40 class AnimationPlaylist : public AnimationFinishedNotifier
41 {
42 public:
43
44   /**
45    * Create an AnimationPlaylist.
46    * @return A newly allocated animation playlist.
47    */
48   static AnimationPlaylist* New();
49
50   /**
51    * Virtual destructor.
52    */
53   virtual ~AnimationPlaylist();
54
55   /**
56    * Called when an animation is constructed.
57    */
58   void AnimationCreated( Animation& animation );
59
60   /**
61    * Called when an animation is destroyed.
62    */
63   void AnimationDestroyed( Animation& animation );
64
65   /**
66    * Called when an animation is playing.
67    * @post The animation will be referenced by AnimationPlaylist, until the "Finished" signal is emitted.
68    */
69   void OnPlay( Animation& animation );
70
71   /**
72    * Called when an animation is cleared.
73    * @post The animation will no longer be referenced by AnimationPlaylist.
74    */
75   void OnClear( Animation& animation );
76
77   /**
78    * From AnimationFinishedNotifier; emit "Finished" signal on any animations that have finished.
79    * This method should be called in the event-thread; the update-thread must use AnimationFinishedMessage.
80    * @post The "Finished" animations will no longer be referenced by AnimationPlaylist.
81    */
82   void NotifyFinishedAnimations();
83
84 private:
85
86   /**
87    * Create an AnimationPlaylist.
88    */
89   AnimationPlaylist();
90
91   // Undefined
92   AnimationPlaylist(const AnimationPlaylist&);
93
94   // Undefined
95   AnimationPlaylist& operator=(const AnimationPlaylist& rhs);
96
97 private:
98
99   std::set< Animation* > mAnimations; ///< All existing animations (not referenced)
100
101   std::set< Dali::Animation > mPlaylist; ///< The currently playing animations (reference counted)
102 };
103
104 } // namespace Internal
105
106 } // namespace Dali
107
108 #endif // __DALI_INTERNAL_NOTIFICATION_MANAGER_H__
109