Merge "[Download] Fix XML documentation warnings"
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Gesture.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI
18 {
19
20     /// <summary>
21     /// Base structure for different gestures that an application can receive.<br>
22     /// A Gesture is an event that is produced from a combination of several touch events
23     /// in a particular order or within a certain time frame (for example, pinch).<br>
24     /// </summary>
25     public class Gesture : global::System.IDisposable
26     {
27         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28         protected bool swigCMemOwn;
29
30         internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn)
31         {
32             swigCMemOwn = cMemoryOwn;
33             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34         }
35
36         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Gesture obj)
37         {
38             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39         }
40
41         //A Flag to check who called Dispose(). (By User or DisposeQueue)
42         private bool isDisposeQueued = false;
43         //A Flat to check if it is already disposed.
44         protected bool disposed = false;
45
46         ~Gesture()
47         {
48             if(!isDisposeQueued)
49             {
50                 isDisposeQueued = true;
51                 DisposeQueue.Instance.Add(this);
52             }
53         }
54
55         /// <summary>
56         /// Dispose.
57         /// </summary>
58         /// <since_tizen> 3 </since_tizen>
59         public void Dispose()
60         {
61             //Throw excpetion if Dispose() is called in separate thread.
62             if (!Window.IsInstalled())
63             {
64                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
65             }
66
67             if (isDisposeQueued)
68             {
69                 Dispose(DisposeTypes.Implicit);
70             }
71             else
72             {
73                 Dispose(DisposeTypes.Explicit);
74                 System.GC.SuppressFinalize(this);
75             }
76         }
77
78         protected virtual void Dispose(DisposeTypes type)
79         {
80             if (disposed)
81             {
82                 return;
83             }
84
85             if(type == DisposeTypes.Explicit)
86             {
87                 //Called by User
88                 //Release your own managed resources here.
89                 //You should release all of your own disposable objects here.
90             }
91
92             //Release your own unmanaged resources here.
93             //You should not access any managed member here except static instance.
94             //because the execution order of Finalizes is non-deterministic.
95
96             if (swigCPtr.Handle != global::System.IntPtr.Zero)
97             {
98                 if (swigCMemOwn)
99                 {
100                     swigCMemOwn = false;
101                     NDalicPINVOKE.delete_Gesture(swigCPtr);
102                 }
103                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
104             }
105             disposed = true;
106         }
107
108
109         /// <summary>
110         /// The gesture type.
111         /// </summary>
112         /// <since_tizen> 3 </since_tizen>
113         public Gesture.GestureType Type
114         {
115             get
116             {
117                 return type;
118             }
119         }
120
121         /// <summary>
122         /// The gesture state.
123         /// </summary>
124         /// <since_tizen> 3 </since_tizen>
125         public Gesture.StateType State
126         {
127             get
128             {
129                 return state;
130             }
131         }
132
133         /// <summary>
134         /// The time the gesture took place.
135         /// </summary>
136         /// <since_tizen> 3 </since_tizen>
137         public uint Time
138         {
139             get
140             {
141                 return time;
142             }
143         }
144
145         /// <summary>
146         /// The Copy constructor.
147         /// </summary>
148         /// <param name="rhs">A reference to the copied handle</param>
149         /// <since_tizen> 3 </since_tizen>
150         public Gesture(Gesture rhs) : this(NDalicPINVOKE.new_Gesture(Gesture.getCPtr(rhs)), true)
151         {
152             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153         }
154
155         private Gesture.GestureType type
156         {
157             set
158             {
159                 NDalicPINVOKE.Gesture_type_set(swigCPtr, (int)value);
160                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161             }
162             get
163             {
164                 Gesture.GestureType ret = (Gesture.GestureType)NDalicPINVOKE.Gesture_type_get(swigCPtr);
165                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166                 return ret;
167             }
168         }
169
170         private Gesture.StateType state
171         {
172             set
173             {
174                 NDalicPINVOKE.Gesture_state_set(swigCPtr, (int)value);
175                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176             }
177             get
178             {
179                 Gesture.StateType ret = (Gesture.StateType)NDalicPINVOKE.Gesture_state_get(swigCPtr);
180                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
181                 return ret;
182             }
183         }
184
185         private uint time
186         {
187             set
188             {
189                 NDalicPINVOKE.Gesture_time_set(swigCPtr, value);
190                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191             }
192             get
193             {
194                 uint ret = NDalicPINVOKE.Gesture_time_get(swigCPtr);
195                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196                 return ret;
197             }
198         }
199
200         /// <summary>
201         /// Enumeration for type of gesture.
202         /// </summary>
203         /// <since_tizen> 3 </since_tizen>
204         public enum GestureType
205         {
206             Pinch = 1 << 0,
207             Pan = 1 << 1,
208             Tap = 1 << 2,
209             LongPress = 1 << 3
210         }
211
212         /// <summary>
213         /// Enumeration for state of the gesture.
214         /// </summary>
215         /// <since_tizen> 3 </since_tizen>
216         public enum StateType
217         {
218             Clear,
219             Started,
220             Continuing,
221             Finished,
222             Cancelled,
223             Possible
224         }
225
226     }
227
228 }