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
32 private DaliEventHandler<object, DetectedEventArgs> _pinchGestureEventHandler;
33 private DetectedCallbackDelegate _pinchGestureCallbackDelegate;
36 /// Creates an initialized PinchGestureDetector.
38 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
39 [EditorBrowsable(EditorBrowsableState.Never)]
40 public PinchGestureDetector() : this(Interop.PinchGesture.PinchGestureDetector_New(), true)
42 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
47 /// The copy constructor.
49 /// <param name="handle">A reference to the copied handle</param>
50 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
51 [EditorBrowsable(EditorBrowsableState.Never)]
52 public PinchGestureDetector(PinchGestureDetector handle) : this(Interop.PinchGesture.new_PinchGestureDetector__SWIG_1(PinchGestureDetector.getCPtr(handle)), true)
54 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
57 internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PinchGesture.PinchGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
61 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
62 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr pinchGesture);
65 /// This signal is emitted when the specified pinch is detected on the attached view.
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 event DaliEventHandler<object, DetectedEventArgs> Detected
75 // Restricted to only one listener
76 if (_pinchGestureEventHandler == null)
78 _pinchGestureEventHandler += value;
80 _pinchGestureCallbackDelegate = new DetectedCallbackDelegate(OnPinchGestureDetected);
81 this.DetectedSignal().Connect(_pinchGestureCallbackDelegate);
90 if (_pinchGestureEventHandler != null)
92 this.DetectedSignal().Disconnect(_pinchGestureCallbackDelegate);
95 _pinchGestureEventHandler -= value;
101 internal static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
103 PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 internal new static PinchGestureDetector DownCast(BaseHandle handle)
110 PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PinchGestureDetector obj)
117 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
120 internal PinchGestureDetector Assign(PinchGestureDetector rhs)
122 PinchGestureDetector ret = new PinchGestureDetector(Interop.PinchGesture.PinchGestureDetector_Assign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127 internal PinchGestureDetectedSignal DetectedSignal()
129 PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(Interop.PinchGesture.PinchGestureDetector_DetectedSignal(swigCPtr), false);
130 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134 /// This will not be public opened.
135 [EditorBrowsable(EditorBrowsableState.Never)]
136 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
138 Interop.PinchGesture.delete_PinchGestureDetector(swigCPtr);
141 private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
143 DetectedEventArgs e = new DetectedEventArgs();
145 // Populate all members of "e" (DetectedEventArgs) with real data.
146 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
149 e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
152 e.PinchGesture = Tizen.NUI.PinchGesture.GetPinchGestureFromPtr(pinchGesture);
154 if (_pinchGestureEventHandler != null)
156 //Here we send all data to user event handlers.
157 _pinchGestureEventHandler(this, e);
162 /// Event arguments that passed via the PinchGestureEvent signal.
164 /// <since_tizen> 5 </since_tizen>
165 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
166 [EditorBrowsable(EditorBrowsableState.Never)]
167 public class DetectedEventArgs : EventArgs
170 private PinchGesture _pinchGesture;
173 /// The attached view.
175 /// <since_tizen> 5 </since_tizen>
176 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
177 [EditorBrowsable(EditorBrowsableState.Never)]
191 /// The PinchGesture.
193 /// <since_tizen> 5 </since_tizen>
194 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
195 [EditorBrowsable(EditorBrowsableState.Never)]
196 public PinchGesture PinchGesture
200 return _pinchGesture;
204 _pinchGesture = value;