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 /// It tries to detect when the user moves two touch points towards or away from each other.
27 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
28 [EditorBrowsable(EditorBrowsableState.Never)]
29 public class PinchGestureDetector : GestureDetector
31 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33 private DaliEventHandler<object, DetectedEventArgs> _pinchGestureEventHandler;
34 private DetectedCallbackDelegate _pinchGestureCallbackDelegate;
38 /// Creates an initialized PinchGestureDetector.
40 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
41 [EditorBrowsable(EditorBrowsableState.Never)]
42 public PinchGestureDetector() : this(Interop.PinchGesture.PinchGestureDetector_New(), true)
44 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
49 /// The copy constructor.
51 /// <param name="handle">A reference to the copied handle</param>
52 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
53 [EditorBrowsable(EditorBrowsableState.Never)]
54 public PinchGestureDetector(PinchGestureDetector handle) : this(Interop.PinchGesture.new_PinchGestureDetector__SWIG_1(PinchGestureDetector.getCPtr(handle)), true)
56 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
59 internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PinchGesture.PinchGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
61 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
64 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
65 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr pinchGesture);
68 /// This signal is emitted when the specified pinch is detected on the attached view.
70 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
71 [EditorBrowsable(EditorBrowsableState.Never)]
72 public event DaliEventHandler<object, DetectedEventArgs> Detected
78 // Restricted to only one listener
79 if (_pinchGestureEventHandler == null)
81 _pinchGestureEventHandler += value;
83 _pinchGestureCallbackDelegate = new DetectedCallbackDelegate(OnPinchGestureDetected);
84 this.DetectedSignal().Connect(_pinchGestureCallbackDelegate);
93 if (_pinchGestureEventHandler != null)
95 this.DetectedSignal().Disconnect(_pinchGestureCallbackDelegate);
98 _pinchGestureEventHandler -= value;
104 internal static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
106 PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
107 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111 internal new static PinchGestureDetector DownCast(BaseHandle handle)
113 PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PinchGestureDetector obj)
120 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
123 internal PinchGestureDetector Assign(PinchGestureDetector rhs)
125 PinchGestureDetector ret = new PinchGestureDetector(Interop.PinchGesture.PinchGestureDetector_Assign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
126 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130 internal PinchGestureDetectedSignal DetectedSignal()
132 PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(Interop.PinchGesture.PinchGestureDetector_DetectedSignal(swigCPtr), false);
133 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140 /// <param name="type">The dispose type</param>
141 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
142 [EditorBrowsable(EditorBrowsableState.Never)]
143 protected override void Dispose(DisposeTypes type)
150 if (type == DisposeTypes.Explicit)
153 //Release your own managed resources here.
154 //You should release all of your own disposable objects here.
158 //Release your own unmanaged resources here.
159 //You should not access any managed member here except static instance.
160 //Because the execution order of Finalizes is non-deterministic.
163 if (swigCPtr.Handle != global::System.IntPtr.Zero)
168 Interop.PinchGesture.delete_PinchGestureDetector(swigCPtr);
170 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
176 private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
178 DetectedEventArgs e = new DetectedEventArgs();
180 // Populate all members of "e" (DetectedEventArgs) with real data.
181 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
182 e.PinchGesture = Tizen.NUI.PinchGesture.GetPinchGestureFromPtr(pinchGesture);
184 if (_pinchGestureEventHandler != null)
186 //Here we send all data to user event handlers.
187 _pinchGestureEventHandler(this, e);
193 /// Event arguments that passed via the PinchGestureEvent signal.
195 /// <since_tizen> 5 </since_tizen>
196 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
197 [EditorBrowsable(EditorBrowsableState.Never)]
198 public class DetectedEventArgs : EventArgs
201 private PinchGesture _pinchGesture;
204 /// The attached view.
206 /// <since_tizen> 5 </since_tizen>
207 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
208 [EditorBrowsable(EditorBrowsableState.Never)]
222 /// The PinchGesture.
224 /// <since_tizen> 5 </since_tizen>
225 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
226 [EditorBrowsable(EditorBrowsableState.Never)]
227 public PinchGesture PinchGesture
231 return _pinchGesture;
235 _pinchGesture = value;