[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / transition / slide-transition-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_SLIDE_TRANSITION_H
2 #define DALI_TOOLKIT_INTERNAL_SLIDE_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/slide-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 SlideTransitionPtr = IntrusivePtr<SlideTransition>;
36
37 class SlideTransition : public TransitionBase
38 {
39 public:
40   /**
41    * @brief Create a new SlideTransition object.
42    * @param[in] control A control of this transition.
43    * @param[in] direction Relative direction that the control is comming from or going to.
44    * @param[in] timePeriod The duration of the animation.
45    * @return A smart-pointer to the newly allocated SlideTransition.
46    */
47   static SlideTransitionPtr New(Dali::Toolkit::Control control, const Vector2& direction, TimePeriod timePeriod);
48
49   /**
50    * @copydoc Dali::Toolkit::SlideTransition::SetDirection()
51    */
52   void SetDirection(const Vector2& direction);
53
54   /**
55    * @copydoc Dali::Toolkit::SlideTransition::GetDirection()
56    */
57   Vector2 GetDirection() const;
58
59 protected:
60   /**
61    * @copydoc Dali::Toolkit::SlideTransition::OnPlay()
62    */
63   void OnPlay() override;
64
65 protected:
66   /**
67    * @brief Construct a new SlideTransition.
68    */
69   SlideTransition(Dali::Toolkit::Control control,
70                   const Vector2&         direction,
71                   TimePeriod             timePeriod);
72
73   /**
74    * @brief A reference counted object may only be deleted by calling Unreference()
75    */
76   ~SlideTransition() override;
77
78 private:
79   // Undefined
80   SlideTransition(const SlideTransition&);
81
82   // Undefined
83   SlideTransition& operator=(const SlideTransition& rhs);
84
85 private:
86   WeakHandle<Dali::Toolkit::Control> mTargetControl;
87   Vector2                            mDirection;
88 };
89
90 } // namespace Internal
91
92 // Helpers for public-api forwarding methods
93
94 inline Internal::SlideTransition& GetImplementation(Dali::Toolkit::SlideTransition& slide)
95 {
96   DALI_ASSERT_ALWAYS(slide && "SlideTransition handle is empty");
97
98   BaseObject& handle = slide.GetBaseObject();
99
100   return static_cast<Internal::SlideTransition&>(handle);
101 }
102
103 inline const Internal::SlideTransition& GetImplementation(const Dali::Toolkit::SlideTransition& slide)
104 {
105   DALI_ASSERT_ALWAYS(slide && "SlideTransition handle is empty");
106
107   const BaseObject& handle = slide.GetBaseObject();
108
109   return static_cast<const Internal::SlideTransition&>(handle);
110 }
111
112 } // namespace Toolkit
113
114 } // namespace Dali
115
116 #endif // DALI_TOOLKIT_INTERNAL_SLIDE_TRANSITION_H