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;
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
37 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
38 [EditorBrowsable(EditorBrowsableState.Never)]
39 public LongPressGestureDetector() : this(Interop.LongPressGestureDetector.New(), true)
41 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
45 /// Creates an initialized LongPressGestureDetector with the number of touches required.<br />
46 /// 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 />
48 /// <param name="touchesRequired">The number of touches required.</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 public LongPressGestureDetector(uint touchesRequired) : this(Interop.LongPressGestureDetector.New(touchesRequired), true)
53 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
57 /// Creates an initialized LongPressGestureDetector with the minimum and maximum number of touches required.<br />
58 /// 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 />
60 /// <param name="minTouches">The minimum number of touches required.</param>
61 /// <param name="maxTouches">The maximum number of touches required.</param>
62 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
63 [EditorBrowsable(EditorBrowsableState.Never)]
64 public LongPressGestureDetector(uint minTouches, uint maxTouches) : this(Interop.LongPressGestureDetector.New(minTouches, maxTouches), true)
66 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
70 /// The copy constructor.
72 /// <param name="handle">A reference to the copied handle</param>
73 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
74 [EditorBrowsable(EditorBrowsableState.Never)]
75 public LongPressGestureDetector(LongPressGestureDetector handle) : this(Interop.LongPressGestureDetector.NewLongPressGestureDetector(LongPressGestureDetector.getCPtr(handle)), true)
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
80 internal LongPressGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.LongPressGestureDetector.Upcast(cPtr), cMemoryOwn)
84 private DaliEventHandler<object, DetectedEventArgs> _detectedEventHandler;
85 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86 private delegate void DetectedCallbackType(IntPtr actor, IntPtr longPressGesture);
87 private DetectedCallbackType _detectedCallback;
90 /// This signal is emitted when the specified long press is detected on the attached view.
92 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
93 [EditorBrowsable(EditorBrowsableState.Never)]
94 public event DaliEventHandler<object, DetectedEventArgs> Detected
98 if (_detectedEventHandler == null)
100 _detectedCallback = OnLongPressGestureDetected;
101 DetectedSignal().Connect(_detectedCallback);
104 _detectedEventHandler += value;
109 _detectedEventHandler -= value;
111 if (_detectedEventHandler == null && DetectedSignal().Empty() == false)
113 DetectedSignal().Disconnect(_detectedCallback);
119 /// Sets the number of touches required.<br />
120 /// The number of touches corresponds to the number of fingers a user has on the screen. The default is 1.<br />
122 /// <param name="touches">Touches required</param>
123 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
124 [EditorBrowsable(EditorBrowsableState.Never)]
125 public void SetTouchesRequired(uint touches)
127 Interop.LongPressGestureDetector.SetTouchesRequired(swigCPtr, touches);
128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132 /// Sets the minimum and maximum touches required.
134 /// <param name="minTouches">Minimum touches required.</param>
135 /// <param name="maxTouches">Maximum touches required.</param>
136 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
137 [EditorBrowsable(EditorBrowsableState.Never)]
138 public void SetTouchesRequired(uint minTouches, uint maxTouches)
140 Interop.LongPressGestureDetector.SetTouchesRequired(swigCPtr, minTouches, maxTouches);
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145 /// Retrieves the minimum number of touches required.
147 /// <returns>The minimum number of touches required.</returns>
148 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
149 [EditorBrowsable(EditorBrowsableState.Never)]
150 public uint GetMinimumTouchesRequired()
152 uint ret = Interop.LongPressGestureDetector.GetMinimumTouchesRequired(swigCPtr);
153 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158 /// Retrieves the maximum number of touches required.
160 /// <returns>The maximum number of touches required.</returns>
161 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
162 [EditorBrowsable(EditorBrowsableState.Never)]
163 public uint GetMaximumTouchesRequired()
165 uint ret = Interop.LongPressGestureDetector.GetMaximumTouchesRequired(swigCPtr);
166 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 internal static LongPressGestureDetector GetLongPressGestureDetectorFromPtr(global::System.IntPtr cPtr)
172 LongPressGestureDetector ret = new LongPressGestureDetector(cPtr, false);
173 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177 internal new static LongPressGestureDetector DownCast(BaseHandle handle)
179 LongPressGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as LongPressGestureDetector;
180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 internal LongPressGestureDetector Assign(LongPressGestureDetector rhs)
186 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.LongPressGestureDetector.Assign(swigCPtr, LongPressGestureDetector.getCPtr(rhs)), false);
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 internal LongPressGestureDetectedSignal DetectedSignal()
193 LongPressGestureDetectedSignal ret = new LongPressGestureDetectedSignal(Interop.LongPressGestureDetector.DetectedSignal(swigCPtr), false);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LongPressGestureDetector obj)
200 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
203 /// This will not be public opened.
204 [EditorBrowsable(EditorBrowsableState.Never)]
205 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
207 if (_detectedEventHandler == null && DetectedSignal().Empty() == false)
209 DetectedSignal().Disconnect(_detectedCallback);
211 Interop.LongPressGestureDetector.DeleteLongPressGestureDetector(swigCPtr);
214 private void OnLongPressGestureDetected(IntPtr actor, IntPtr longPressGesture)
216 DetectedEventArgs e = new DetectedEventArgs();
218 // Populate all members of "e" (LongPressGestureEventArgs) with real data.
219 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
222 e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
225 e.LongPressGesture = Tizen.NUI.LongPressGesture.GetLongPressGestureFromPtr(longPressGesture);
227 if (_detectedEventHandler != null)
229 //Here we send all data to user event handlers.
230 _detectedEventHandler(this, e);
235 /// Event arguments that passed via the LongPressGestureEvent signal.
237 /// <since_tizen> 5 </since_tizen>
238 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
239 [EditorBrowsable(EditorBrowsableState.Never)]
240 public class DetectedEventArgs : EventArgs
243 private LongPressGesture _longPressGesture;
246 /// View the attached view.
248 /// <since_tizen> 5 </since_tizen>
249 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
250 [EditorBrowsable(EditorBrowsableState.Never)]
264 /// The LongPressGesture.
266 /// <since_tizen> 5 </since_tizen>
267 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
268 [EditorBrowsable(EditorBrowsableState.Never)]
269 public LongPressGesture LongPressGesture
273 return _longPressGesture;
277 _longPressGesture = value;