Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[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) 2018 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   };
85
86   /**
87    * @brief Enumeration for state of the gesture.
88    * @SINCE_1_0.0
89    */
90   enum State
91   {
92     Clear,      ///< There is no state associated with this gesture. @SINCE_1_0.0
93     Started,    ///< The touched points on the screen have moved enough to be considered a gesture. @SINCE_1_0.0
94     Continuing, ///< The gesture is continuing. @SINCE_1_0.0
95     Finished,   ///< The user has lifted a finger or touched an additional point on the screen. @SINCE_1_0.0
96     Cancelled,  ///< The gesture has been cancelled. @SINCE_1_0.0
97     Possible    ///< A gesture is possible. @SINCE_1_0.0
98   };
99
100   // Data
101
102   /**
103    * @brief The gesture type.
104    */
105   Type type;
106
107   /**
108    * @brief The gesture state.
109    *
110    * Please see the description in the sub-classes to see the states
111    * used by the actual gesture.
112    */
113   State state;
114
115   /**
116    * @brief The time the gesture took place.
117    */
118   uint32_t time;
119
120 protected: // Creation
121
122   /**
123    * @brief This constructor is only used by derived classes.
124    *
125    * @SINCE_1_0.0
126    * @param[in] gestureType   The type of gesture event.
127    * @param[in] gestureState  The state of the gesture event.
128    */
129   Gesture(Type gestureType, State gestureState);
130
131 };
132
133 /**
134  * @}
135  */
136 } // namespace Dali
137
138 #endif // __DALI_GESTURE_H__