1 #ifndef DALI_INTERNAL_ANIMATION_PLAYLIST_H
2 #define DALI_INTERNAL_ANIMATION_PLAYLIST_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/internal/common/message.h>
23 #include <dali/internal/event/common/complete-notification-interface.h>
24 #include <dali/public-api/animation/animation.h>
25 #include <dali/public-api/common/dali-vector.h>
26 #include <dali/public-api/common/vector-wrapper.h>
40 * AnimationPlaylist provides notifications to applications when animations are finished.
41 * It reference-counts playing animations, to allow "fire and forget" behaviour.
43 class AnimationPlaylist : public CompleteNotificationInterface
47 * Create an AnimationPlaylist.
48 * @return A newly allocated animation playlist.
50 static AnimationPlaylist* New();
55 ~AnimationPlaylist() override;
58 * Called when an animation is constructed.
60 void AnimationCreated(Animation& animation);
63 * Called when an animation is destroyed.
65 void AnimationDestroyed(Animation& animation);
68 * Called when an animation is playing.
69 * @post The animation will be referenced by AnimationPlaylist, until the "Finished" signal is emitted.
71 void OnPlay(Animation& animation);
74 * Called when an animation is cleared.
75 * @post The animation will no longer be referenced by AnimationPlaylist.
77 void OnClear(Animation& animation);
80 * @brief Notify that an animation has reached a progress marker
81 * @param[in] sceneGraphAnimation scene graph animation that has reached progress
83 void NotifyProgressReached(const SceneGraph::Animation* sceneGraphAnimation);
86 * @brief Retrive the number of Animations.
88 * @return The number of Animations.
90 uint32_t GetAnimationCount();
93 * @brief Retrieve an Animation by index.
95 * @param[in] index The index of the Animation to retrieve
96 * @return The Dali::Animation for the given index or empty handle
98 Dali::Animation GetAnimationAt(uint32_t index);
102 * Create an AnimationPlaylist.
107 AnimationPlaylist(const AnimationPlaylist&);
110 AnimationPlaylist& operator=(const AnimationPlaylist& rhs);
112 private: // from CompleteNotificationInterface
114 * @copydoc CompleteNotificationInterface::NotifyCompleted()
116 void NotifyCompleted() override;
119 Dali::Vector<Animation*> mAnimations; ///< All existing animations (not owned)
120 std::vector<Dali::Animation> mPlaylist; ///< The currently playing animations (owned through handle)
124 * Called when an animation reaches a progress marker
126 * Note animationPlaylist is of type CompleteNotificationInterface because of updateManager only knowing about the interface not actual playlist
128 inline MessageBase* NotifyProgressReachedMessage(CompleteNotificationInterface& animationPlaylist, const SceneGraph::Animation* animation)
130 return new MessageValue1<AnimationPlaylist, const SceneGraph::Animation*>(static_cast<AnimationPlaylist*>(&animationPlaylist), &AnimationPlaylist::NotifyProgressReached, animation);
133 } // namespace Internal
137 #endif // DALI_INTERNAL_ANIMATION_PLAYLIST_H