e634b9a7426f4df900af7681d2cc6df5a7fef23a
[platform/core/uifw/dali-core.git] / dali / public-api / events / gesture.h
1 #ifndef DALI_GESTURE_H
2 #define DALI_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 // EXTERNAL INCLUDES
22 #include <cstdint> // uint32_t
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/object/base-handle.h>
27
28 namespace Dali
29 {
30 /**
31  * @addtogroup dali_core_events
32  * @{
33  */
34
35 namespace Internal DALI_INTERNAL
36 {
37 class Gesture;
38 }
39
40 /**
41  * @brief Base structure for different gestures that an application can receive.
42  *
43  * A gesture is an event that is produced from a combination of
44  * several touch events in a particular order or within a certain time
45  * frame (e.g pinch).
46  *
47  * To receive a particular gesture, the application has to create and connect to the appropriate
48  * GestureDetector.
49  *
50  * @SINCE_1_9.28
51  * @note An instance of this class cannot be created.
52  * @see GestureDetector
53  *
54  */
55 class DALI_CORE_API Gesture : public BaseHandle
56 {
57 public:
58
59   /**
60    * @brief Creates an uninitialized Gesture handle.
61    *
62    * Calling member functions with an uninitialized Actor handle is not allowed.
63    * @SINCE_1_9.28
64    */
65   Gesture();
66
67   /**
68    * @brief Copy constructor.
69    * @SINCE_1_9.28
70    * @param[in] rhs A reference to the copied handle
71    */
72   Gesture( const Gesture& rhs );
73
74   /**
75    * @brief Move constructor.
76    * @SINCE_1_9.28
77    * @param[in] rhs A reference to the handle to move
78    */
79   Gesture( Gesture&& rhs );
80
81   /**
82    * @brief Assignment operator.
83    * @SINCE_1_9.28
84    * @param[in] rhs A reference to the copied handle
85    * @return A reference to this
86    */
87   Gesture& operator=( const Gesture& rhs );
88
89   /**
90    * @brief Move assignment operator.
91    * @SINCE_1_9.28
92    * @param[in] rhs A reference to the handle to move
93    * @return A reference to this
94    */
95   Gesture& operator=( Gesture&& rhs );
96
97   /**
98    * @brief Non virtual destructor.
99    * @SINCE_1_9.28
100    */
101   ~Gesture();
102
103   /**
104    * @brief Enumeration for type of gesture.
105    * @SINCE_1_0.0
106    */
107   enum Type
108   {
109     Pinch      = 1 << 0, ///< When two touch points move away or towards each other. @SINCE_1_0.0
110     Pan        = 1 << 1, ///< When the user drags their finger(s) in a particular direction. @SINCE_1_0.0
111     Tap        = 1 << 2, ///< When the user taps the screen. @SINCE_1_0.0
112     LongPress  = 1 << 3, ///< When the user continues to touch the same area on the screen for the device configured time. @SINCE_1_0.0
113     Rotation   = 1 << 4, ///< When the user rotates two fingers around a particular ares of the screen. @SINCE_1_9.27
114   };
115
116   /**
117    * @brief Enumeration for state of the gesture.
118    * @SINCE_1_0.0
119    */
120   enum State
121   {
122     Clear,      ///< There is no state associated with this gesture. @SINCE_1_0.0
123     Started,    ///< The touched points on the screen have moved enough to be considered a gesture. @SINCE_1_0.0
124     Continuing, ///< The gesture is continuing. @SINCE_1_0.0
125     Finished,   ///< The user has lifted a finger or touched an additional point on the screen. @SINCE_1_0.0
126     Cancelled,  ///< The gesture has been cancelled. @SINCE_1_0.0
127     Possible    ///< A gesture is possible. @SINCE_1_0.0
128   };
129
130   /**
131    * @brief The gesture type.
132    * @SINCE_1_9.28
133    * @return The gesture type
134    */
135   Type GetType() const;
136
137   /**
138    * @brief The gesture state.
139    *
140    * Please see the description in the sub-classes to see the states
141    * used by the actual gesture.
142    * @SINCE_1_9.28
143    * @return The state of the gesture
144    */
145   State GetState() const;
146
147   /**
148    * @brief The time the gesture took place.
149    * @SINCE_1_9.28
150    * @return The time the gesture took place
151    */
152   uint32_t GetTime() const;
153
154 public: // Not intended for application developers
155
156   /// @cond internal
157   /**
158    * @brief Internal constructor.
159    * @SINCE_1_9.28
160    * @param[in] gesture Pointer to internal gesture
161    */
162   explicit DALI_INTERNAL Gesture(Internal::Gesture* gesture);
163   /// @endcond
164 };
165
166 /**
167  * @}
168  */
169 } // namespace Dali
170
171 #endif // DALI_GESTURE_H