Merge "Fix: The last line of the text overlaps with the text-editor's border/edge...
[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] useDestinationTarget True if this transition uses destination control as target.
45    * @param[in] timePeriod The timePeriod of the animation.
46    * @return A smart-pointer to the newly allocated Transition.
47    */
48   static TransitionPtr New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, bool useDestinationTarget, TimePeriod timePeriod);
49
50 protected:
51   /**
52    * @copydoc Dali::Toolkit::Transition::OnPlay()
53    */
54   void OnPlay() override;
55
56   /**
57    * @brief Emit the Finished signal
58    */
59   void OnFinished() override;
60
61 protected:
62   /**
63    * @brief Construct a new Transition.
64    */
65   Transition(Dali::Toolkit::Control source,
66              Dali::Toolkit::Control destination,
67              bool                   useDestinationTarget,
68              TimePeriod             timePeriod);
69
70   /**
71    * @brief A reference counted object may only be deleted by calling Unreference()
72    */
73   ~Transition() override;
74
75 private:
76   // Undefined
77   Transition(const Transition&);
78
79   // Undefined
80   Transition& operator=(const Transition& rhs);
81
82 private:
83   Dali::Toolkit::Control GetTargetControl();
84   Dali::Toolkit::Control GetWaitingControl();
85
86 private:
87   bool                                                               mUseDestinationTarget;
88   Vector3                                                            mOriginalSize;
89   std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>> mOriginalVisualProperties;
90   WeakHandle<Dali::Toolkit::Control>                                 mSourceControl;
91   WeakHandle<Dali::Toolkit::Control>                                 mDestinationControl;
92 };
93
94 } // namespace Internal
95
96 // Helpers for public-api forwarding methods
97
98 inline Internal::Transition& GetImplementation(Dali::Toolkit::Transition& transition)
99 {
100   DALI_ASSERT_ALWAYS(transition && "Transition handle is empty");
101
102   BaseObject& handle = transition.GetBaseObject();
103
104   return static_cast<Internal::Transition&>(handle);
105 }
106
107 inline const Internal::Transition& GetImplementation(const Dali::Toolkit::Transition& transition)
108 {
109   DALI_ASSERT_ALWAYS(transition && "Transition handle is empty");
110
111   const BaseObject& handle = transition.GetBaseObject();
112
113   return static_cast<const Internal::Transition&>(handle);
114 }
115
116 } // namespace Toolkit
117
118 } // namespace Dali
119
120 #endif // DALI_TOOLKIT_INTERNAL_TRANSITION_H