[NUI] Setting since_tizen 3/4 on Tizen.NUI API
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Gesture.cs
1 /*
2  * Copyright(c) 2017 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
18 namespace Tizen.NUI
19 {
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 : global::System.IDisposable
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30         /// <summary>
31         /// swigCMemOwn.
32         /// </summary>
33         /// <since_tizen> 3 </since_tizen>
34         protected bool swigCMemOwn;
35
36         internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn)
37         {
38             swigCMemOwn = cMemoryOwn;
39             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
40         }
41
42         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Gesture obj)
43         {
44             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
45         }
46
47         //A Flag to check who called Dispose(). (By User or DisposeQueue)
48         private bool isDisposeQueued = false;
49         /// <summary>
50         /// A Flat to check if it is already disposed.
51         /// </summary>
52         /// <since_tizen> 3 </since_tizen>
53         protected bool disposed = false;
54
55         /// <summary>
56         /// Dispose.
57         /// </summary>
58         /// <since_tizen> 3 </since_tizen>
59         ~Gesture()
60         {
61             if(!isDisposeQueued)
62             {
63                 isDisposeQueued = true;
64                 DisposeQueue.Instance.Add(this);
65             }
66         }
67
68         /// <summary>
69         /// Dispose.
70         /// </summary>
71         /// <since_tizen> 3 </since_tizen>
72         public void Dispose()
73         {
74             //Throw excpetion if Dispose() is called in separate thread.
75             if (!Window.IsInstalled())
76             {
77                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
78             }
79
80             if (isDisposeQueued)
81             {
82                 Dispose(DisposeTypes.Implicit);
83             }
84             else
85             {
86                 Dispose(DisposeTypes.Explicit);
87                 System.GC.SuppressFinalize(this);
88             }
89         }
90
91         /// <summary>
92         /// Dispose.
93         /// </summary>
94         /// <since_tizen> 3 </since_tizen>
95         protected virtual void Dispose(DisposeTypes type)
96         {
97             if (disposed)
98             {
99                 return;
100             }
101
102             if(type == DisposeTypes.Explicit)
103             {
104                 //Called by User
105                 //Release your own managed resources here.
106                 //You should release all of your own disposable objects here.
107             }
108
109             //Release your own unmanaged resources here.
110             //You should not access any managed member here except static instance.
111             //because the execution order of Finalizes is non-deterministic.
112
113             if (swigCPtr.Handle != global::System.IntPtr.Zero)
114             {
115                 if (swigCMemOwn)
116                 {
117                     swigCMemOwn = false;
118                     NDalicPINVOKE.delete_Gesture(swigCPtr);
119                 }
120                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
121             }
122             disposed = true;
123         }
124
125
126         /// <summary>
127         /// The gesture type.
128         /// </summary>
129         /// <since_tizen> 3 </since_tizen>
130         public Gesture.GestureType Type
131         {
132             get
133             {
134                 return type;
135             }
136         }
137
138         /// <summary>
139         /// The gesture state.
140         /// </summary>
141         /// <since_tizen> 3 </since_tizen>
142         public Gesture.StateType State
143         {
144             get
145             {
146                 return state;
147             }
148         }
149
150         /// <summary>
151         /// The time the gesture took place.
152         /// </summary>
153         /// <since_tizen> 3 </since_tizen>
154         public uint Time
155         {
156             get
157             {
158                 return time;
159             }
160         }
161
162         /// <summary>
163         /// The Copy constructor.
164         /// </summary>
165         /// <param name="rhs">A reference to the copied handle</param>
166         /// <since_tizen> 3 </since_tizen>
167         public Gesture(Gesture rhs) : this(NDalicPINVOKE.new_Gesture(Gesture.getCPtr(rhs)), true)
168         {
169             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170         }
171
172         private Gesture.GestureType type
173         {
174             set
175             {
176                 NDalicPINVOKE.Gesture_type_set(swigCPtr, (int)value);
177                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178             }
179             get
180             {
181                 Gesture.GestureType ret = (Gesture.GestureType)NDalicPINVOKE.Gesture_type_get(swigCPtr);
182                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183                 return ret;
184             }
185         }
186
187         private Gesture.StateType state
188         {
189             set
190             {
191                 NDalicPINVOKE.Gesture_state_set(swigCPtr, (int)value);
192                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193             }
194             get
195             {
196                 Gesture.StateType ret = (Gesture.StateType)NDalicPINVOKE.Gesture_state_get(swigCPtr);
197                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198                 return ret;
199             }
200         }
201
202         private uint time
203         {
204             set
205             {
206                 NDalicPINVOKE.Gesture_time_set(swigCPtr, value);
207                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208             }
209             get
210             {
211                 uint ret = NDalicPINVOKE.Gesture_time_get(swigCPtr);
212                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213                 return ret;
214             }
215         }
216
217         /// <summary>
218         /// Enumeration for type of gesture.
219         /// </summary>
220         /// <since_tizen> 3 </since_tizen>
221         public enum GestureType
222         {
223             /// <summary>
224             /// When two touch points move away or towards each other.
225             /// </summary>
226             /// <since_tizen> 3 </since_tizen>
227             Pinch = 1 << 0,
228             /// <summary>
229             /// When the user drags their finger(s) in a particular direction.
230             /// </summary>
231             /// <since_tizen> 3 </since_tizen>
232             Pan = 1 << 1,
233             /// <summary>
234             /// When the user taps the screen.
235             /// </summary>
236             /// <since_tizen> 3 </since_tizen>
237             Tap = 1 << 2,
238             /// <summary>
239             ///  When the user continues to touch the same area on the screen for the device configured time.
240             /// </summary>
241             /// <since_tizen> 3 </since_tizen>
242             LongPress = 1 << 3
243         }
244
245         /// <summary>
246         /// Enumeration for state of the gesture.
247         /// </summary>
248         /// <since_tizen> 3 </since_tizen>
249         public enum StateType
250         {
251             /// <summary>
252             /// There is no state associated with this gesture.
253             /// </summary>
254             /// <since_tizen> 3 </since_tizen>
255             Clear,
256             /// <summary>
257             /// The touched points on the screen have moved enough to be considered a gesture.
258             /// </summary>
259             /// <since_tizen> 3 </since_tizen>
260             Started,
261             /// <summary>
262             /// The gesture is continuing.
263             /// </summary>
264             /// <since_tizen> 3 </since_tizen>
265             Continuing,
266             /// <summary>
267             /// The user has lifted a finger or touched an additional point on the screen.
268             /// </summary>
269             /// <since_tizen> 3 </since_tizen>
270             Finished,
271             /// <summary>
272             /// The gesture has been cancelled.
273             /// </summary>
274             /// <since_tizen> 3 </since_tizen>
275             Cancelled,
276             /// <summary>
277             ///  A gesture is possible.
278             /// </summary>
279             /// <since_tizen> 3 </since_tizen>
280             Possible
281         }
282
283     }
284
285 }