2 * Copyright(c) 2018 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;
25 /// This class emits a signals when a long press gesture occurs that meets the requirements set by the application.<br />
26 /// For any valid long press, two signals will be emitted:<br />
27 /// - First identifying the beginning (state = Started) i.e. when fingers held down for the required time.<br />
28 /// - Second identifying the ending (state = Finished) i.e. when fingers are released.<br />
30 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public class LongPressGestureDetector : GestureDetector
34 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
36 private DaliEventHandler<object, DetectedEventArgs> _longPressGestureEventHandler;
37 private DetectedCallbackDelegate _longPressGestureCallbackDelegate;
42 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
43 [EditorBrowsable(EditorBrowsableState.Never)]
44 public LongPressGestureDetector() : this(Interop.LongPressGestureDetector.LongPressGestureDetector_New__SWIG_0(), true)
46 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50 /// Creates an initialized LongPressGestureDetector with the number of touches required.<br />
51 /// A long press gesture will be emitted from this detector if the number of fingers touching the screen is equal to the touches required.<br />
53 /// <param name="touchesRequired">The number of touches required.</param>
54 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
55 [EditorBrowsable(EditorBrowsableState.Never)]
56 public LongPressGestureDetector(uint touchesRequired) : this(Interop.LongPressGestureDetector.LongPressGestureDetector_New__SWIG_1(touchesRequired), true)
58 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
62 /// Creates an initialized LongPressGestureDetector with the minimum and maximum number of touches required.<br />
63 /// A long press gesture will be emitted from this detector if the number of fingers touching the screen falls between the minimum and maximum touches set.<br />
65 /// <param name="minTouches">The minimum number of touches required.</param>
66 /// <param name="maxTouches">The maximum number of touches required.</param>
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 LongPressGestureDetector(uint minTouches, uint maxTouches) : this(Interop.LongPressGestureDetector.LongPressGestureDetector_New__SWIG_2(minTouches, maxTouches), true)
71 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
75 /// The copy constructor.
77 /// <param name="handle">A reference to the copied handle</param>
78 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
79 [EditorBrowsable(EditorBrowsableState.Never)]
80 public LongPressGestureDetector(LongPressGestureDetector handle) : this(Interop.LongPressGestureDetector.new_LongPressGestureDetector__SWIG_1(LongPressGestureDetector.getCPtr(handle)), true)
82 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
85 internal LongPressGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.LongPressGestureDetector.LongPressGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
87 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
90 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
91 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr longPressGesture);
94 /// This signal is emitted when the specified long press is detected on the attached view.
96 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
97 [EditorBrowsable(EditorBrowsableState.Never)]
98 public event DaliEventHandler<object, DetectedEventArgs> Detected
104 // Restricted to only one listener.
105 if (_longPressGestureEventHandler == null)
107 _longPressGestureEventHandler += value;
109 _longPressGestureCallbackDelegate = new DetectedCallbackDelegate(OnLongPressGestureDetected);
110 this.DetectedSignal().Connect(_longPressGestureCallbackDelegate);
119 if (_longPressGestureEventHandler != null)
121 this.DetectedSignal().Disconnect(_longPressGestureCallbackDelegate);
124 _longPressGestureEventHandler -= value;
130 /// Sets the number of touches required.<br />
131 /// The number of touches corresponds to the number of fingers a user has on the screen. The default is 1.<br />
133 /// <param name="touches">Touches required</param>
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 void SetTouchesRequired(uint touches)
138 Interop.LongPressGestureDetector.LongPressGestureDetector_SetTouchesRequired__SWIG_0(swigCPtr, touches);
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143 /// Sets the minimum and maximum touches required.
145 /// <param name="minTouches">Minimum touches required.</param>
146 /// <param name="maxTouches">Maximum touches required.</param>
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 void SetTouchesRequired(uint minTouches, uint maxTouches)
151 Interop.LongPressGestureDetector.LongPressGestureDetector_SetTouchesRequired__SWIG_1(swigCPtr, minTouches, maxTouches);
152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 /// Retrieves the minimum number of touches required.
158 /// <returns>The minimum number of touches required.</returns>
159 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
160 [EditorBrowsable(EditorBrowsableState.Never)]
161 public uint GetMinimumTouchesRequired()
163 uint ret = Interop.LongPressGestureDetector.LongPressGestureDetector_GetMinimumTouchesRequired(swigCPtr);
164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169 /// Retrieves the maximum number of touches required.
171 /// <returns>The maximum number of touches required.</returns>
172 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
173 [EditorBrowsable(EditorBrowsableState.Never)]
174 public uint GetMaximumTouchesRequired()
176 uint ret = Interop.LongPressGestureDetector.LongPressGestureDetector_GetMaximumTouchesRequired(swigCPtr);
177 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
181 internal static LongPressGestureDetector GetLongPressGestureDetectorFromPtr(global::System.IntPtr cPtr)
183 LongPressGestureDetector ret = new LongPressGestureDetector(cPtr, false);
184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188 internal new static LongPressGestureDetector DownCast(BaseHandle handle)
190 LongPressGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as LongPressGestureDetector;
191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
195 internal LongPressGestureDetector Assign(LongPressGestureDetector rhs)
197 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.LongPressGestureDetector.LongPressGestureDetector_Assign(swigCPtr, LongPressGestureDetector.getCPtr(rhs)), false);
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202 internal LongPressGestureDetectedSignal DetectedSignal()
204 LongPressGestureDetectedSignal ret = new LongPressGestureDetectedSignal(Interop.LongPressGestureDetector.LongPressGestureDetector_DetectedSignal(swigCPtr), false);
205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LongPressGestureDetector obj)
211 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
217 /// <param name="type">The dispose type</param>
218 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
219 [EditorBrowsable(EditorBrowsableState.Never)]
220 protected override void Dispose(DisposeTypes type)
227 //Release your own unmanaged resources here.
228 //You should not access any managed member here except static instance.
229 //because the execution order of Finalizes is non-deterministic.
231 if (swigCPtr.Handle != global::System.IntPtr.Zero)
236 Interop.LongPressGestureDetector.delete_LongPressGestureDetector(swigCPtr);
238 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
244 private void OnLongPressGestureDetected(IntPtr actor, IntPtr longPressGesture)
246 DetectedEventArgs e = new DetectedEventArgs();
248 // Populate all members of "e" (LongPressGestureEventArgs) with real data.
249 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
250 e.LongPressGesture = Tizen.NUI.LongPressGesture.GetLongPressGestureFromPtr(longPressGesture);
252 if (_longPressGestureEventHandler != null)
254 //Here we send all data to user event handlers.
255 _longPressGestureEventHandler(this, e);
260 /// Event arguments that passed via the LongPressGestureEvent signal.
262 /// <since_tizen> 5 </since_tizen>
263 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
264 [EditorBrowsable(EditorBrowsableState.Never)]
265 public class DetectedEventArgs : EventArgs
268 private LongPressGesture _longPressGesture;
271 /// View the attached view.
273 /// <since_tizen> 5 </since_tizen>
274 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
275 [EditorBrowsable(EditorBrowsableState.Never)]
289 /// The LongPressGesture.
291 /// <since_tizen> 5 </since_tizen>
292 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
293 [EditorBrowsable(EditorBrowsableState.Never)]
294 public LongPressGesture LongPressGesture
298 return _longPressGesture;
302 _longPressGesture = value;