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 internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PinchGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
35 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PinchGestureDetector obj)
40 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46 /// <param name="type">The dispose type</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 protected override void Dispose(DisposeTypes type)
56 if (type == DisposeTypes.Explicit)
59 //Release your own managed resources here.
60 //You should release all of your own disposable objects here.
64 //Release your own unmanaged resources here.
65 //You should not access any managed member here except static instance.
66 //because the execution order of Finalizes is non-deterministic.
69 if (swigCPtr.Handle != global::System.IntPtr.Zero)
74 NDalicPINVOKE.delete_PinchGestureDetector(swigCPtr);
76 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
83 /// Event arguments that passed via the PinchGestureEvent signal.
85 /// <since_tizen> 5 </since_tizen>
86 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
87 [EditorBrowsable(EditorBrowsableState.Never)]
88 public class DetectedEventArgs : EventArgs
91 private PinchGesture _pinchGesture;
94 /// The attached view.
96 /// <since_tizen> 5 </since_tizen>
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)]
112 /// The PinchGesture.
114 /// <since_tizen> 5 </since_tizen>
115 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
116 [EditorBrowsable(EditorBrowsableState.Never)]
117 public PinchGesture PinchGesture
121 return _pinchGesture;
125 _pinchGesture = value;
130 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
131 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr pinchGesture);
132 private DaliEventHandler<object, DetectedEventArgs> _pinchGestureEventHandler;
133 private DetectedCallbackDelegate _pinchGestureCallbackDelegate;
136 /// This signal is emitted when the specified pinch is detected on the attached view.
138 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
139 [EditorBrowsable(EditorBrowsableState.Never)]
140 public event DaliEventHandler<object, DetectedEventArgs> Detected
146 // Restricted to only one listener
147 if (_pinchGestureEventHandler == null)
149 _pinchGestureEventHandler += value;
151 _pinchGestureCallbackDelegate = new DetectedCallbackDelegate(OnPinchGestureDetected);
152 this.DetectedSignal().Connect(_pinchGestureCallbackDelegate);
161 if (_pinchGestureEventHandler != null)
163 this.DetectedSignal().Disconnect(_pinchGestureCallbackDelegate);
166 _pinchGestureEventHandler -= value;
171 private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
173 DetectedEventArgs e = new DetectedEventArgs();
175 // Populate all members of "e" (DetectedEventArgs) with real data
176 e.View = Registry.GetManagedBaseHandleFromNativePtr(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);
188 internal static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
190 PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196 /// Creates an initialized PinchGestureDetector.
198 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
199 [EditorBrowsable(EditorBrowsableState.Never)]
200 public PinchGestureDetector() : this(NDalicPINVOKE.PinchGestureDetector_New(), true)
202 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206 internal new static PinchGestureDetector DownCast(BaseHandle handle)
208 PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
214 /// The copy constructor.
216 /// <param name="handle">A reference to the copied handle</param>
217 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
218 [EditorBrowsable(EditorBrowsableState.Never)]
219 public PinchGestureDetector(PinchGestureDetector handle) : this(NDalicPINVOKE.new_PinchGestureDetector__SWIG_1(PinchGestureDetector.getCPtr(handle)), true)
221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224 internal PinchGestureDetector Assign(PinchGestureDetector rhs)
226 PinchGestureDetector ret = new PinchGestureDetector(NDalicPINVOKE.PinchGestureDetector_Assign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 internal PinchGestureDetectedSignal DetectedSignal()
233 PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(NDalicPINVOKE.PinchGestureDetector_DetectedSignal(swigCPtr), false);
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();