English Review: NUI public files (#434)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / TapGestureDetector.cs
1 /*
2  * Copyright(c) 2018 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;
18 using System.Runtime.InteropServices;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
21
22 namespace Tizen.NUI
23 {
24
25     /// <summary>
26     /// This class emits a signal when a tap gesture occurs that meets the requirements set by the application.<br />
27     /// A TapGesture is a discrete gesture, which means it does not have any state information attached.<br />
28     /// </summary>
29     /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
30     [EditorBrowsable(EditorBrowsableState.Never)]
31     public class TapGestureDetector : GestureDetector
32     {
33         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
34
35         internal TapGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.TapGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
36         {
37             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38         }
39
40         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TapGestureDetector obj)
41         {
42             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43         }
44
45         /// <summary>
46         /// Dispose.
47         /// </summary>
48         /// <param name="type">The dispose type</param>
49         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
50         [EditorBrowsable(EditorBrowsableState.Never)]
51         protected override void Dispose(DisposeTypes type)
52         {
53             if (disposed)
54             {
55                 return;
56             }
57
58             if (type == DisposeTypes.Explicit)
59             {
60                 //Called by User
61                 //Release your own managed resources here.
62                 //You should release all of your own disposable objects here.
63
64             }
65
66             //Release your own unmanaged resources here.
67             //You should not access any managed member here except static instance.
68             //because the execution order of Finalizes is non-deterministic.
69
70             if (swigCPtr.Handle != global::System.IntPtr.Zero)
71             {
72                 if (swigCMemOwn)
73                 {
74                     swigCMemOwn = false;
75                     NDalicPINVOKE.delete_TapGestureDetector(swigCPtr);
76                 }
77                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
78             }
79
80             base.Dispose(type);
81         }
82
83         /// <summary>
84         /// Event arguments that are passed via the TapGestureEvent signal.
85         /// </summary>
86         /// <since_tizen> 5 </since_tizen>
87         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
88         [EditorBrowsable(EditorBrowsableState.Never)]
89         public class DetectedEventArgs : EventArgs
90         {
91             private View _view;
92             private TapGesture _tapGesture;
93
94             /// <summary>
95             /// The attached view.
96             /// </summary>
97             /// <since_tizen> 5 </since_tizen>
98             /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
99             [EditorBrowsable(EditorBrowsableState.Never)]
100             public View View
101             {
102                 get
103                 {
104                     return _view;
105                 }
106                 set
107                 {
108                     _view = value;
109                 }
110             }
111
112             /// <summary>
113             /// The TapGesture.
114             /// </summary>
115             /// <since_tizen> 5 </since_tizen>
116             /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
117             [EditorBrowsable(EditorBrowsableState.Never)]
118             public TapGesture TapGesture
119             {
120                 get
121                 {
122                     return _tapGesture;
123                 }
124                 set
125                 {
126                     _tapGesture = value;
127                 }
128             }
129         }
130
131         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
132         private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr TapGesture);
133         private DaliEventHandler<object, DetectedEventArgs> _tapGestureEventHandler;
134         private DetectedCallbackDelegate _tapGestureCallbackDelegate;
135
136         /// <summary>
137         /// This signal is emitted when the specified tap is detected on the attached view.
138         /// </summary>
139         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
140         [EditorBrowsable(EditorBrowsableState.Never)]
141         public event DaliEventHandler<object, DetectedEventArgs> Detected
142         {
143             add
144             {
145                 lock (this)
146                 {
147                     // Restricted to only one listener
148                     if (_tapGestureEventHandler == null)
149                     {
150                         _tapGestureEventHandler += value;
151
152                         _tapGestureCallbackDelegate = new DetectedCallbackDelegate(OnTapGestureDetected);
153                         this.DetectedSignal().Connect(_tapGestureCallbackDelegate);
154                     }
155                 }
156             }
157
158             remove
159             {
160                 lock (this)
161                 {
162                     if (_tapGestureEventHandler != null)
163                     {
164                         this.DetectedSignal().Disconnect(_tapGestureCallbackDelegate);
165                     }
166
167                     _tapGestureEventHandler -= value;
168                 }
169             }
170         }
171
172         private void OnTapGestureDetected(IntPtr actor, IntPtr tapGesture)
173         {
174             DetectedEventArgs e = new DetectedEventArgs();
175
176             // Populate all members of "e" (DetectedEventArgs) with real data
177             e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
178             e.TapGesture = Tizen.NUI.TapGesture.GetTapGestureFromPtr(tapGesture);
179
180             if (_tapGestureEventHandler != null)
181             {
182                 //here we send all data to user event handlers
183                 _tapGestureEventHandler(this, e);
184             }
185
186         }
187
188         internal static TapGestureDetector GetTapGestureDetectorFromPtr(global::System.IntPtr cPtr)
189         {
190             TapGestureDetector ret = new TapGestureDetector(cPtr, false);
191             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192             return ret;
193         }
194
195         /// <summary>
196         /// Creates an initialized TapGestureDetector.
197         /// </summary>
198         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
199         [EditorBrowsable(EditorBrowsableState.Never)]
200         public TapGestureDetector() : this(NDalicPINVOKE.TapGestureDetector_New__SWIG_0(), true)
201         {
202             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203
204         }
205
206         /// <summary>
207         /// Creates an initialized TapGestureDetector with the specified parameters.
208         /// </summary>
209         /// <param name="tapsRequired">The minimum & maximum number of taps required</param>
210         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
211         [EditorBrowsable(EditorBrowsableState.Never)]
212         public TapGestureDetector(uint tapsRequired) : this(NDalicPINVOKE.TapGestureDetector_New__SWIG_1(tapsRequired), true)
213         {
214             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215
216         }
217
218         internal new static TapGestureDetector DownCast(BaseHandle handle)
219         {
220             TapGestureDetector ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as TapGestureDetector;
221             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222             return ret;
223         }
224
225         /// <summary>
226         /// The copy constructor.
227         /// </summary>
228         /// <param name="handle">A reference to the copied handle</param>
229         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
230         [EditorBrowsable(EditorBrowsableState.Never)]
231         public TapGestureDetector(TapGestureDetector handle) : this(NDalicPINVOKE.new_TapGestureDetector__SWIG_1(TapGestureDetector.getCPtr(handle)), true)
232         {
233             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234         }
235
236         internal TapGestureDetector Assign(TapGestureDetector rhs)
237         {
238             TapGestureDetector ret = new TapGestureDetector(NDalicPINVOKE.TapGestureDetector_Assign(swigCPtr, TapGestureDetector.getCPtr(rhs)), false);
239             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240             return ret;
241         }
242
243         /// <summary>
244         /// Sets the minimum number of taps required. The tap count is the number of times a user should "tap" the screen.<br />
245         /// The default is 1.<br />
246         /// </summary>
247         /// <param name="minimumTaps">The minimum taps required</param>
248         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
249         [EditorBrowsable(EditorBrowsableState.Never)]
250         public void SetMinimumTapsRequired(uint minimumTaps)
251         {
252             NDalicPINVOKE.TapGestureDetector_SetMinimumTapsRequired(swigCPtr, minimumTaps);
253             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254         }
255
256         /// <summary>
257         /// Sets the maximum number of taps required. The tap count is the number of times a user should "tap" the screen.<br />
258         /// The default is 1.<br />
259         /// </summary>
260         /// <param name="maximumTaps">The maximum taps required</param>
261         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
262         [EditorBrowsable(EditorBrowsableState.Never)]
263         public void SetMaximumTapsRequired(uint maximumTaps)
264         {
265             NDalicPINVOKE.TapGestureDetector_SetMaximumTapsRequired(swigCPtr, maximumTaps);
266             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267         }
268
269         /// <summary>
270         /// Retrieves the minimum number of taps required.
271         /// </summary>
272         /// <returns>The minimum taps required</returns>
273         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
274         [EditorBrowsable(EditorBrowsableState.Never)]
275         public uint GetMinimumTapsRequired()
276         {
277             uint ret = NDalicPINVOKE.TapGestureDetector_GetMinimumTapsRequired(swigCPtr);
278             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279             return ret;
280         }
281
282         /// <summary>
283         /// Retrieves the maximum number of taps required.
284         /// </summary>
285         /// <returns>The maximum taps required</returns>
286         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
287         [EditorBrowsable(EditorBrowsableState.Never)]
288         public uint GetMaximumTapsRequired()
289         {
290             uint ret = NDalicPINVOKE.TapGestureDetector_GetMaximumTapsRequired(swigCPtr);
291             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292             return ret;
293         }
294
295         internal TapGestureDetectedSignal DetectedSignal()
296         {
297             TapGestureDetectedSignal ret = new TapGestureDetectedSignal(NDalicPINVOKE.TapGestureDetector_DetectedSignal(swigCPtr), false);
298             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299             return ret;
300         }
301
302     }
303
304 }