[NUI] Add Touch source type for gesture
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Events / Gesture.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// Base structure for different gestures that an application can receive.<br />
23     /// A Gesture is an event that is produced from a combination of several touch events
24     /// in a particular order or within a certain time frame (for example, pinch).<br />
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public class Gesture : BaseHandle
28     {
29
30         /// <summary>
31         /// The Copy constructor.
32         /// </summary>
33         /// <param name="rhs">A reference to the copied handle</param>
34         /// <since_tizen> 3 </since_tizen>
35         public Gesture(Gesture rhs) : this(Interop.Gesture.NewGesture(Gesture.getCPtr(rhs)), true)
36         {
37             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
38         }
39
40         internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
41         {
42         }
43
44         /// <summary>
45         /// Enumeration for type of gesture.
46         /// </summary>
47         /// <since_tizen> 3 </since_tizen>
48         public enum GestureType
49         {
50             /// <summary>
51             /// When two touch points move away or towards each other.
52             /// </summary>
53             /// <since_tizen> 3 </since_tizen>
54             Pinch = 1 << 0,
55             /// <summary>
56             /// When the user drags their finger(s) in a particular direction.
57             /// </summary>
58             /// <since_tizen> 3 </since_tizen>
59             Pan = 1 << 1,
60             /// <summary>
61             /// When the user taps the screen.
62             /// </summary>
63             /// <since_tizen> 3 </since_tizen>
64             Tap = 1 << 2,
65             /// <summary>
66             ///  When the user continues to touch the same area on the screen for the device configured time.
67             /// </summary>
68             /// <since_tizen> 3 </since_tizen>
69             LongPress = 1 << 3
70         }
71
72         /// <summary>
73         /// Enumeration for state of the gesture.
74         /// </summary>
75         /// <since_tizen> 3 </since_tizen>
76         public enum StateType
77         {
78             /// <summary>
79             /// There is no state associated with this gesture.
80             /// </summary>
81             /// <since_tizen> 3 </since_tizen>
82             Clear,
83             /// <summary>
84             /// The touched points on the screen have moved enough to be considered a gesture.
85             /// </summary>
86             /// <since_tizen> 3 </since_tizen>
87             Started,
88             /// <summary>
89             /// The gesture is continuing.
90             /// </summary>
91             /// <since_tizen> 3 </since_tizen>
92             Continuing,
93             /// <summary>
94             /// The user has lifted a finger or touched an additional point on the screen.
95             /// </summary>
96             /// <since_tizen> 3 </since_tizen>
97             Finished,
98             /// <summary>
99             /// The gesture has been cancelled.
100             /// </summary>
101             /// <since_tizen> 3 </since_tizen>
102             Cancelled,
103             /// <summary>
104             ///  A gesture is possible.
105             /// </summary>
106             /// <since_tizen> 3 </since_tizen>
107             Possible
108         }
109
110         /// <summary>
111         /// This is the value of which source the gesture was started with. (ex : mouse)
112         /// </summary>
113         [EditorBrowsable(EditorBrowsableState.Never)]
114         public enum SourceType
115         {
116             /// <summary>
117             /// invalid data.
118             /// </summary>
119             [EditorBrowsable(EditorBrowsableState.Never)]
120             Invalid,
121             /// <summary>
122             /// Mouse.
123             /// </summary>
124             [EditorBrowsable(EditorBrowsableState.Never)]
125             Mouse,
126             /// <summary>
127             /// Touch.
128             /// </summary>
129             [EditorBrowsable(EditorBrowsableState.Never)]
130             Touch,
131         }
132
133         /// <summary>
134         /// This is the data of source type
135         /// </summary>
136         [EditorBrowsable(EditorBrowsableState.Never)]
137         public enum SourceDataType
138         {
139             /// <summary>
140             /// invalid data.
141             /// </summary>
142             [EditorBrowsable(EditorBrowsableState.Never)]
143             Invalid = -1,
144             /// <summary>
145             /// Primary(Left) mouse button.
146             /// </summary>
147             [EditorBrowsable(EditorBrowsableState.Never)]
148             MousePrimary = 1,
149             /// <summary>
150             /// Secondary(Right) mouse button.
151             /// </summary>
152             [EditorBrowsable(EditorBrowsableState.Never)]
153             MouseSecondary = 3,
154             /// <summary>
155             /// Tertiary(Third) mouse button.
156             /// </summary>
157             [EditorBrowsable(EditorBrowsableState.Never)]
158             MouseTertiary = 2,
159         }
160
161         /// <summary>
162         /// The gesture type.
163         /// </summary>
164         /// <since_tizen> 3 </since_tizen>
165         public Gesture.GestureType Type
166         {
167             get
168             {
169                 return type;
170             }
171         }
172
173         /// <summary>
174         /// The gesture state.
175         /// </summary>
176         /// <since_tizen> 3 </since_tizen>
177         public Gesture.StateType State
178         {
179             get
180             {
181                 return state;
182             }
183         }
184
185         /// <summary>
186         /// The time the gesture took place.
187         /// </summary>
188         /// <since_tizen> 3 </since_tizen>
189         public uint Time
190         {
191             get
192             {
193                 return time;
194             }
195         }
196
197         /// <summary>
198         /// This is the property of which source type the gesture (read-only).
199         /// If you started the gesture with the mouse, it will tell you what type of mouse it is.
200         /// </summary>
201         [EditorBrowsable(EditorBrowsableState.Never)]
202         public Gesture.SourceType Source
203         {
204             get
205             {
206                 return sourceType;
207             }
208         }
209
210         /// <summary>
211         /// This is a property of the source type data (read-only).
212         /// If you started the gesture with the mouse, it will tell you which mouse button you started the gesture with.
213         /// </summary>
214         [EditorBrowsable(EditorBrowsableState.Never)]
215         public Gesture.SourceDataType SourceData
216         {
217             get
218             {
219                 return sourceDataType;
220             }
221         }
222
223         private Gesture.GestureType type
224         {
225             set
226             {
227                 Interop.Gesture.TypeSet(SwigCPtr, (int)value);
228                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229             }
230             get
231             {
232                 Gesture.GestureType ret = (Gesture.GestureType)Interop.Gesture.TypeGet(SwigCPtr);
233                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234                 return ret;
235             }
236         }
237
238         private Gesture.StateType state
239         {
240             set
241             {
242                 Interop.Gesture.StateSet(SwigCPtr, (int)value);
243                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244             }
245             get
246             {
247                 Gesture.StateType ret = (Gesture.StateType)Interop.Gesture.StateGet(SwigCPtr);
248                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249                 return ret;
250             }
251         }
252
253         private uint time
254         {
255             set
256             {
257                 Interop.Gesture.TimeSet(SwigCPtr, value);
258                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
259             }
260             get
261             {
262                 uint ret = Interop.Gesture.TimeGet(SwigCPtr);
263                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264                 return ret;
265             }
266         }
267
268         private Gesture.SourceType sourceType
269         {
270             get
271             {
272                 Gesture.SourceType ret = (Gesture.SourceType)Interop.Gesture.SourceTypeGet(SwigCPtr);
273                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274                 return ret;
275             }
276         }
277
278         private Gesture.SourceDataType sourceDataType
279         {
280             get
281             {
282                 Gesture.SourceDataType ret = (Gesture.SourceDataType)Interop.Gesture.SourceDataGet(SwigCPtr);
283                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284                 return ret;
285             }
286         }
287
288         internal static Gesture GetGestureFromPtr(global::System.IntPtr cPtr)
289         {
290             Gesture ret = new Gesture(cPtr, false);
291             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292             return ret;
293         }
294
295         /// This will not be public opened.
296         [EditorBrowsable(EditorBrowsableState.Never)]
297         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
298         {
299             Interop.Gesture.DeleteGesture(swigCPtr);
300         }
301     }
302
303 }