1 #ifndef DALI_INTERNAL_PINCH_GESTURE_H
2 #define DALI_INTERNAL_PINCH_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/pinch-gesture.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/object/base-object.h>
32 using PinchGesturePtr = IntrusivePtr<PinchGesture>;
35 * @copydoc Dali::PinchGesture
37 class PinchGesture final : public Gesture
41 * @brief Default constructor
43 PinchGesture(GestureState state)
44 : Gesture(GestureType::PINCH, state)
48 PinchGesture(const PinchGesture&) = delete; ///< Deleted copy constructor
49 PinchGesture(PinchGesture&&) = delete; ///< Deleted move constructor
50 PinchGesture& operator=(const PinchGesture&) = delete; ///< Deleted copy assignment operator
51 PinchGesture& operator=(PinchGesture&&) = delete; ///< Deleted move assignment operator
54 * @brief The scale factor from the start of the pinch gesture till the latest pinch gesture.
55 * @param[in] scale The scale to set.
57 inline void SetScale(float scale)
63 * @copydoc Dali::PinchGesture::GetScale()
65 inline float GetScale() const
71 * @brief The speed at which the user is moving their fingers.
72 * @param[in] speed The speed to set.
74 inline void SetSpeed(float speed)
80 * @copydoc Dali::PinchGesture::GetSpeed()
82 inline float GetSpeed() const
88 * @brief The center point of the two points that caused the pinch gesture in screen coordinates.
89 * @param[in] screenCenterPoint The point in screen coordinates to set.
91 inline void SetScreenCenterPoint(const Vector2& screenCenterPoint)
93 mScreenCenterPoint = screenCenterPoint;
97 * @copydoc Dali::PinchGesture::GetScreenCenterPoint()
99 inline const Vector2& GetScreenCenterPoint() const
101 return mScreenCenterPoint;
105 * @brief The center point of the two points that caused the pinch gesture in local actor coordinates.
106 * @param[in] localCenterPoint The point in local actor coordinates to set.
108 inline void SetLocalCenterPoint(const Vector2& localCenterPoint)
110 mLocalCenterPoint = localCenterPoint;
114 * @copydoc Dali::PinchGesture::GetLocalCenterPoint()
116 inline const Vector2& GetLocalCenterPoint() const
118 return mLocalCenterPoint;
123 * @brief Virtual destructor
125 * A reference counted object may only be deleted by calling Unreference()
127 ~PinchGesture() override = default;
130 Vector2 mScreenCenterPoint;
131 Vector2 mLocalCenterPoint;
136 } // namespace Internal
138 // Helpers for public-api forwarding methods
140 inline Internal::PinchGesture& GetImplementation(Dali::PinchGesture& pinchGesture)
142 DALI_ASSERT_ALWAYS(pinchGesture && "pinchGesture handle is empty");
144 BaseObject& object = pinchGesture.GetBaseObject();
146 return static_cast<Internal::PinchGesture&>(object);
149 inline const Internal::PinchGesture& GetImplementation(const Dali::PinchGesture& pinchGesture)
151 DALI_ASSERT_ALWAYS(pinchGesture && "pinchGesture handle is empty");
153 const BaseObject& object = pinchGesture.GetBaseObject();
155 return static_cast<const Internal::PinchGesture&>(object);
160 #endif // DALI_INTERNAL_PINCH_GESTURE_H