[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / transition / transition-set.h
1 #ifndef DALI_TOOLKIT_TRANSITION_SET_H
2 #define DALI_TOOLKIT_TRANSITION_SET_H
3
4 /*
5  * Copyright (c) 2021 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/public-api/transition/transition-base.h>
23
24 // EXTERNAL INCLUDES
25 #include <dali/public-api/object/handle.h>
26 #include <dali/public-api/signals/dali-signal.h>
27 #include <cstdint> // uint32_t, uint8_t
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Internal DALI_INTERNAL
34 {
35 class TransitionSet;
36 }
37
38 /**
39  * @brief
40  * TransitionSet is used to control lifetime of multiple Transitions.
41  * Transition could be played with multiple other transitions for a scene change.
42  * For the case, it is more useful to manage a group of transitions with same lifetime and a finished signal.
43  * TransitionSet provides a single Play call and Finished callback for the multiple traisitions those added on it.
44  *
45  * @note
46  * Do not add transitions for a View by dividing them into multiple TransitionSets.
47  */
48 class DALI_TOOLKIT_API TransitionSet : public BaseHandle
49 {
50 public:
51   using TransitionSetSignalType = Signal<void(TransitionSet&)>; ///< TransitionSet finished signal type
52
53   /**
54    * @brief Creates an uninitialized TransitionSet; this can be initialized with TransitionSet::New().
55    *
56    * Calling member functions with an uninitialized TransitionSet handle is not allowed.
57    */
58   TransitionSet();
59
60   /**
61    * @brief Creates an initialized TransitionSet.
62    *
63    * @return A handle to a newly allocated Dali resource
64    * @note durationSeconds can not be negative.
65    */
66   static TransitionSet New();
67
68   /**
69    * @brief Downcasts a handle to TransitionSet handle.
70    *
71    * If handle points to an TransitionSet object, the downcast produces valid handle.
72    * If not, the returned handle is left uninitialized.
73    *
74    * @param[in] handle Handle to an object
75    * @return Handle to an TransitionSet object or an uninitialized handle
76    */
77   static TransitionSet DownCast(BaseHandle handle);
78
79   /**
80    * @brief Destructor.
81    *
82    * This is non-virtual since derived Handle types must not contain data or virtual methods.
83    */
84   ~TransitionSet();
85
86   /**
87    * @brief This copy constructor is required for (smart) pointer semantics.
88    *
89    * @param[in] handle A reference to the copied handle
90    */
91   TransitionSet(const TransitionSet& handle);
92
93   /**
94    * @brief This assignment operator is required for (smart) pointer semantics.
95    *
96    * @param[in] rhs A reference to the copied handle
97    * @return A reference to this
98    */
99   TransitionSet& operator=(const TransitionSet& rhs);
100
101   /**
102    * @brief Move constructor.
103    *
104    * @param[in] rhs A reference to the moved handle
105    */
106   TransitionSet(TransitionSet&& rhs);
107
108   /**
109    * @brief Move assignment operator.
110    *
111    * @param[in] rhs A reference to the moved handle
112    * @return A reference to this handle
113    */
114   TransitionSet& operator=(TransitionSet&& rhs);
115
116   /**
117    * @brief Add a TransitionBase on this TransitionSet.
118    *
119    * @param[in] transition TransitionBase to be added.
120    */
121   void AddTransition(TransitionBase transition);
122
123   /**
124    * @brief Retrieves a TransitionBase at the index.
125    *
126    * @return The TransitionBase of index
127    */
128   TransitionBase GetTransitionAt(uint32_t index) const;
129
130   /**
131    * @brief Retrieves the number of Transitions added in TransitionSet
132    *
133    * @return The number of Transitions
134    */
135   uint32_t GetTransitionCount() const;
136
137   /**
138    * @brief Play the transition.
139    * This method not make property animation instantly.
140    * Transition requires some world transform properties.
141    * The Transitions currently added on this TransitionSet are queued TransitionQueue
142    * and they are played at the end of this tick of event Thread
143    */
144   void Play();
145
146   /**
147    * @brief Connects to this signal to be notified when all TransitionSet's transitions have finished.
148    *
149    * @return A signal object to connect with
150    */
151   TransitionSetSignalType& FinishedSignal();
152
153 public: // Not intended for use by Application developers
154   /// @cond internal
155   /**
156    * @brief This constructor is used by TransitionSet::New() methods.
157    * @param[in] transition A pointer to a newly allocated Dali resource
158    */
159   explicit DALI_INTERNAL TransitionSet(Internal::TransitionSet* transition);
160   /// @endcond
161 };
162
163 } // namespace Toolkit
164
165 } // namespace Dali
166
167 #endif // DALI_TOOLKIT_TRANSITION_SET_H