[NUI] remove "_" and refactoring naming to pascal case.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / PinchGestureDetector.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.Runtime.InteropServices;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
21
22 namespace Tizen.NUI
23 {
24     /// <summary>
25     /// It tries to detect when the user moves two touch points towards or away from each other.
26     /// </summary>
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
30     {
31         /// <summary>
32         /// Creates an initialized PinchGestureDetector.
33         /// </summary>
34         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
35         [EditorBrowsable(EditorBrowsableState.Never)]
36         public PinchGestureDetector() : this(Interop.PinchGesture.PinchGestureDetectorNew(), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39
40         }
41
42         /// <summary>
43         /// The copy constructor.
44         /// </summary>
45         /// <param name="handle">A reference to the copied handle</param>
46         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
47         [EditorBrowsable(EditorBrowsableState.Never)]
48         public PinchGestureDetector(PinchGestureDetector handle) : this(Interop.PinchGesture.NewPinchGestureDetector(PinchGestureDetector.getCPtr(handle)), true)
49         {
50             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51         }
52
53         internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PinchGesture.PinchGestureDetectorUpcast(cPtr), cMemoryOwn)
54         {
55         }
56
57         private DaliEventHandler<object, DetectedEventArgs> _detectedEventHandler;
58         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
59         private delegate void DetectedCallbackType(IntPtr actor, IntPtr pinchGesture);
60         private DetectedCallbackType _detectedCallback;
61
62         /// <summary>
63         /// This signal is emitted when the specified pinch is detected on the attached view.
64         /// </summary>
65         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         public event DaliEventHandler<object, DetectedEventArgs> Detected
68         {
69             add
70             {
71                 if (_detectedEventHandler == null)
72                 {
73                     _detectedCallback = OnPinchGestureDetected;
74                     DetectedSignal().Connect(_detectedCallback);
75                 }
76
77                 _detectedEventHandler += value;
78             }
79
80             remove
81             {
82                 _detectedEventHandler -= value;
83
84                 if (_detectedEventHandler == null && DetectedSignal().Empty() == false)
85                 {
86                     DetectedSignal().Disconnect(_detectedCallback);
87                 }
88             }
89         }
90
91
92         internal static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
93         {
94             PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
95             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
96             return ret;
97         }
98
99         internal new static PinchGestureDetector DownCast(BaseHandle handle)
100         {
101             PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
102             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
103             return ret;
104         }
105
106         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PinchGestureDetector obj)
107         {
108             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
109         }
110
111         internal PinchGestureDetector Assign(PinchGestureDetector rhs)
112         {
113             PinchGestureDetector ret = new PinchGestureDetector(Interop.PinchGesture.PinchGestureDetectorAssign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
114             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115             return ret;
116         }
117
118         internal PinchGestureDetectedSignal DetectedSignal()
119         {
120             PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(Interop.PinchGesture.PinchGestureDetectorDetectedSignal(swigCPtr), false);
121             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122             return ret;
123         }
124
125         /// This will not be public opened.
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
128         {
129             if (_detectedCallback != null)
130             {
131                 DetectedSignal().Disconnect(_detectedCallback);
132             }
133
134             Interop.PinchGesture.DeletePinchGestureDetector(swigCPtr);
135         }
136
137         private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
138         {
139             DetectedEventArgs e = new DetectedEventArgs();
140
141             // Populate all members of "e" (DetectedEventArgs) with real data.
142             e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
143             if (null == e.View)
144             {
145                 e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
146             }
147
148             e.PinchGesture = Tizen.NUI.PinchGesture.GetPinchGestureFromPtr(pinchGesture);
149
150             if (_detectedEventHandler != null)
151             {
152                 //Here we send all data to user event handlers.
153                 _detectedEventHandler(this, e);
154             }
155         }
156
157         /// <summary>
158         /// Event arguments that passed via the PinchGestureEvent signal.
159         /// </summary>
160         /// <since_tizen> 5 </since_tizen>
161         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
162         [EditorBrowsable(EditorBrowsableState.Never)]
163         public class DetectedEventArgs : EventArgs
164         {
165             private View _view;
166             private PinchGesture _pinchGesture;
167
168             /// <summary>
169             /// The attached view.
170             /// </summary>
171             /// <since_tizen> 5 </since_tizen>
172             /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
173             [EditorBrowsable(EditorBrowsableState.Never)]
174             public View View
175             {
176                 get
177                 {
178                     return _view;
179                 }
180                 set
181                 {
182                     _view = value;
183                 }
184             }
185
186             /// <summary>
187             /// The PinchGesture.
188             /// </summary>
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 PinchGesture PinchGesture
193             {
194                 get
195                 {
196                     return _pinchGesture;
197                 }
198                 set
199                 {
200                     _pinchGesture = value;
201                 }
202             }
203         }
204     }
205 }