[NUI] Refactor dispose pattern to reduce duplication (#1112)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / CubeTransitionEffect.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
18 using System;
19 using System.Runtime.InteropServices;
20 using Tizen.NUI.BaseComponents;
21 using System.ComponentModel;
22
23 namespace Tizen.NUI
24 {
25     /// <summary>
26     /// Cube Transition Effect base class, used to apply custom effects to a
27     /// Cube Transition instance.
28     /// </summary>
29     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
30     [EditorBrowsable(EditorBrowsableState.Never)]
31     public class CubeTransitionEffect : View
32     {
33         private EventHandler<TransitionCompletedEventArgs> _transitionCompletedEventHandler;
34         private TransitionCompletedCallbackDelegate _transitionCompletedCallbackDelegate;
35
36         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
37         private delegate void TransitionCompletedCallbackDelegate(IntPtr cubeTransition, IntPtr cubeTexture);
38
39         /// <summary>
40         /// The constructor.
41         /// </summary>
42         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
43         [EditorBrowsable(EditorBrowsableState.Never)]
44         public CubeTransitionEffect() : this(Interop.CubeTransitionEffect.new_CubeTransitionEffect(), true)
45         {
46             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
47         }
48
49         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CubeTransitionEffect obj)
50         {
51             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
52         }
53
54         internal CubeTransitionEffect(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.CubeTransitionEffect.CubeTransitionEffect_SWIGUpcast(cPtr), cMemoryOwn)
55         {
56         }
57
58         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
59         [EditorBrowsable(EditorBrowsableState.Never)]
60         public void SetTransitionDuration(float duration)
61         {
62             Interop.CubeTransitionEffect.CubeTransitionEffect_SetTransitionDuration(swigCPtr, duration);
63             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
64         }
65
66         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
67         [EditorBrowsable(EditorBrowsableState.Never)]
68         public float GetTransitionDuration()
69         {
70             float result = Interop.CubeTransitionEffect.CubeTransitionEffect_GetTransitionDuration(swigCPtr);
71             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72             return result;
73         }
74
75         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
76         [EditorBrowsable(EditorBrowsableState.Never)]
77         public void SetCubeDisplacement(float displacement)
78         {
79             Interop.CubeTransitionEffect.CubeTransitionEffect_SetCubeDisplacement(swigCPtr, displacement);
80             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81         }
82
83         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
84         [EditorBrowsable(EditorBrowsableState.Never)]
85         public float GetCubeDisplacement()
86         {
87             float result = Interop.CubeTransitionEffect.CubeTransitionEffect_GetCubeDisplacement(swigCPtr);
88             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89             return result;
90         }
91
92         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
93         [EditorBrowsable(EditorBrowsableState.Never)]
94         public bool IsTransitioning()
95         {
96             bool result = Interop.CubeTransitionEffect.CubeTransitionEffect_IsTransitioning(swigCPtr);
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98             return result;
99         }
100
101         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
102         [EditorBrowsable(EditorBrowsableState.Never)]
103         public void SetCurrentTexture(Texture texture)
104         {
105             Interop.CubeTransitionEffect.CubeTransitionEffect_SetCurrentTexture(swigCPtr, Texture.getCPtr(texture));
106             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
107         }
108
109         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
110         [EditorBrowsable(EditorBrowsableState.Never)]
111         public void SetTargetTexture(Texture texture)
112         {
113             Interop.CubeTransitionEffect.CubeTransitionEffect_SetTargetTexture(swigCPtr, Texture.getCPtr(texture));
114             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115         }
116
117         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
118         [EditorBrowsable(EditorBrowsableState.Never)]
119         public void StartTransition(bool toNextImage = true)
120         {
121             Interop.CubeTransitionEffect.CubeTransitionEffect_StartTransition__SWIG1(swigCPtr, toNextImage);
122             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123         }
124
125         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         public void StartTransition(Vector2 panPosition, Vector2 panDisplacement)
128         {
129             Interop.CubeTransitionEffect.CubeTransitionEffect_StartTransition__SWIG2(swigCPtr, Vector2.getCPtr(panPosition), Vector2.getCPtr(panDisplacement));
130             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131         }
132
133         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
134         [EditorBrowsable(EditorBrowsableState.Never)]
135         public void PauseTransition()
136         {
137             Interop.CubeTransitionEffect.CubeTransitionEffect_PauseTransition(swigCPtr);
138             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139         }
140
141         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
142         [EditorBrowsable(EditorBrowsableState.Never)]
143         public void ResumeTransition()
144         {
145             Interop.CubeTransitionEffect.CubeTransitionEffect_ResumeTransition(swigCPtr);
146             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147         }
148
149         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
150         [EditorBrowsable(EditorBrowsableState.Never)]
151         public void StopTransition()
152         {
153             Interop.CubeTransitionEffect.CubeTransitionEffect_StopTransition(swigCPtr);
154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155         }
156
157         CubeTransitionEffectSignal TransitionCompletedSignal()
158         {
159             CubeTransitionEffectSignal ret = new CubeTransitionEffectSignal(Interop.CubeTransitionEffect.CubeTransitionEffect_TransitionCompletedSignal(swigCPtr), false);
160             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161             return ret;
162         }
163
164         /// <summary>
165         /// The TransitionCompleted event.
166         /// </summary>
167         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
168         [EditorBrowsable(EditorBrowsableState.Never)]
169         public event EventHandler<TransitionCompletedEventArgs> TransitionCompleted
170         {
171             add
172             {
173                 if (_transitionCompletedEventHandler == null)
174                 {
175                     _transitionCompletedCallbackDelegate = (OnTransitionCompleted);
176                     TransitionCompletedSignal().Connect(_transitionCompletedCallbackDelegate);
177                 }
178                 _transitionCompletedEventHandler += value;
179             }
180             remove
181             {
182                 _transitionCompletedEventHandler -= value;
183                 if (_transitionCompletedEventHandler == null && TransitionCompletedSignal().Empty() == false)
184                 {
185                     TransitionCompletedSignal().Disconnect(_transitionCompletedCallbackDelegate);
186                 }
187             }
188         }
189
190         private void OnTransitionCompleted(IntPtr cubeTransition, IntPtr cubeTexture)
191         {
192             TransitionCompletedEventArgs e = new TransitionCompletedEventArgs();
193
194             // Populate all members of "e" (TransitionCompletedEventArgs) with real data
195             //e.CubeTransitionEffect = Registry.GetManagedBaseHandleFromNativePtr(cubeTransition) as CubeTransitionEffect;
196
197             if (_transitionCompletedEventHandler != null)
198             {
199                 //here we send all data to user event handlers
200                 _transitionCompletedEventHandler(this, e);
201             }
202         }
203
204         /// This will not be public opened.
205         [EditorBrowsable(EditorBrowsableState.Never)]
206         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
207         {
208             Interop.CubeTransitionEffect.delete_CubeTransitionEffect(swigCPtr);
209         }
210
211         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
212         [EditorBrowsable(EditorBrowsableState.Never)]
213         public class TransitionCompletedEventArgs : EventArgs
214         {
215             private CubeTransitionEffect _cubeTransitionEffect;
216             private Texture _cubeTransitonTexture;
217
218             /// <summary>
219             /// CubeTransitionEffect.
220             /// </summary>
221             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
222             [EditorBrowsable(EditorBrowsableState.Never)]
223             public CubeTransitionEffect CubeTransitionEffect
224             {
225                 get
226                 {
227                     return _cubeTransitionEffect;
228                 }
229                 set
230                 {
231                     _cubeTransitionEffect = value;
232                 }
233             }
234
235             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
236             [EditorBrowsable(EditorBrowsableState.Never)]
237             public Texture CubeTransitonTexture
238             {
239                 get
240                 {
241                     return _cubeTransitonTexture;
242                 }
243                 set
244                 {
245                     _cubeTransitonTexture = value;
246                 }
247             }
248         }
249     }
250
251     internal class CubeTransitionEffectSignal : Disposable
252     {
253
254         internal CubeTransitionEffectSignal(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
255         {
256         }
257
258         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CubeTransitionEffectSignal obj)
259         {
260             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
261         }
262
263         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
264         [EditorBrowsable(EditorBrowsableState.Never)]
265         public bool Empty()
266         {
267             bool ret = Interop.CubeTransitionEffect.CubeTransitionEffectSignal_Empty(swigCPtr);
268             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269             return ret;
270         }
271
272         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
273         [EditorBrowsable(EditorBrowsableState.Never)]
274         public uint GetConnectionCount()
275         {
276             uint ret = Interop.CubeTransitionEffect.CubeTransitionEffectSignal_GetConnectionCount(swigCPtr);
277             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278             return ret;
279         }
280
281         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
282         [EditorBrowsable(EditorBrowsableState.Never)]
283         public void Connect(System.Delegate func)
284         {
285             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
286             {
287                 Interop.CubeTransitionEffect.CubeTransitionEffectSignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
288                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289             }
290         }
291
292         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
293         [EditorBrowsable(EditorBrowsableState.Never)]
294         public void Disconnect(System.Delegate func)
295         {
296             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
297             {
298                 Interop.CubeTransitionEffect.CubeTransitionEffectSignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
299                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300             }
301         }
302
303         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
304         [EditorBrowsable(EditorBrowsableState.Never)]
305         public void Emit(CubeTransitionEffect arg)
306         {
307             Interop.TextField.TextFieldSignal_Emit(swigCPtr, CubeTransitionEffect.getCPtr(arg));
308             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309         }
310
311         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
312         [EditorBrowsable(EditorBrowsableState.Never)]
313         public CubeTransitionEffectSignal() : this(Interop.CubeTransitionEffect.new_CubeTransitionEffectSignal(), true)
314         {
315             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316         }
317
318         /// This will be public opened.
319         [EditorBrowsable(EditorBrowsableState.Never)]
320         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
321         {
322             Interop.CubeTransitionEffect.delete_CubeTransitionEffectSignal(swigCPtr);
323         }
324     }
325
326     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
327     [EditorBrowsable(EditorBrowsableState.Never)]
328     public class CubeTransitionWaveEffect : CubeTransitionEffect
329     {
330
331         /// <summary>
332         /// The constructor.
333         /// </summary>
334         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
335         [EditorBrowsable(EditorBrowsableState.Never)]
336         public CubeTransitionWaveEffect(uint numRows, uint numColumns) : this(Interop.CubeTransitionWaveEffect.CubeTransitionWaveEffect_New(numRows, numColumns), true)
337         {
338             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339         }
340
341         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CubeTransitionWaveEffect obj)
342         {
343             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
344         }
345
346         internal CubeTransitionWaveEffect(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.CubeTransitionWaveEffect.CubeTransitionWaveEffect_SWIGUpcast(cPtr), cMemoryOwn)
347         {
348         }
349
350         /// This will be public opened.
351         [EditorBrowsable(EditorBrowsableState.Never)]
352         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
353         {
354             Interop.CubeTransitionWaveEffect.delete_CubeTransitionWaveEffect(swigCPtr);
355         }
356     }
357
358     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
359     [EditorBrowsable(EditorBrowsableState.Never)]
360     public class CubeTransitionCrossEffect : CubeTransitionEffect
361     {
362
363         /// <summary>
364         /// The constructor.
365         /// </summary>
366         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
367         [EditorBrowsable(EditorBrowsableState.Never)]
368         public CubeTransitionCrossEffect(uint numRows, uint numColumns) : this(Interop.CubeTransitionCrossEffect.CubeTransitionCrossEffect_New(numRows, numColumns), true)
369         {
370             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
371         }
372
373         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CubeTransitionCrossEffect obj)
374         {
375             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
376         }
377
378         internal CubeTransitionCrossEffect(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.CubeTransitionCrossEffect.CubeTransitionCrossEffect_SWIGUpcast(cPtr), cMemoryOwn)
379         {
380         }
381
382         /// This will not be public opened.
383         [EditorBrowsable(EditorBrowsableState.Never)]
384         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
385         {
386             Interop.CubeTransitionCrossEffect.delete_CubeTransitionCrossEffect(swigCPtr);
387         }
388     }
389
390     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
391     [EditorBrowsable(EditorBrowsableState.Never)]
392     public class CubeTransitionFoldEffect : CubeTransitionEffect
393     {
394
395         /// <summary>
396         /// The constructor.
397         /// </summary>
398         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
399         [EditorBrowsable(EditorBrowsableState.Never)]
400         public CubeTransitionFoldEffect(uint numRows, uint numColumns) : this(Interop.CubeTransitionFoldEffect.CubeTransitionFoldEffect_New(numRows, numColumns), true)
401         {
402             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
403         }
404
405         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CubeTransitionFoldEffect obj)
406         {
407             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
408         }
409
410         internal CubeTransitionFoldEffect(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.CubeTransitionWaveEffect.CubeTransitionWaveEffect_SWIGUpcast(cPtr), cMemoryOwn)
411         {
412         }
413
414         /// This will not be public opened.
415         [EditorBrowsable(EditorBrowsableState.Never)]
416         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
417         {
418             Interop.CubeTransitionFoldEffect.delete_CubeTransitionFoldEffect(swigCPtr);
419         }
420     }
421 }