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