8e521db3426c8e704a951486f0fbcb5904a05143
[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) 2020 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/public-api/events/gesture.h>
23 #include <dali/integration-api/events/event.h>
24 #include <dali/public-api/object/base-object.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class Gesture;
33 typedef IntrusivePtr<Gesture> GesturePtr;
34
35 /**
36  * This is the abstract base structure for any gestures that the adaptor detects and wishes to send
37  * to the Core.
38  */
39 class Gesture : public BaseObject
40 {
41 public:
42
43   /**
44    * @brief Get the gesture type.
45    *
46    * @return The gesture type.
47    */
48   inline GestureType::Value GetType() const
49   {
50     return mGestureType;
51   }
52
53   /**
54    * @brief Set the state of the gesture.
55    * @param[in] state The state of the gesture to set
56    */
57   inline void SetState( GestureState state )
58   {
59     mState = state;
60   }
61
62    /**
63    * @brief Get the state of the gesture.
64    *
65    * @return The state of the gesture.
66    */
67   inline GestureState GetState() const
68   {
69     return mState;
70   }
71
72   /**
73    * @brief Set The time the gesture took place.
74    * @param[in] time The time the gesture took place. to set
75    */
76   inline void SetTime( uint32_t time )
77   {
78     mTime = time;
79   }
80
81   /**
82    * @brief Get the time the gesture took place.
83    *
84    * @return The time the gesture took place.
85    */
86   inline uint32_t GetTime() const
87   {
88     return mTime;
89   }
90
91   Gesture(const Gesture&) = delete; ///< Deleted copy constructor
92   Gesture(Gesture&&) = delete; ///< Deleted move constructor
93   Gesture& operator=(const Gesture&) = delete; ///< Deleted copy assignment operator
94   Gesture& operator=(Gesture&&) = delete; ///< Deleted move assignment operator
95
96 protected:
97
98   /**
99    * This constructor is only used by derived classes.
100    * @param[in] gestureType   The type of gesture event.
101    * @param[in] gestureState  The state of the gesture event.
102    */
103   Gesture(GestureType::Value gestureType, GestureState gestureState)
104   : mGestureType( gestureType ),
105     mState( gestureState )
106   {
107   }
108
109   /**
110    * @brief Virtual destructor.
111    *
112    * A reference counted object may only be deleted by calling Unreference()
113    */
114   virtual ~Gesture() = default;
115
116 private:
117   GestureType::Value mGestureType;
118   GestureState mState;
119   uint32_t mTime{0u};
120 };
121
122 } // namespace Internal
123
124 /**
125  * Helper methods for public API.
126  */
127 inline Internal::Gesture& GetImplementation(Dali::Gesture& gesture)
128 {
129   DALI_ASSERT_ALWAYS( gesture && "gesture handle is empty" );
130
131   BaseObject& handle = gesture.GetBaseObject();
132
133   return static_cast<Internal::Gesture&>(handle);
134 }
135
136 inline const Internal::Gesture& GetImplementation(const Dali::Gesture& gesture)
137 {
138   DALI_ASSERT_ALWAYS( gesture && "gesture handle is empty" );
139
140   const BaseObject& handle = gesture.GetBaseObject();
141
142   return static_cast<const Internal::Gesture&>(handle);
143 }
144
145 } // namespace Dali
146
147 #endif // DALI_INTERNAL_GESTURE_H