Remove std::vector dependency for dali-signal.h
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / transition / transition-set-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TRANSITION_SET_H
2 #define DALI_TOOLKIT_INTERNAL_TRANSITION_SET_H
3
4 /*
5  * Copyright (c) 2022 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 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/transition/transition-impl.h>
23 #include <dali-toolkit/public-api/transition/transition-set.h>
24
25 // EXTERNAL INCLUDES
26 #include <dali/integration-api/processor-interface.h>
27 #include <dali/public-api/common/vector-wrapper.h>
28 #include <dali/public-api/object/base-object.h>
29 #include <dali/public-api/signals/connection-tracker.h>
30
31 namespace Dali
32 {
33 namespace Toolkit
34 {
35 namespace Internal
36 {
37 using TransitionSetPtr = IntrusivePtr<TransitionSet>;
38
39 class TransitionSet : public BaseObject, public ConnectionTracker, public Integration::Processor
40 {
41 public:
42   /**
43    * Create a new TransitionSet object.
44    * @return A smart-pointer to the newly allocated TransitionSet.
45    */
46   static TransitionSetPtr New();
47
48   /**
49    * @copydoc Dali::Toolkit::TransitionSet::AddTransition(TransitionPtr transition)
50    */
51   void AddTransition(TransitionBasePtr transition);
52
53   /**
54    * @copydoc Dali::Toolkit::TransitionSet::GetTransitionAt(uint32_t index)
55    */
56   TransitionBase* GetTransitionAt(uint32_t index) const;
57
58   /**
59    * @copydoc Dali::Toolkit::TransitionSet::GetTransitionCount()
60    */
61   uint32_t GetTransitionCount() const;
62
63   /**
64    * @brief Make ready this transition set to play.
65    * Transitions in this transition set will be create property animations at the end of this tick of main thread.
66    */
67   void Play();
68
69   /**
70    * @copydoc Dali::Toolkit::TransitionSet::FinishedSignal()
71    */
72   Dali::Toolkit::TransitionSet::TransitionSetSignalType& FinishedSignal();
73
74   /**
75    * Connects a callback function with the object's signals.
76    * @param[in] object The object providing the signal.
77    * @param[in] tracker Used to disconnect the signal.
78    * @param[in] signalName The signal to connect to.
79    * @param[in] functor A newly allocated FunctorDelegate.
80    * @return True if the signal was connected.
81    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
82    */
83   static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
84
85 private:
86   /**
87    * @brief Set pre process of each transition.
88    */
89   void TransitionPreProcess();
90
91   /**
92    * @brief Start to play each of Transition.
93    * This method called at the end of event thread tick, and this method call OnPlay method of TransitionBase internally.
94    */
95   void TransitionStart();
96
97   /**
98    * @brief Remove each finished TransitionBase from play list.
99    * If all transitions are finished emit Finished signal.
100    */
101   void TransitionFinished(Dali::Animation& source);
102
103   /**
104    * Emit the Finished signal
105    */
106   void EmitFinishedSignal();
107
108 protected: // Implementation of Processor
109   /**
110    * @copydoc Dali::Integration::Processor::Process()
111    */
112   void Process(bool postProcessor) override;
113
114 protected:
115   /**
116    * Construct a new TransitionSet.
117    */
118   TransitionSet();
119
120   /**
121    * A reference counted object may only be deleted by calling Unreference()
122    */
123   ~TransitionSet() override;
124
125 private:
126   // Undefined
127   TransitionSet(const TransitionSet&);
128
129   // Undefined
130   TransitionSet& operator=(const TransitionSet& rhs);
131
132 private:
133   Dali::Toolkit::TransitionSet::TransitionSetSignalType mFinishedSignal{};
134   std::vector<TransitionBasePtr>                        mTransitions;
135   Dali::Animation                                       mAnimation;
136 };
137
138 } // namespace Internal
139
140 // Helpers for public-api forwarding methods
141
142 inline Internal::TransitionSet& GetImplementation(Dali::Toolkit::TransitionSet& transitionSet)
143 {
144   DALI_ASSERT_ALWAYS(transitionSet && "TransitionSet handle is empty");
145
146   BaseObject& handle = transitionSet.GetBaseObject();
147
148   return static_cast<Internal::TransitionSet&>(handle);
149 }
150
151 inline const Internal::TransitionSet& GetImplementation(const Dali::Toolkit::TransitionSet& transitionSet)
152 {
153   DALI_ASSERT_ALWAYS(transitionSet && "TransitionSet handle is empty");
154
155   const BaseObject& handle = transitionSet.GetBaseObject();
156
157   return static_cast<const Internal::TransitionSet&>(handle);
158 }
159
160 } // namespace Toolkit
161
162 } // namespace Dali
163
164 #endif // DALI_TOOLKIT_INTERNAL_TRANSITION_SET_H