Moved Gesture::State and -::Type to gesture-enumerations.h.
[platform/core/uifw/dali-core.git] / dali / internal / event / events / rotation-gesture / rotation-gesture-impl.h
1 #ifndef DALI_INTERNAL_ROTATION_GESTURE_H
2 #define DALI_INTERNAL_ROTATION_GESTURE_H
3
4 /*
5  * Copyright (c) 2020 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/public-api/math/vector2.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/events/rotation-gesture.h>
25 #include <dali/internal/event/events/gesture-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 class RotationGesture;
34 typedef IntrusivePtr< RotationGesture > RotationGesturePtr;
35
36 /**
37  * @copydoc Dali::RotationGesture
38  */
39 class RotationGesture final : public Gesture
40 {
41 public:
42
43   /**
44    * @brief Default constructor
45    */
46   RotationGesture( GestureState state )
47   : Gesture( GestureType::ROTATION, state )
48   {
49   }
50
51   RotationGesture(const RotationGesture&) = delete; ///< Deleted copy constructor
52   RotationGesture(RotationGesture&&) = delete; ///< Deleted move constructor
53   RotationGesture& operator=(const RotationGesture&) = delete; ///< Deleted copy assignment operator
54   RotationGesture& operator=(RotationGesture&&) = delete; ///< Deleted move assignment operator
55
56   /**
57    * @brief The overall rotation from the start of the rotation gesture till the latest rotation gesture.
58    * @param[in] rotation The rotation to set.
59    */
60   inline void SetRotation( const Radian& rotation )
61   {
62     mRotation = rotation;
63   }
64
65   /**
66    * @copydoc Dali::RotationGesture::GetRotation()
67    */
68   inline const Radian& GetRotation() const
69   {
70     return mRotation;
71   }
72
73   /**
74    * @brief The center point of the two points that caused the rotation gesture in screen coordinates.
75    * @param[in] screenCenterPoint The point in screen coordinates to set.
76    */
77   inline void SetScreenCenterPoint( const Vector2& screenCenterPoint )
78   {
79     mScreenCenterPoint = screenCenterPoint;
80   }
81
82   /**
83    * @copydoc Dali::RotationGesture::GetScreenCenterPoint()
84    */
85   inline const Vector2& GetScreenCenterPoint() const
86   {
87     return mScreenCenterPoint;
88   }
89
90   /**
91    * @brief The center point of the two points that caused the rotation gesture in local actor coordinates.
92    * @param[in] localCenterPoint The point in local actor coordinates to set.
93    */
94   inline void SetLocalCenterPoint( const Vector2& localCenterPoint )
95   {
96     mLocalCenterPoint = localCenterPoint;
97   }
98
99   /**
100    * @copydoc Dali::RotationGesture::GetLocalCenterPoint()
101    */
102   inline const Vector2& GetLocalCenterPoint() const
103   {
104     return mLocalCenterPoint;
105   }
106
107 private:
108
109   /**
110    * @brief Virtual destructor
111    *
112    * A reference counted object may only be deleted by calling Unreference()
113    */
114   virtual ~RotationGesture() = default;
115
116 private:
117   Radian mRotation;
118   Vector2 mScreenCenterPoint;
119   Vector2 mLocalCenterPoint;
120 };
121
122 } // namespace Internal
123
124 // Helpers for public-api forwarding methods
125
126 inline Internal::RotationGesture& GetImplementation( Dali::RotationGesture& rotationGesture )
127 {
128   DALI_ASSERT_ALWAYS( rotationGesture && "rotationGesture handle is empty" );
129
130   BaseObject& object = rotationGesture.GetBaseObject();
131
132   return static_cast< Internal::RotationGesture& >( object );
133 }
134
135 inline const Internal::RotationGesture& GetImplementation( const Dali::RotationGesture& rotationGesture )
136 {
137   DALI_ASSERT_ALWAYS( rotationGesture && "rotationGesture handle is empty" );
138
139   const BaseObject& object = rotationGesture.GetBaseObject();
140
141   return static_cast< const Internal::RotationGesture& >( object );
142 }
143
144 } // namespace Dali
145
146 #endif // DALI_INTERNAL_ROTATION_GESTURE_H