[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) 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/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   Gesture(const Gesture&) = delete;            ///< Deleted copy constructor
89   Gesture(Gesture&&)      = delete;            ///< Deleted move constructor
90   Gesture& operator=(const Gesture&) = delete; ///< Deleted copy assignment operator
91   Gesture& operator=(Gesture&&) = delete;      ///< Deleted move assignment operator
92
93 protected:
94   /**
95    * This constructor is only used by derived classes.
96    * @param[in] gestureType   The type of gesture event.
97    * @param[in] gestureState  The state of the gesture event.
98    */
99   Gesture(GestureType::Value gestureType, GestureState gestureState)
100   : mGestureType(gestureType),
101     mState(gestureState)
102   {
103   }
104
105   /**
106    * @brief Virtual destructor.
107    *
108    * A reference counted object may only be deleted by calling Unreference()
109    */
110   ~Gesture() override = default;
111
112 private:
113   GestureType::Value mGestureType;
114   GestureState       mState;
115   uint32_t           mTime{0u};
116 };
117
118 } // namespace Internal
119
120 /**
121  * Helper methods for public API.
122  */
123 inline Internal::Gesture& GetImplementation(Dali::Gesture& gesture)
124 {
125   DALI_ASSERT_ALWAYS(gesture && "gesture handle is empty");
126
127   BaseObject& handle = gesture.GetBaseObject();
128
129   return static_cast<Internal::Gesture&>(handle);
130 }
131
132 inline const Internal::Gesture& GetImplementation(const Dali::Gesture& gesture)
133 {
134   DALI_ASSERT_ALWAYS(gesture && "gesture handle is empty");
135
136   const BaseObject& handle = gesture.GetBaseObject();
137
138   return static_cast<const Internal::Gesture&>(handle);
139 }
140
141 } // namespace Dali
142
143 #endif // DALI_INTERNAL_GESTURE_H