6aa1374b8a25df84bbf7eca5fa3cc789390d659c
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / transition / transition-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TRANSITION_H
2 #define DALI_TOOLKIT_INTERNAL_TRANSITION_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/internal/transition/transition-base-impl.h>
23 #include <dali-toolkit/public-api/controls/control.h>
24 #include <dali-toolkit/public-api/transition/transition.h>
25
26 // EXTERNAL INCLUDES
27 #include <dali/public-api/object/weak-handle.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Internal
34 {
35 using TransitionPtr = IntrusivePtr<Transition>;
36
37 class Transition : public TransitionBase
38 {
39 public:
40   /**
41    * @brief Create a new Transition object.
42    * @param[in] source A source control of this transition.
43    * @param[in] destination A destination control of this transition.
44    * @param[in] timePeriod The timePeriod of the animation.
45    * @return A smart-pointer to the newly allocated Transition.
46    */
47   static TransitionPtr New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, TimePeriod timePeriod);
48
49 protected:
50   /**
51    * @copydoc Dali::Toolkit::Transition::OnPlay()
52    */
53   void OnPlay() override;
54
55   /**
56    * @brief Emit the Finished signal
57    */
58   void OnFinished() override;
59
60 protected:
61   /**
62    * @brief Construct a new Transition.
63    */
64   Transition(Dali::Toolkit::Control source,
65              Dali::Toolkit::Control destination,
66              TimePeriod             timePeriod);
67
68   /**
69    * @brief A reference counted object may only be deleted by calling Unreference()
70    */
71   ~Transition() override;
72
73 private:
74   // Undefined
75   Transition(const Transition&);
76
77   // Undefined
78   Transition& operator=(const Transition& rhs);
79
80 private:
81   WeakHandle<Dali::Toolkit::Control> mSourceControl;
82   WeakHandle<Dali::Toolkit::Control> mDestinationControl;
83 };
84
85 } // namespace Internal
86
87 // Helpers for public-api forwarding methods
88
89 inline Internal::Transition& GetImplementation(Dali::Toolkit::Transition& transition)
90 {
91   DALI_ASSERT_ALWAYS(transition && "Transition handle is empty");
92
93   BaseObject& handle = transition.GetBaseObject();
94
95   return static_cast<Internal::Transition&>(handle);
96 }
97
98 inline const Internal::Transition& GetImplementation(const Dali::Toolkit::Transition& transition)
99 {
100   DALI_ASSERT_ALWAYS(transition && "Transition handle is empty");
101
102   const BaseObject& handle = transition.GetBaseObject();
103
104   return static_cast<const Internal::Transition&>(handle);
105 }
106
107 } // namespace Toolkit
108
109 } // namespace Dali
110
111 #endif // DALI_TOOLKIT_INTERNAL_TRANSITION_H