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
34 /// Creates an initialized TapGestureDetector.
36 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
37 [EditorBrowsable(EditorBrowsableState.Never)]
38 public TapGestureDetector() : this(Interop.TapGestureDetector.New(), true)
40 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
44 /// Creates an initialized TapGestureDetector with the specified parameters.
46 /// <param name="tapsRequired">The minimum and maximum number of taps required</param>
47 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
48 [EditorBrowsable(EditorBrowsableState.Never)]
49 public TapGestureDetector(uint tapsRequired) : this(Interop.TapGestureDetector.New(tapsRequired), true)
51 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55 internal TapGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
59 private DaliEventHandler<object, DetectedEventArgs> _detectedEventHandler;
60 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
61 private delegate void DetectedCallbackType(IntPtr actor, IntPtr TapGesture);
62 private DetectedCallbackType _detectedCallback;
65 /// This signal is emitted when the specified tap is detected on the attached view.
67 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
68 [EditorBrowsable(EditorBrowsableState.Never)]
69 public event DaliEventHandler<object, DetectedEventArgs> Detected
73 if (_detectedEventHandler == null)
75 _detectedCallback = OnTapGestureDetected;
76 DetectedSignal().Connect(_detectedCallback);
79 _detectedEventHandler += value;
84 _detectedEventHandler -= value;
86 if (_detectedEventHandler == null && DetectedSignal().Empty() == false)
88 DetectedSignal().Disconnect(_detectedCallback);
94 /// The copy constructor.
96 /// <param name="handle">A reference to the copied handle</param>
97 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
98 [EditorBrowsable(EditorBrowsableState.Never)]
99 public TapGestureDetector(TapGestureDetector handle) : this(Interop.TapGestureDetector.NewTapGestureDetector(TapGestureDetector.getCPtr(handle)), true)
101 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105 /// Sets the minimum number of taps required. The tap count is the number of times a user should "tap" the screen.<br />
106 /// The default is 1.<br />
108 /// <param name="minimumTaps">The minimum taps required</param>
109 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
110 [EditorBrowsable(EditorBrowsableState.Never)]
111 public void SetMinimumTapsRequired(uint minimumTaps)
113 Interop.TapGestureDetector.SetMinimumTapsRequired(SwigCPtr, minimumTaps);
114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 /// Sets the maximum number of taps required. The tap count is the number of times a user should "tap" the screen.<br />
119 /// The default is 1.<br />
121 /// <param name="maximumTaps">The maximum taps required</param>
122 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
123 [EditorBrowsable(EditorBrowsableState.Never)]
124 public void SetMaximumTapsRequired(uint maximumTaps)
126 Interop.TapGestureDetector.SetMaximumTapsRequired(SwigCPtr, maximumTaps);
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 /// Retrieves the minimum number of taps required.
133 /// <returns>The minimum taps required</returns>
134 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
135 [EditorBrowsable(EditorBrowsableState.Never)]
136 public uint GetMinimumTapsRequired()
138 uint ret = Interop.TapGestureDetector.GetMinimumTapsRequired(SwigCPtr);
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144 /// Retrieves the maximum number of taps required.
146 /// <returns>The maximum taps required</returns>
147 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
148 [EditorBrowsable(EditorBrowsableState.Never)]
149 public uint GetMaximumTapsRequired()
151 uint ret = Interop.TapGestureDetector.GetMaximumTapsRequired(SwigCPtr);
152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 internal new static TapGestureDetector DownCast(BaseHandle handle)
158 TapGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TapGestureDetector;
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TapGestureDetector obj)
165 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
168 internal static TapGestureDetector GetTapGestureDetectorFromPtr(global::System.IntPtr cPtr)
170 TapGestureDetector ret = new TapGestureDetector(cPtr, false);
171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175 internal TapGestureDetectedSignal DetectedSignal()
177 TapGestureDetectedSignal ret = new TapGestureDetectedSignal(Interop.TapGestureDetector.DetectedSignal(SwigCPtr), false);
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182 internal TapGestureDetector Assign(TapGestureDetector rhs)
184 TapGestureDetector ret = new TapGestureDetector(Interop.TapGestureDetector.Assign(SwigCPtr, TapGestureDetector.getCPtr(rhs)), false);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189 /// This will not be public opened.
190 [EditorBrowsable(EditorBrowsableState.Never)]
191 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
193 if (_detectedCallback != null)
195 DetectedSignal().Disconnect(_detectedCallback);
198 Interop.TapGestureDetector.DeleteTapGestureDetector(swigCPtr);
201 private void OnTapGestureDetected(IntPtr actor, IntPtr tapGesture)
203 DetectedEventArgs e = new DetectedEventArgs();
205 // Populate all members of "e" (DetectedEventArgs) with real data
206 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
210 e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
213 e.TapGesture = Tizen.NUI.TapGesture.GetTapGestureFromPtr(tapGesture);
215 if (_detectedEventHandler != null)
217 //here we send all data to user event handlers
218 _detectedEventHandler(this, e);
223 /// Event arguments that are passed via the TapGestureEvent signal.
225 /// <since_tizen> 5 </since_tizen>
226 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
227 [EditorBrowsable(EditorBrowsableState.Never)]
228 public class DetectedEventArgs : EventArgs
231 private TapGesture _tapGesture;
234 /// The attached view.
236 /// <since_tizen> 5 </since_tizen>
237 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
238 [EditorBrowsable(EditorBrowsableState.Never)]
254 /// <since_tizen> 5 </since_tizen>
255 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
256 [EditorBrowsable(EditorBrowsableState.Never)]
257 public TapGesture TapGesture