Merge changes I2df640e0,Ia1188305,I7fae506e,I7967a7cc,Ib0fdcdf4, ... into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-vector-image / vector-animation-manager.h
1 #ifndef DALI_TOOLKIT_INTERNAL_VECTOR_ANIMATION_MANAGER_H
2 #define DALI_TOOLKIT_INTERNAL_VECTOR_ANIMATION_MANAGER_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/signals/callback.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/integration-api/processor-interface.h>
25 #include <memory>
26
27 // INTERNAL INCLUDES
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Internal
36 {
37
38 class VectorAnimationThread;
39
40 /**
41  * @brief Vector animation manager
42  */
43 class VectorAnimationManager: public Integration::Processor
44 {
45 public:
46   struct LifecycleObserver
47   {
48     virtual void VectorAnimationManagerDestroyed() = 0;
49   };
50
51   /**
52    * @brief Constructor.
53    */
54   VectorAnimationManager();
55
56   /**
57    * @brief Destructor.
58    */
59   ~VectorAnimationManager() override;
60
61   /**
62    * Add a lifecycle observer
63    * @param[in] observer The object watching this one
64    */
65   void AddObserver( LifecycleObserver& observer );
66
67   /**
68    * Remove a lifecycle observer
69    * @param[in] observer The object watching this one
70    */
71   void RemoveObserver( LifecycleObserver& observer );
72
73   /**
74    * Get the vector animation thread.
75    * @return A raw pointer pointing to the vector animation thread.
76    */
77   VectorAnimationThread& GetVectorAnimationThread();
78
79   /**
80    * @brief Register a callback.
81    *
82    * @param callback The callback to register
83    * @note Ownership of the callback is passed onto this class.
84    */
85   void RegisterEventCallback( CallbackBase* callback );
86
87   /**
88    * @brief Unregister a previously registered callback
89    *
90    * @param callback The callback to unregister
91    */
92   void UnregisterEventCallback( CallbackBase* callback );
93
94 protected: // Implementation of Processor
95
96   /**
97    * @copydoc Dali::Integration::Processor::Process()
98    */
99   void Process() override;
100
101 private:
102
103   // Undefined
104   VectorAnimationManager( const VectorAnimationManager& manager ) = delete;
105
106   // Undefined
107   VectorAnimationManager& operator=( const VectorAnimationManager& manager ) = delete;
108
109 private:
110
111   std::vector< CallbackBase* >             mEventCallbacks;
112   std::vector<LifecycleObserver*>         mLifecycleObservers;
113   std::unique_ptr< VectorAnimationThread > mVectorAnimationThread;
114   bool                                     mProcessorRegistered;
115 };
116
117 } // namespace Internal
118
119 } // namespace Toolkit
120
121 } // namespace Dali
122
123 #endif // DALI_TOOLKIT_INTERNAL_VECTOR_ANIMATION_MANAGER_H