1 #ifndef DALI_INTERNAL_ANIMATION_PLAYLIST_H
2 #define DALI_INTERNAL_ANIMATION_PLAYLIST_H
5 * Copyright (c) 2024 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/integration-api/ordered-set.h>
24 #include <dali/internal/common/message.h>
25 #include <dali/internal/event/common/complete-notification-interface.h>
26 #include <dali/internal/event/common/scene-graph-notifier-interface-mapper.h>
27 #include <dali/public-api/animation/animation.h>
28 #include <dali/public-api/common/dali-vector.h>
29 #include <dali/public-api/common/vector-wrapper.h>
43 * AnimationPlaylist provides notifications to applications when animations are finished.
44 * It reference-counts playing animations, to allow "fire and forget" behaviour.
46 class AnimationPlaylist : public CompleteNotificationInterface, public SceneGraphNotifierInterfaceMapper<Animation>
50 * Create an AnimationPlaylist.
51 * @return A newly allocated animation playlist.
53 static AnimationPlaylist* New();
58 ~AnimationPlaylist() override;
61 * Called when an animation is constructed.
63 void AnimationCreated(Animation& animation);
66 * Called when an animation is destroyed.
68 void AnimationDestroyed(Animation& animation);
71 * Called when an animation is playing.
72 * @post The animation will be referenced by AnimationPlaylist, until the "Finished" signal is emitted.
74 void OnPlay(Animation& animation);
77 * Called when an animation is cleared.
78 * @post The animation will no longer be referenced by AnimationPlaylist.
80 void OnClear(Animation& animation);
83 * @brief Notify that an animation has reached a progress marker
84 * @param[in] notifyId scene graph animation's notifyId that has reached progress
86 void NotifyProgressReached(NotifierInterface::NotifyId notifyId);
89 * @brief Retrive the number of Animations.
91 * @return The number of Animations.
93 uint32_t GetAnimationCount();
96 * @brief Retrieve an Animation by index.
98 * @param[in] index The index of the Animation to retrieve
99 * @return The Dali::Animation for the given index or empty handle
101 Dali::Animation GetAnimationAt(uint32_t index);
105 * Create an AnimationPlaylist.
110 AnimationPlaylist(const AnimationPlaylist&);
113 AnimationPlaylist& operator=(const AnimationPlaylist& rhs);
115 private: // from CompleteNotificationInterface
117 * @copydoc CompleteNotificationInterface::NotifyCompleted()
119 void NotifyCompleted(CompleteNotificationInterface::ParameterList notifierList) override;
122 Integration::OrderedSet<Animation, false> mAnimations; ///< All existing animations (not owned)
123 std::map<Dali::Animation, uint32_t> mPlaylist; ///< The currently playing animations (owned through handle).
124 ///< Note we can hold same handles multiple, since OnClear can be called after NotifyCompleted.
128 * Called when an animation reaches a progress marker
130 * Note animationPlaylist is of type CompleteNotificationInterface because of updateManager only knowing about the interface not actual playlist
132 inline MessageBase* NotifyProgressReachedMessage(CompleteNotificationInterface& animationPlaylist, NotifierInterface::NotifyId notifyId)
134 return new MessageValue1<AnimationPlaylist, NotifierInterface::NotifyId>(static_cast<AnimationPlaylist*>(&animationPlaylist), &AnimationPlaylist::NotifyProgressReached, notifyId);
137 } // namespace Internal
141 #endif // DALI_INTERNAL_ANIMATION_PLAYLIST_H