2 * Copyright(c) 2021 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 in a circular motion.
27 /// This will be made public in the next tizen release after an ACR is done. Till then, it needs to be hidden as an inhouse API.
28 [EditorBrowsable(EditorBrowsableState.Never)]
29 public class RotationGestureDetector : GestureDetector
32 /// Creates an initialized RotationGestureDetector.
34 /// This will be made public in the next tizen release after an ACR is done. Till then, it needs to be hidden as an inhouse API.
35 [EditorBrowsable(EditorBrowsableState.Never)]
36 public RotationGestureDetector() : this(Interop.RotationGesture.RotationGestureDetectorNew(), true)
38 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
43 /// The copy constructor.
45 /// <param name="handle">A reference to the copied handle</param>
46 /// This will be made public in the next tizen release after an ACR is done. Till then, it needs to be hidden as an inhouse API.
47 [EditorBrowsable(EditorBrowsableState.Never)]
48 public RotationGestureDetector(RotationGestureDetector handle) : this(Interop.RotationGesture.NewRotationGestureDetector(RotationGestureDetector.getCPtr(handle)), true)
50 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
53 internal RotationGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.RotationGesture.RotationGestureDetectorUpcast(cPtr), cMemoryOwn)
57 private DaliEventHandler<object, DetectedEventArgs> detectedEventHandler;
58 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
59 private delegate void DetectedCallbackType(IntPtr actor, IntPtr rotationGesture);
60 private DetectedCallbackType detectedCallback;
63 /// This signal is emitted when the specified rotation is detected on the attached view.
65 /// This will be made public in the next tizen release after an ACR is done. Till then, it needs to be hidden as an inhouse API.
66 [EditorBrowsable(EditorBrowsableState.Never)]
67 public event DaliEventHandler<object, DetectedEventArgs> Detected
71 if (detectedEventHandler == null)
73 detectedCallback = OnRotationGestureDetected;
74 DetectedSignal().Connect(detectedCallback);
77 detectedEventHandler += value;
82 detectedEventHandler -= value;
84 if (detectedEventHandler == null && DetectedSignal().Empty() == false)
86 DetectedSignal().Disconnect(detectedCallback);
92 internal static RotationGestureDetector GetRotationGestureDetectorFromPtr(global::System.IntPtr cPtr)
94 RotationGestureDetector ret = new RotationGestureDetector(cPtr, false);
95 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99 internal new static RotationGestureDetector DownCast(BaseHandle handle)
101 RotationGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as RotationGestureDetector;
102 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RotationGestureDetector obj)
108 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
111 internal RotationGestureDetector Assign(RotationGestureDetector rhs)
113 RotationGestureDetector ret = new RotationGestureDetector(Interop.RotationGesture.RotationGestureDetectorAssign(SwigCPtr, RotationGestureDetector.getCPtr(rhs)), false);
114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 internal RotationGestureDetectedSignal DetectedSignal()
120 RotationGestureDetectedSignal ret = new RotationGestureDetectedSignal(Interop.RotationGesture.RotationGestureDetectorDetectedSignal(SwigCPtr), false);
121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 /// This will not be public opened.
126 [EditorBrowsable(EditorBrowsableState.Never)]
127 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
129 if (detectedCallback != null)
131 DetectedSignal().Disconnect(detectedCallback);
134 Interop.RotationGesture.DeleteRotationGestureDetector(swigCPtr);
137 private void OnRotationGestureDetected(IntPtr actor, IntPtr rotationGesture)
139 if (detectedEventHandler != null)
141 DetectedEventArgs e = new DetectedEventArgs();
143 // Populate all members of "e" (DetectedEventArgs) with real data.
144 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
147 e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
150 e.RotationGesture = Tizen.NUI.RotationGesture.GetRotationGestureFromPtr(rotationGesture);
151 //Here we send all data to user event handlers.
152 detectedEventHandler(this, e);
157 /// Event arguments that passed via the RotationGestureEvent signal.
159 /// <since_tizen> 5 </since_tizen>
160 /// This will be made public in the next tizen release after an ACR is done. Till then, it needs to be hidden as an inhouse API.
161 [EditorBrowsable(EditorBrowsableState.Never)]
162 public class DetectedEventArgs : EventArgs
165 private RotationGesture rotationGesture;
168 /// The attached view.
170 /// <since_tizen> 5 </since_tizen>
171 /// This will be made public in the next tizen release after an ACR is done. Till then, it needs to be hidden as an inhouse API.
172 [EditorBrowsable(EditorBrowsableState.Never)]
186 /// The RotationGesture.
188 /// <since_tizen> 5 </since_tizen>
189 /// This will be made public in the next tizen release after an ACR is done. Till then, it needs to be hidden as an inhouse API.
190 [EditorBrowsable(EditorBrowsableState.Never)]
191 public RotationGesture RotationGesture
195 return rotationGesture;
199 rotationGesture = value;