1 #ifndef DALI_INTERNAL_TAP_GESTURE_H
2 #define DALI_INTERNAL_TAP_GESTURE_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/internal/event/events/gesture-impl.h>
23 #include <dali/public-api/events/tap-gesture.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/object/base-object.h>
32 using TapGesturePtr = IntrusivePtr<TapGesture>;
35 * @copydoc Dali::TapGesture
37 class TapGesture final : public Gesture
41 * @brief Default constructor
43 TapGesture(GestureState state)
44 : Gesture(GestureType::TAP, state)
48 TapGesture(const TapGesture&) = delete; ///< Deleted copy constructor
49 TapGesture(TapGesture&&) = delete; ///< Deleted move constructor
50 TapGesture& operator=(const TapGesture&) = delete; ///< Deleted copy assignment operator
51 TapGesture& operator=(TapGesture&&) = delete; ///< Deleted move assignment operator
54 * @brief The number of taps in this tap gesture.
55 * @param[in] numberOfTaps The number of taps to set.
57 inline void SetNumberOfTaps(uint32_t numberOfTaps)
59 mNumberOfTaps = numberOfTaps;
63 * @copydoc Dali::TapGesture::GetNumberOfTaps()
65 inline uint32_t GetNumberOfTaps() const
71 * @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.
72 * @param[in] numberOfTouches The number of touch points in this tap gesture to set.
74 inline void SetNumberOfTouches(uint32_t numberOfTouches)
76 mNumberOfTouches = numberOfTouches;
80 * @copydoc Dali::TapGesture::GetPointCount()
82 inline uint32_t GetNumberOfTouches() const
84 return mNumberOfTouches;
88 * @brief This is the point, in screen coordinates, where the tap occurred.
89 * @param[in] screenPoint The point in screen coordinates to set.
91 inline void SetScreenPoint(const Vector2& screenPoint)
93 mScreenPoint = screenPoint;
97 * @copydoc Dali::TapGesture::GetDeviceId()
99 inline const Vector2& GetScreenPoint() const
105 * @brief This is the point, in local actor coordinates, where the tap occurred.
106 * @param[in] localPoint The point in local actor coordinates to set.
108 inline void SetLocalPoint(const Vector2& localPoint)
110 mLocalPoint = localPoint;
114 * @copydoc Dali::TapGesture::GetGetState()
116 inline const Vector2& GetLocalPoint() const
122 * @brief This is the value of which input was tapped.
123 * @param[in] source This is the value of which input was tapped to set.
125 inline void SetGestureSourceType(const GestureSourceType sourceType)
127 mGestureSourceType = sourceType;
131 * @copydoc Dali::TapGesture::GetSourceType()
133 inline const GestureSourceType& GetSourceType() const
135 return mGestureSourceType;
140 * @brief Virtual destructor
142 * A reference counted object may only be deleted by calling Unreference()
144 ~TapGesture() override = default;
147 Vector2 mScreenPoint;
149 uint32_t mNumberOfTaps{1u};
150 uint32_t mNumberOfTouches{1u};
151 GestureSourceType mGestureSourceType{GestureSourceType::INVALID};
154 } // namespace Internal
156 // Helpers for public-api forwarding methods
158 inline Internal::TapGesture& GetImplementation(Dali::TapGesture& tapGesture)
160 DALI_ASSERT_ALWAYS(tapGesture && "TapGesture handle is empty");
162 BaseObject& object = tapGesture.GetBaseObject();
164 return static_cast<Internal::TapGesture&>(object);
167 inline const Internal::TapGesture& GetImplementation(const Dali::TapGesture& tapGesture)
169 DALI_ASSERT_ALWAYS(tapGesture && "TapGesture handle is empty");
171 const BaseObject& object = tapGesture.GetBaseObject();
173 return static_cast<const Internal::TapGesture&>(object);
178 #endif // DALI_INTERNAL_TAP_GESTURE_H