[NUI] Make ReleaseSwigCPtr didn't check HasBody()
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Transition / TransitionItem.cs
1 /*
2  * Copyright(c) 2021 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.ComponentModel;
20 using Tizen.NUI.BaseComponents;
21
22 namespace Tizen.NUI
23 {
24     /// <summary>
25     /// TransitionItem is an object to set Transition of View pair those have same TransitionTag.
26     /// TransitionItem object is required for each View pair and this is added to the TransitionSet to play.
27     /// </summary>
28     internal class TransitionItem : TransitionItemBase
29     {
30         /// <summary>
31         /// Creates an initialized transition.<br />
32         /// </summary>
33         /// <remarks>DurationmSeconds must be greater than zero.</remarks>
34         public TransitionItem(View source, View destination, bool useDestinationTarget, TimePeriod timePeriod, AlphaFunction alphaFunction) : this(Interop.TransitionItem.New(source.SwigCPtr, destination.SwigCPtr, useDestinationTarget, timePeriod.SwigCPtr), true)
35         {
36             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
37             AlphaFunction = alphaFunction;
38         }
39
40         internal TransitionItem(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
41         {
42         }
43
44         internal TransitionItem(TransitionItem handle) : this(Interop.TransitionItem.NewTransitionItem(TransitionItem.getCPtr(handle)), true)
45         {
46             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
47         }
48
49         internal TransitionItem Assign(TransitionItem rhs)
50         {
51             TransitionItem ret = new TransitionItem(Interop.TransitionItem.Assign(SwigCPtr, TransitionItem.getCPtr(rhs)), false);
52             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
53             return ret;
54         }
55
56         /// <summary>
57         /// To make transition instance be disposed.
58         /// </summary>
59         protected override void Dispose(DisposeTypes type)
60         {
61             if (disposed)
62             {
63                 return;
64             }
65             base.Dispose(type);
66         }
67
68         /// This will not be public opened.
69         [EditorBrowsable(EditorBrowsableState.Never)]
70         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
71         {
72             if (swigCPtr.Handle == IntPtr.Zero || Disposed)
73             {
74                 Tizen.Log.Fatal("NUI", $"[ERROR] TransitionItem ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} Disposed={Disposed}");
75                 return;
76             }
77             Interop.TransitionItem.Delete(swigCPtr);
78         }
79     }
80 }