Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / internal / event / events / tap-gesture / tap-gesture-impl.h
1 #ifndef DALI_INTERNAL_TAP_GESTURE_H
2 #define DALI_INTERNAL_TAP_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/tap-gesture.h>
25 #include <dali/internal/event/events/gesture-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 class TapGesture;
34 using TapGesturePtr = IntrusivePtr<TapGesture>;
35
36 /**
37  * @copydoc Dali::TapGesture
38  */
39 class TapGesture final : public Gesture
40 {
41 public:
42
43   /**
44    * @brief Default constructor
45    */
46   TapGesture( GestureState state )
47   : Gesture(GestureType::TAP, state)
48   {
49   }
50
51   TapGesture(const TapGesture&) = delete; ///< Deleted copy constructor
52   TapGesture(TapGesture&&) = delete; ///< Deleted move constructor
53   TapGesture& operator=(const TapGesture&) = delete; ///< Deleted copy assignment operator
54   TapGesture& operator=(TapGesture&&) = delete; ///< Deleted move assignment operator
55
56   /**
57    * @brief The number of taps in this tap gesture.
58    * @param[in] numberOfTaps The number of taps to set.
59    */
60   inline void SetNumberOfTaps( uint32_t numberOfTaps )
61   {
62     mNumberOfTaps = numberOfTaps;
63   }
64
65   /**
66    * @copydoc Dali::TapGesture::GetNumberOfTaps()
67    */
68   inline uint32_t GetNumberOfTaps() const
69   {
70     return mNumberOfTaps;
71   }
72
73   /**
74    * @brief The number of touch points in this tap gesture, i.e. the number of fingers the user had on the screen to generate the tap gesture.
75    * @param[in] numberOfTouches The number of touch points in this tap gesture to set.
76    */
77   inline void SetNumberOfTouches( uint32_t numberOfTouches )
78   {
79     mNumberOfTouches = numberOfTouches;
80   }
81
82   /**
83    * @copydoc Dali::TapGesture::GetPointCount()
84    */
85   inline uint32_t GetNumberOfTouches() const
86   {
87     return mNumberOfTouches;
88   }
89
90   /**
91    * @brief This is the point, in screen coordinates, where the tap occurred.
92    * @param[in] screenPoint The point in screen coordinates to set.
93    */
94   inline void SetScreenPoint( const Vector2& screenPoint )
95   {
96     mScreenPoint = screenPoint;
97   }
98
99   /**
100    * @copydoc Dali::TapGesture::GetDeviceId()
101    */
102   inline const Vector2& GetScreenPoint() const
103   {
104     return mScreenPoint;
105   }
106
107   /**
108    * @brief This is the point, in local actor coordinates, where the tap occurred.
109    * @param[in] localPoint The point in local actor coordinates to set.
110    */
111   inline void SetLocalPoint( const Vector2& localPoint )
112   {
113     mLocalPoint = localPoint;
114   }
115
116   /**
117    * @copydoc Dali::TapGesture::GetGetState()
118    */
119   inline const Vector2& GetLocalPoint() const
120   {
121     return mLocalPoint;
122   }
123
124 private:
125
126   /**
127    * @brief Virtual destructor
128    *
129    * A reference counted object may only be deleted by calling Unreference()
130    */
131   virtual ~TapGesture() = default;
132
133 private:
134   Vector2 mScreenPoint;
135   Vector2 mLocalPoint;
136   uint32_t mNumberOfTaps{1u};
137   uint32_t mNumberOfTouches{1u};
138 };
139
140 } // namespace Internal
141
142 // Helpers for public-api forwarding methods
143
144 inline Internal::TapGesture& GetImplementation( Dali::TapGesture& tapGesture )
145 {
146   DALI_ASSERT_ALWAYS( tapGesture && "TapGesture handle is empty" );
147
148   BaseObject& object = tapGesture.GetBaseObject();
149
150   return static_cast< Internal::TapGesture& >( object );
151 }
152
153 inline const Internal::TapGesture& GetImplementation( const Dali::TapGesture& tapGesture )
154 {
155   DALI_ASSERT_ALWAYS( tapGesture && "TapGesture handle is empty" );
156
157   const BaseObject& object = tapGesture.GetBaseObject();
158
159   return static_cast< const Internal::TapGesture& >( object );
160 }
161
162 } // namespace Dali
163
164 #endif // DALI_INTERNAL_TAP_GESTURE_H