Revert "[Tizen] Not execute the remove callback"
[platform/core/uifw/dali-core.git] / dali / internal / event / events / gesture-impl.h
1 #ifndef DALI_INTERNAL_GESTURE_H
2 #define DALI_INTERNAL_GESTURE_H
3
4 /*
5  * Copyright (c) 2022 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/integration-api/events/event.h>
23 #include <dali/public-api/events/gesture.h>
24 #include <dali/public-api/object/base-object.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 class Gesture;
31 using GesturePtr = IntrusivePtr<Gesture>;
32
33 /**
34  * This is the abstract base structure for any gestures that the adaptor detects and wishes to send
35  * to the Core.
36  */
37 class Gesture : public BaseObject
38 {
39 public:
40   /**
41    * @brief Get the gesture type.
42    *
43    * @return The gesture type.
44    */
45   inline GestureType::Value GetType() const
46   {
47     return mGestureType;
48   }
49
50   /**
51    * @brief Set the state of the gesture.
52    * @param[in] state The state of the gesture to set
53    */
54   inline void SetState(GestureState state)
55   {
56     mState = state;
57   }
58
59   /**
60    * @brief Get the state of the gesture.
61    *
62    * @return The state of the gesture.
63    */
64   inline GestureState GetState() const
65   {
66     return mState;
67   }
68
69   /**
70    * @brief Set The time the gesture took place.
71    * @param[in] time The time the gesture took place. to set
72    */
73   inline void SetTime(uint32_t time)
74   {
75     mTime = time;
76   }
77
78   /**
79    * @brief Get the time the gesture took place.
80    *
81    * @return The time the gesture took place.
82    */
83   inline uint32_t GetTime() const
84   {
85     return mTime;
86   }
87
88   /**
89    * @brief Sets the value of which source the gesture was started with. (ex : mouse)
90    * @param[in] source The gesture source type.
91    */
92   inline void SetSourceType(GestureSourceType source)
93   {
94     mSourceType = source;
95   }
96
97   /**
98    * @brief Gets the value of which source the gesture was started with.
99    * @return The gesture source type.
100    */
101   inline GestureSourceType GetSourceType() const
102   {
103     return mSourceType;
104   }
105
106   /**
107    * @brief Sets the value of source data.
108    * @param[in] data The gesture source data.
109    */
110   inline void SetSourceData(GestureSourceData data)
111   {
112     mSourceData = data;
113   }
114
115   /**
116    * @brief Gets the data of source type.
117    * @return The gesture source data.
118    */
119   inline GestureSourceData GetSourceData() const
120   {
121     return mSourceData;
122   }
123
124   Gesture(const Gesture&) = delete;            ///< Deleted copy constructor
125   Gesture(Gesture&&)      = delete;            ///< Deleted move constructor
126   Gesture& operator=(const Gesture&) = delete; ///< Deleted copy assignment operator
127   Gesture& operator=(Gesture&&) = delete;      ///< Deleted move assignment operator
128
129 protected:
130   /**
131    * This constructor is only used by derived classes.
132    * @param[in] gestureType   The type of gesture event.
133    * @param[in] gestureState  The state of the gesture event.
134    */
135   Gesture(GestureType::Value gestureType, GestureState gestureState)
136   : mGestureType(gestureType),
137     mState(gestureState),
138     mSourceType(GestureSourceType::INVALID),
139     mSourceData(GestureSourceData::INVALID)
140   {
141   }
142
143   /**
144    * @brief Virtual destructor.
145    *
146    * A reference counted object may only be deleted by calling Unreference()
147    */
148   ~Gesture() override = default;
149
150 private:
151   GestureType::Value mGestureType;
152   GestureState       mState;
153   uint32_t           mTime{0u};
154   GestureSourceType  mSourceType;
155   GestureSourceData  mSourceData;
156 };
157
158 } // namespace Internal
159
160 /**
161  * Helper methods for public API.
162  */
163 inline Internal::Gesture& GetImplementation(Dali::Gesture& gesture)
164 {
165   DALI_ASSERT_ALWAYS(gesture && "gesture handle is empty");
166
167   BaseObject& handle = gesture.GetBaseObject();
168
169   return static_cast<Internal::Gesture&>(handle);
170 }
171
172 inline const Internal::Gesture& GetImplementation(const Dali::Gesture& gesture)
173 {
174   DALI_ASSERT_ALWAYS(gesture && "gesture handle is empty");
175
176   const BaseObject& handle = gesture.GetBaseObject();
177
178   return static_cast<const Internal::Gesture&>(handle);
179 }
180
181 } // namespace Dali
182
183 #endif // DALI_INTERNAL_GESTURE_H