[dali_2.3.42] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / events / long-press-gesture / long-press-gesture-impl.h
1 #ifndef DALI_INTERNAL_LONG_PRESS_GESTURE_H
2 #define DALI_INTERNAL_LONG_PRESS_GESTURE_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/internal/event/events/gesture-impl.h>
23 #include <dali/public-api/events/long-press-gesture.h>
24 #include <dali/public-api/math/vector2.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 class LongPressGesture;
31 using LongPressGesturePtr = IntrusivePtr<LongPressGesture>;
32
33 /**
34  * @copydoc Dali::LongPressGesture
35  */
36 class LongPressGesture final : public Gesture
37 {
38 public:
39   /**
40    * Default Constructor
41    * @param[in]  state  STARTED, when we detect a long press.
42    *                    FINISHED, when all touches are finished.
43    */
44   LongPressGesture(GestureState state)
45   : Gesture(GestureType::LONG_PRESS, state)
46   {
47   }
48
49   LongPressGesture(const LongPressGesture&) = delete;            ///< Deleted copy constructor
50   LongPressGesture(LongPressGesture&&)      = delete;            ///< Deleted move constructor
51   LongPressGesture& operator=(const LongPressGesture&) = delete; ///< Deleted copy assignment operator
52   LongPressGesture& operator=(LongPressGesture&&) = delete;      ///< Deleted move assignment operator
53
54   /**
55    * @brief Set the number of touch points.
56    * @param[in] numberOfTouches The number of touch points to set.
57    */
58   inline void SetNumberOfTouches(uint32_t numberOfTouches)
59   {
60     mNumberOfTouches = numberOfTouches;
61   }
62
63   /**
64    * @copydoc Dali::LongPressGesture::GetNumberOfTouches()
65    */
66   inline uint32_t GetNumberOfTouches() const
67   {
68     return mNumberOfTouches;
69   }
70
71   /**
72    * @brief Set This is the point, in screen coordinates.
73    * @param[in] screenPoint The point in screen coordinates to set.
74    */
75   inline void SetScreenPoint(const Vector2& screenPoint)
76   {
77     mScreenPoint = screenPoint;
78   }
79
80   /**
81    * @copydoc Dali::LongPressGesture::GetScreenPoint()
82    */
83   inline const Vector2& GetScreenPoint() const
84   {
85     return mScreenPoint;
86   }
87
88   /**
89    * @brief Set This is the point, in local actor coordinates.
90    * @param[in] localPoint The point in local actor coordinates to set.
91    */
92   inline void SetLocalPoint(const Vector2& localPoint)
93   {
94     mLocalPoint = localPoint;
95   }
96
97   /**
98    * @copydoc Dali::LongPressGesture::GetLocalPoint()
99    */
100   inline const Vector2& GetLocalPoint() const
101   {
102     return mLocalPoint;
103   }
104
105 private:
106   /**
107    * @brief Virtual destructor
108    *
109    * A reference counted object may only be deleted by calling Unreference()
110    */
111   ~LongPressGesture() override = default;
112
113 private:
114   Vector2  mScreenPoint;
115   Vector2  mLocalPoint;
116   uint32_t mNumberOfTouches{1u};
117 };
118
119 } // namespace Internal
120
121 // Helpers for public-api forwarding methods
122
123 inline Internal::LongPressGesture& GetImplementation(Dali::LongPressGesture& longPressGesture)
124 {
125   DALI_ASSERT_ALWAYS(longPressGesture && "longPressGesture handle is empty");
126
127   BaseObject& object = longPressGesture.GetBaseObject();
128
129   return static_cast<Internal::LongPressGesture&>(object);
130 }
131
132 inline const Internal::LongPressGesture& GetImplementation(const Dali::LongPressGesture& longPressGesture)
133 {
134   DALI_ASSERT_ALWAYS(longPressGesture && "longPressGesture handle is empty");
135
136   const BaseObject& object = longPressGesture.GetBaseObject();
137
138   return static_cast<const Internal::LongPressGesture&>(object);
139 }
140
141 } // namespace Dali
142
143 #endif // DALI_INTERNAL_LONG_PRESS_GESTURE_H