2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
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 />
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
33 private DaliEventHandler<object, DetectedEventArgs> _tapGestureEventHandler;
34 private DetectedCallbackDelegate _tapGestureCallbackDelegate;
37 /// Creates an initialized TapGestureDetector.
39 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
40 [EditorBrowsable(EditorBrowsableState.Never)]
41 public TapGestureDetector() : this(Interop.TapGestureDetector.TapGestureDetector_New__SWIG_0(), true)
43 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
47 /// Creates an initialized TapGestureDetector with the specified parameters.
49 /// <param name="tapsRequired">The minimum and maximum number of taps required</param>
50 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
51 [EditorBrowsable(EditorBrowsableState.Never)]
52 public TapGestureDetector(uint tapsRequired) : this(Interop.TapGestureDetector.TapGestureDetector_New__SWIG_1(tapsRequired), true)
54 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
58 internal TapGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.TapGestureDetector.TapGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
62 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
63 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr TapGesture);
66 /// This signal is emitted when the specified tap is detected on the attached view.
68 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
69 [EditorBrowsable(EditorBrowsableState.Never)]
70 public event DaliEventHandler<object, DetectedEventArgs> Detected
76 // Restricted to only one listener
77 if (_tapGestureEventHandler == null)
79 _tapGestureEventHandler += value;
81 _tapGestureCallbackDelegate = new DetectedCallbackDelegate(OnTapGestureDetected);
82 this.DetectedSignal().Connect(_tapGestureCallbackDelegate);
91 if (_tapGestureEventHandler != null)
93 this.DetectedSignal().Disconnect(_tapGestureCallbackDelegate);
96 _tapGestureEventHandler -= value;
102 /// The copy constructor.
104 /// <param name="handle">A reference to the copied handle</param>
105 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
106 [EditorBrowsable(EditorBrowsableState.Never)]
107 public TapGestureDetector(TapGestureDetector handle) : this(Interop.TapGestureDetector.new_TapGestureDetector__SWIG_1(TapGestureDetector.getCPtr(handle)), true)
109 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113 /// Sets the minimum number of taps required. The tap count is the number of times a user should "tap" the screen.<br />
114 /// The default is 1.<br />
116 /// <param name="minimumTaps">The minimum taps required</param>
117 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
118 [EditorBrowsable(EditorBrowsableState.Never)]
119 public void SetMinimumTapsRequired(uint minimumTaps)
121 Interop.TapGestureDetector.TapGestureDetector_SetMinimumTapsRequired(swigCPtr, minimumTaps);
122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126 /// Sets the maximum number of taps required. The tap count is the number of times a user should "tap" the screen.<br />
127 /// The default is 1.<br />
129 /// <param name="maximumTaps">The maximum taps required</param>
130 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
131 [EditorBrowsable(EditorBrowsableState.Never)]
132 public void SetMaximumTapsRequired(uint maximumTaps)
134 Interop.TapGestureDetector.TapGestureDetector_SetMaximumTapsRequired(swigCPtr, maximumTaps);
135 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139 /// Retrieves the minimum number of taps required.
141 /// <returns>The minimum taps required</returns>
142 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
143 [EditorBrowsable(EditorBrowsableState.Never)]
144 public uint GetMinimumTapsRequired()
146 uint ret = Interop.TapGestureDetector.TapGestureDetector_GetMinimumTapsRequired(swigCPtr);
147 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152 /// Retrieves the maximum number of taps required.
154 /// <returns>The maximum taps required</returns>
155 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
156 [EditorBrowsable(EditorBrowsableState.Never)]
157 public uint GetMaximumTapsRequired()
159 uint ret = Interop.TapGestureDetector.TapGestureDetector_GetMaximumTapsRequired(swigCPtr);
160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164 internal new static TapGestureDetector DownCast(BaseHandle handle)
166 TapGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TapGestureDetector;
167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TapGestureDetector obj)
173 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
176 internal static TapGestureDetector GetTapGestureDetectorFromPtr(global::System.IntPtr cPtr)
178 TapGestureDetector ret = new TapGestureDetector(cPtr, false);
179 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183 internal TapGestureDetectedSignal DetectedSignal()
185 TapGestureDetectedSignal ret = new TapGestureDetectedSignal(Interop.TapGestureDetector.TapGestureDetector_DetectedSignal(swigCPtr), false);
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 internal TapGestureDetector Assign(TapGestureDetector rhs)
192 TapGestureDetector ret = new TapGestureDetector(Interop.TapGestureDetector.TapGestureDetector_Assign(swigCPtr, TapGestureDetector.getCPtr(rhs)), false);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197 /// This will not be public opened.
198 [EditorBrowsable(EditorBrowsableState.Never)]
199 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
201 Interop.TapGestureDetector.delete_TapGestureDetector(swigCPtr);
204 private void OnTapGestureDetected(IntPtr actor, IntPtr tapGesture)
206 DetectedEventArgs e = new DetectedEventArgs();
208 // Populate all members of "e" (DetectedEventArgs) with real data
209 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
213 e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
216 e.TapGesture = Tizen.NUI.TapGesture.GetTapGestureFromPtr(tapGesture);
218 if (_tapGestureEventHandler != null)
220 //here we send all data to user event handlers
221 _tapGestureEventHandler(this, e);
226 /// Event arguments that are passed via the TapGestureEvent signal.
228 /// <since_tizen> 5 </since_tizen>
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 class DetectedEventArgs : EventArgs
234 private TapGesture _tapGesture;
237 /// The attached view.
239 /// <since_tizen> 5 </since_tizen>
240 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
241 [EditorBrowsable(EditorBrowsableState.Never)]
257 /// <since_tizen> 5 </since_tizen>
258 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
259 [EditorBrowsable(EditorBrowsableState.Never)]
260 public TapGesture TapGesture