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/set-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 * @param[in] animation The animation that is cleared.
79 * @param[in] ignoreRequired Whether to ignore the notify for current event loop, or not.
80 * @post The animation will no longer be referenced by AnimationPlaylist.
82 void OnClear(Animation& animation, bool ignoreRequired);
85 * Notify from core that current event loop finisehd.
86 * It will clear all ignored animations at OnClear.
88 void EventLoopFinished();
91 * @brief Notify that an animation has reached a progress marker
92 * @param[in] notifyId scene graph animation's notifyId that has reached progress
94 void NotifyProgressReached(NotifierInterface::NotifyId notifyId);
97 * @brief Retrive the number of Animations.
99 * @return The number of Animations.
101 uint32_t GetAnimationCount();
104 * @brief Retrieve an Animation by index.
106 * @param[in] index The index of the Animation to retrieve
107 * @return The Dali::Animation for the given index or empty handle
109 Dali::Animation GetAnimationAt(uint32_t index);
113 * Create an AnimationPlaylist.
118 AnimationPlaylist(const AnimationPlaylist&);
121 AnimationPlaylist& operator=(const AnimationPlaylist& rhs);
123 private: // from CompleteNotificationInterface
125 * @copydoc CompleteNotificationInterface::NotifyCompleted()
127 void NotifyCompleted(CompleteNotificationInterface::ParameterList notifierList) override;
130 Integration::OrderedSet<Animation, false> mAnimations; ///< All existing animations (not owned)
131 std::set<Dali::Animation> mPlaylist; ///< The currently playing animations (owned through handle).
132 std::set<NotifierInterface::NotifyId> mIgnoredAnimations; ///< The currently cleard animations. We should not send notification at NotifyCompleted.
136 * Called when an animation reaches a progress marker
138 * Note animationPlaylist is of type CompleteNotificationInterface because of updateManager only knowing about the interface not actual playlist
140 inline MessageBase* NotifyProgressReachedMessage(CompleteNotificationInterface& animationPlaylist, NotifierInterface::NotifyId notifyId)
142 return new MessageValue1<AnimationPlaylist, NotifierInterface::NotifyId>(static_cast<AnimationPlaylist*>(&animationPlaylist), &AnimationPlaylist::NotifyProgressReached, notifyId);
145 } // namespace Internal
149 #endif // DALI_INTERNAL_ANIMATION_PLAYLIST_H