[NUI] Make ReleaseSwigCPtr didn't check HasBody()
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Transition / TransitionItemBase.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     internal class TransitionItemBase : BaseHandle
25     {
26         private bool appearingTransition = true;
27
28         /// <summary>
29         /// Creates an initialized TransitionItemBase.<br />
30         /// </summary>
31         public TransitionItemBase(View target, bool appearingTransition, TimePeriod timePeriod, AlphaFunction alphaFunction) : this(Interop.TransitionItemBase.New(), true)
32         {
33             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
34             
35             AppearingTransition = appearingTransition;
36             TimePeriod = timePeriod;
37             AlphaFunction = alphaFunction;
38         }
39
40         internal TransitionItemBase(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
41         {
42         }
43
44         /// <summary>
45         /// Gets or sets the TimePeriod
46         /// </summary>
47         public TimePeriod TimePeriod
48         {
49             set
50             {
51                 Interop.TransitionItemBase.SetTimePeriod(SwigCPtr, value.SwigCPtr);
52                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
53             }
54             get
55             {
56                 TimePeriod ret = new TimePeriod(Interop.TransitionItemBase.GetTimePeriod(SwigCPtr), true);
57                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
58                 return ret;
59             }
60         }
61
62         /// <summary>
63         /// Gets or sets the AlphaFunction
64         /// </summary>
65         public AlphaFunction AlphaFunction
66         {
67             set
68             {
69                 Interop.TransitionItemBase.SetAlphaFunction(SwigCPtr, value.SwigCPtr);
70                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71             }
72             get
73             {
74                 AlphaFunction ret = new AlphaFunction(Interop.TransitionItemBase.GetAlphaFunction(SwigCPtr), true);
75                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
76                 return ret;
77             }
78         }
79
80         /// <summary>
81         /// Gets or sets whether the View moves with child or not.
82         /// </summary>
83         public virtual bool TransitionWithChild
84         {
85             set
86             {
87                 Interop.TransitionItemBase.TransitionWithChild(SwigCPtr, value);
88                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89             }
90         }
91
92         /// <summary>
93         /// Gets or sets whether this transition is appearing transition or not.
94         /// </summary>
95         public bool AppearingTransition
96         {
97             set
98             {
99                 appearingTransition = value;
100                 Interop.TransitionItemBase.SetAppearingTransition(SwigCPtr, value);
101                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102             }
103             get
104             {
105                 return appearingTransition;
106             }
107         }
108
109         /// <summary>
110         /// Downcasts a handle to TransitionItemBase handle.<br />
111         /// If handle points to an TransitionItemBase object, the downcast produces a valid handle.<br />
112         /// If not, the returned handle is left uninitialized.<br />
113         /// </summary>
114         /// <param name="handle">Handle to an object.</param>
115         /// <returns>Handle to an TransitionItemBase object or an uninitialized handle.</returns>
116         /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
117         public static TransitionItemBase DownCast(BaseHandle handle)
118         {
119             if (handle == null)
120             {
121                 throw new ArgumentNullException(nameof(handle));
122             }
123             TransitionItemBase ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TransitionItemBase;
124             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125             return ret;
126         }
127
128         internal TransitionItemBase(TransitionItemBase handle) : this(Interop.TransitionItemBase.NewTransitionItemBase(TransitionItemBase.getCPtr(handle)), true)
129         {
130             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131         }
132
133         internal TransitionItemBase Assign(TransitionItemBase rhs)
134         {
135             TransitionItemBase ret = new TransitionItemBase(Interop.TransitionItemBase.Assign(SwigCPtr, TransitionItemBase.getCPtr(rhs)), false);
136             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137             return ret;
138         }
139
140         /// <summary>
141         /// To make TransitionItemBase instance be disposed.
142         /// </summary>
143         protected override void Dispose(DisposeTypes type)
144         {
145             if (disposed)
146             {
147                 return;
148             }
149             base.Dispose(type);
150         }
151
152         /// This will not be public opened.
153         [EditorBrowsable(EditorBrowsableState.Never)]
154         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
155         {
156             if (swigCPtr.Handle == IntPtr.Zero || Disposed)
157             {
158                 Tizen.Log.Fatal("NUI", $"[ERROR] TransitionItemBase ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} Disposed={Disposed}");
159                 return;
160             }
161             Interop.TransitionItemBase.Delete(swigCPtr);
162         }
163
164         private float MilliSecondsToSeconds(int millisec)
165         {
166             return (float)millisec / 1000.0f;
167         }
168
169         private int SecondsToMilliSeconds(float sec)
170         {
171             return (int)(sec * 1000);
172         }
173     }
174 }