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 /// 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;
37 /// Creates an initialized PinchGestureDetector.
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 PinchGestureDetector() : this(Interop.PinchGesture.PinchGestureDetector_New(), true)
43 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
48 /// The copy constructor.
50 /// <param name="handle">A reference to the copied handle</param>
51 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
52 [EditorBrowsable(EditorBrowsableState.Never)]
53 public PinchGestureDetector(PinchGestureDetector handle) : this(Interop.PinchGesture.new_PinchGestureDetector__SWIG_1(PinchGestureDetector.getCPtr(handle)), true)
55 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
58 internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PinchGesture.PinchGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
60 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
63 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
64 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr pinchGesture);
67 /// This signal is emitted when the specified pinch is detected on the attached view.
69 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
70 [EditorBrowsable(EditorBrowsableState.Never)]
71 public event DaliEventHandler<object, DetectedEventArgs> Detected
77 // Restricted to only one listener
78 if (_pinchGestureEventHandler == null)
80 _pinchGestureEventHandler += value;
82 _pinchGestureCallbackDelegate = new DetectedCallbackDelegate(OnPinchGestureDetected);
83 this.DetectedSignal().Connect(_pinchGestureCallbackDelegate);
92 if (_pinchGestureEventHandler != null)
94 this.DetectedSignal().Disconnect(_pinchGestureCallbackDelegate);
97 _pinchGestureEventHandler -= value;
103 internal static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
105 PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110 internal new static PinchGestureDetector DownCast(BaseHandle handle)
112 PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PinchGestureDetector obj)
119 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
122 internal PinchGestureDetector Assign(PinchGestureDetector rhs)
124 PinchGestureDetector ret = new PinchGestureDetector(Interop.PinchGesture.PinchGestureDetector_Assign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
125 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129 internal PinchGestureDetectedSignal DetectedSignal()
131 PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(Interop.PinchGesture.PinchGestureDetector_DetectedSignal(swigCPtr), false);
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139 /// <param name="type">The dispose type</param>
140 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
141 [EditorBrowsable(EditorBrowsableState.Never)]
142 protected override void Dispose(DisposeTypes type)
149 //Release your own unmanaged resources here.
150 //You should not access any managed member here except static instance.
151 //Because the execution order of Finalizes is non-deterministic.
153 if (swigCPtr.Handle != global::System.IntPtr.Zero)
158 Interop.PinchGesture.delete_PinchGestureDetector(swigCPtr);
160 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
166 private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
168 DetectedEventArgs e = new DetectedEventArgs();
170 // Populate all members of "e" (DetectedEventArgs) with real data.
171 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
174 e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
177 e.PinchGesture = Tizen.NUI.PinchGesture.GetPinchGestureFromPtr(pinchGesture);
179 if (_pinchGestureEventHandler != null)
181 //Here we send all data to user event handlers.
182 _pinchGestureEventHandler(this, e);
187 /// Event arguments that passed via the PinchGestureEvent signal.
189 /// <since_tizen> 5 </since_tizen>
190 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
191 [EditorBrowsable(EditorBrowsableState.Never)]
192 public class DetectedEventArgs : EventArgs
195 private PinchGesture _pinchGesture;
198 /// The attached view.
200 /// <since_tizen> 5 </since_tizen>
201 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
202 [EditorBrowsable(EditorBrowsableState.Never)]
216 /// The PinchGesture.
218 /// <since_tizen> 5 </since_tizen>
219 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
220 [EditorBrowsable(EditorBrowsableState.Never)]
221 public PinchGesture PinchGesture
225 return _pinchGesture;
229 _pinchGesture = value;