0e9a6ff25446a6f8cec566ccff7f271a94b37532
[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
27 namespace Dali
28 {
29 /**
30  * @addtogroup dali_core_events
31  * @{
32  */
33
34 /**
35  * @brief Base structure for different gestures that an application can receive.
36  *
37  * A gesture is an event that is produced from a combination of
38  * several touch events in a particular order or within a certain time
39  * frame (e.g pinch).
40  *
41  * To receive a particular gesture, the application has to create and connect to the appropriate
42  * GestureDetector.
43  *
44  * @SINCE_1_0.0
45  * @note An instance of this class cannot be created.
46  * @see GestureDetector
47  *
48  */
49 struct DALI_CORE_API Gesture
50 {
51   /**
52    * @brief Copy constructor.
53    * @SINCE_1_0.0
54    * @param[in] rhs A reference to the copied handle
55    */
56   Gesture( const Gesture& rhs );
57
58   /**
59    * @brief Assignment operator.
60    * @SINCE_1_0.0
61    * @param[in] rhs A reference to the copied handle
62    * @return A reference to this
63    */
64   Gesture& operator=( const Gesture& rhs );
65
66   // Destruction
67
68   /**
69    * @brief Virtual destructor.
70    * @SINCE_1_0.0
71    */
72   virtual ~Gesture();
73
74   /**
75    * @brief Enumeration for type of gesture.
76    * @SINCE_1_0.0
77    */
78   enum Type
79   {
80     Pinch      = 1 << 0, ///< When two touch points move away or towards each other. @SINCE_1_0.0
81     Pan        = 1 << 1, ///< When the user drags their finger(s) in a particular direction. @SINCE_1_0.0
82     Tap        = 1 << 2, ///< When the user taps the screen. @SINCE_1_0.0
83     LongPress  = 1 << 3, ///< When the user continues to touch the same area on the screen for the device configured time. @SINCE_1_0.0
84     Rotation   = 1 << 4, ///< When the user rotates two fingers around a particular ares of the screen. @SINCE_1_9.27
85   };
86
87   /**
88    * @brief Enumeration for state of the gesture.
89    * @SINCE_1_0.0
90    */
91   enum State
92   {
93     Clear,      ///< There is no state associated with this gesture. @SINCE_1_0.0
94     Started,    ///< The touched points on the screen have moved enough to be considered a gesture. @SINCE_1_0.0
95     Continuing, ///< The gesture is continuing. @SINCE_1_0.0
96     Finished,   ///< The user has lifted a finger or touched an additional point on the screen. @SINCE_1_0.0
97     Cancelled,  ///< The gesture has been cancelled. @SINCE_1_0.0
98     Possible    ///< A gesture is possible. @SINCE_1_0.0
99   };
100
101   // Data
102
103   /**
104    * @brief The gesture type.
105    */
106   Type type;
107
108   /**
109    * @brief The gesture state.
110    *
111    * Please see the description in the sub-classes to see the states
112    * used by the actual gesture.
113    */
114   State state;
115
116   /**
117    * @brief The time the gesture took place.
118    */
119   uint32_t time;
120
121 protected: // Creation
122
123   /**
124    * @brief This constructor is only used by derived classes.
125    *
126    * @SINCE_1_0.0
127    * @param[in] gestureType   The type of gesture event.
128    * @param[in] gestureState  The state of the gesture event.
129    */
130   Gesture(Type gestureType, State gestureState);
131
132 };
133
134 /**
135  * @}
136  */
137 } // namespace Dali
138
139 #endif // DALI_GESTURE_H