1 #ifndef DALI_INTERNAL_ANIMATION_PLAYLIST_H
2 #define DALI_INTERNAL_ANIMATION_PLAYLIST_H
5 * Copyright (c) 2023 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/devel-api/common/map-wrapper.h>
23 #include <dali/internal/common/message.h>
24 #include <dali/internal/common/ordered-set.h>
25 #include <dali/internal/event/common/complete-notification-interface.h>
26 #include <dali/public-api/animation/animation.h>
27 #include <dali/public-api/common/dali-vector.h>
28 #include <dali/public-api/common/vector-wrapper.h>
42 * AnimationPlaylist provides notifications to applications when animations are finished.
43 * It reference-counts playing animations, to allow "fire and forget" behaviour.
45 class AnimationPlaylist : public CompleteNotificationInterface
49 * Create an AnimationPlaylist.
50 * @return A newly allocated animation playlist.
52 static AnimationPlaylist* New();
57 ~AnimationPlaylist() override;
60 * Called when an animation is constructed.
62 void AnimationCreated(Animation& animation);
65 * Called when an animation is destroyed.
67 void AnimationDestroyed(Animation& animation);
70 * Called when an animation is playing.
71 * @post The animation will be referenced by AnimationPlaylist, until the "Finished" signal is emitted.
73 void OnPlay(Animation& animation);
76 * Called when an animation is cleared.
77 * @post The animation will no longer be referenced by AnimationPlaylist.
79 void OnClear(Animation& animation);
82 * @brief Notify that an animation has reached a progress marker
83 * @param[in] sceneGraphAnimation scene graph animation that has reached progress
85 void NotifyProgressReached(const SceneGraph::Animation* sceneGraphAnimation);
88 * @brief Retrive the number of Animations.
90 * @return The number of Animations.
92 uint32_t GetAnimationCount();
95 * @brief Retrieve an Animation by index.
97 * @param[in] index The index of the Animation to retrieve
98 * @return The Dali::Animation for the given index or empty handle
100 Dali::Animation GetAnimationAt(uint32_t index);
104 * Create an AnimationPlaylist.
109 AnimationPlaylist(const AnimationPlaylist&);
112 AnimationPlaylist& operator=(const AnimationPlaylist& rhs);
114 private: // from CompleteNotificationInterface
116 * @copydoc CompleteNotificationInterface::NotifyCompleted()
118 void NotifyCompleted() override;
121 OrderedSet<Animation, false> mAnimations; ///< All existing animations (not owned)
122 std::map<Dali::Animation, uint32_t> mPlaylist; ///< The currently playing animations (owned through handle). Note we can hold same handles multiple.
126 * Called when an animation reaches a progress marker
128 * Note animationPlaylist is of type CompleteNotificationInterface because of updateManager only knowing about the interface not actual playlist
130 inline MessageBase* NotifyProgressReachedMessage(CompleteNotificationInterface& animationPlaylist, const SceneGraph::Animation* animation)
132 return new MessageValue1<AnimationPlaylist, const SceneGraph::Animation*>(static_cast<AnimationPlaylist*>(&animationPlaylist), &AnimationPlaylist::NotifyProgressReached, animation);
135 } // namespace Internal
139 #endif // DALI_INTERNAL_ANIMATION_PLAYLIST_H