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