6882b9fc6fafee8e547ce0c11a6da5df71424197
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Gesture.cs
1 /*
2  * Copyright(c) 2019 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     /// <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     /// <since_tizen> 3 </since_tizen>
26     public class Gesture : Disposable
27     {
28         /// <summary>
29         /// swigCMemOwn.
30         /// </summary>
31         /// <since_tizen> 3 </since_tizen>
32         protected bool swigCMemOwn;
33
34         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
35
36         /// <summary>
37         /// The Copy constructor.
38         /// </summary>
39         /// <param name="rhs">A reference to the copied handle</param>
40         /// <since_tizen> 3 </since_tizen>
41         public Gesture(Gesture rhs) : this(Interop.Gesture.new_Gesture(Gesture.getCPtr(rhs)), true)
42         {
43             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
44         }
45
46         internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn)
47         {
48             swigCMemOwn = cMemoryOwn;
49             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
50         }
51
52         /// <summary>
53         /// Enumeration for type of gesture.
54         /// </summary>
55         /// <since_tizen> 3 </since_tizen>
56         public enum GestureType
57         {
58             /// <summary>
59             /// When two touch points move away or towards each other.
60             /// </summary>
61             /// <since_tizen> 3 </since_tizen>
62             Pinch = 1 << 0,
63             /// <summary>
64             /// When the user drags their finger(s) in a particular direction.
65             /// </summary>
66             /// <since_tizen> 3 </since_tizen>
67             Pan = 1 << 1,
68             /// <summary>
69             /// When the user taps the screen.
70             /// </summary>
71             /// <since_tizen> 3 </since_tizen>
72             Tap = 1 << 2,
73             /// <summary>
74             ///  When the user continues to touch the same area on the screen for the device configured time.
75             /// </summary>
76             /// <since_tizen> 3 </since_tizen>
77             LongPress = 1 << 3
78         }
79
80         /// <summary>
81         /// Enumeration for state of the gesture.
82         /// </summary>
83         /// <since_tizen> 3 </since_tizen>
84         public enum StateType
85         {
86             /// <summary>
87             /// There is no state associated with this gesture.
88             /// </summary>
89             /// <since_tizen> 3 </since_tizen>
90             Clear,
91             /// <summary>
92             /// The touched points on the screen have moved enough to be considered a gesture.
93             /// </summary>
94             /// <since_tizen> 3 </since_tizen>
95             Started,
96             /// <summary>
97             /// The gesture is continuing.
98             /// </summary>
99             /// <since_tizen> 3 </since_tizen>
100             Continuing,
101             /// <summary>
102             /// The user has lifted a finger or touched an additional point on the screen.
103             /// </summary>
104             /// <since_tizen> 3 </since_tizen>
105             Finished,
106             /// <summary>
107             /// The gesture has been cancelled.
108             /// </summary>
109             /// <since_tizen> 3 </since_tizen>
110             Cancelled,
111             /// <summary>
112             ///  A gesture is possible.
113             /// </summary>
114             /// <since_tizen> 3 </since_tizen>
115             Possible
116         }
117
118         /// <summary>
119         /// The gesture type.
120         /// </summary>
121         /// <since_tizen> 3 </since_tizen>
122         public Gesture.GestureType Type
123         {
124             get
125             {
126                 return type;
127             }
128         }
129
130         /// <summary>
131         /// The gesture state.
132         /// </summary>
133         /// <since_tizen> 3 </since_tizen>
134         public Gesture.StateType State
135         {
136             get
137             {
138                 return state;
139             }
140         }
141
142         /// <summary>
143         /// The time the gesture took place.
144         /// </summary>
145         /// <since_tizen> 3 </since_tizen>
146         public uint Time
147         {
148             get
149             {
150                 return time;
151             }
152         }
153
154         private Gesture.GestureType type
155         {
156             set
157             {
158                 Interop.Gesture.Gesture_type_set(swigCPtr, (int)value);
159                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160             }
161             get
162             {
163                 Gesture.GestureType ret = (Gesture.GestureType)Interop.Gesture.Gesture_type_get(swigCPtr);
164                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165                 return ret;
166             }
167         }
168
169         private Gesture.StateType state
170         {
171             set
172             {
173                 Interop.Gesture.Gesture_state_set(swigCPtr, (int)value);
174                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175             }
176             get
177             {
178                 Gesture.StateType ret = (Gesture.StateType)Interop.Gesture.Gesture_state_get(swigCPtr);
179                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180                 return ret;
181             }
182         }
183
184         private uint time
185         {
186             set
187             {
188                 Interop.Gesture.Gesture_time_set(swigCPtr, value);
189                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190             }
191             get
192             {
193                 uint ret = Interop.Gesture.Gesture_time_get(swigCPtr);
194                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
195                 return ret;
196             }
197         }
198
199         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Gesture obj)
200         {
201             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
202         }
203
204         /// <summary>
205         /// Dispose.
206         /// </summary>
207         /// <since_tizen> 3 </since_tizen>
208         protected override void Dispose(DisposeTypes type)
209         {
210             if (disposed)
211             {
212                 return;
213             }
214
215             //Release your own unmanaged resources here.
216             //You should not access any managed member here except static instance.
217             //because the execution order of Finalizes is non-deterministic.
218
219             if (swigCPtr.Handle != global::System.IntPtr.Zero)
220             {
221                 if (swigCMemOwn)
222                 {
223                     swigCMemOwn = false;
224                     Interop.Gesture.delete_Gesture(swigCPtr);
225                 }
226                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
227             }
228             base.Dispose(type);
229         }
230     }
231 }