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.
21 using System.ComponentModel;
22 using Tizen.NUI.BaseComponents;
24 internal class TransitionItemBase : BaseHandle
27 /// Creates an initialized TransitionItemBase.<br />
29 public TransitionItemBase(View target, bool isEntering, TimePeriod timePeriod, AlphaFunction alphaFunction) : this(Interop.TransitionItemBase.New(/*target.SwigCPtr, isEntering, timePeriod.SwigCPtr*/), true)
31 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
32 AlphaFunction = alphaFunction;
35 internal TransitionItemBase(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
40 /// Gets or sets the duration in milliseconds of the transition.
46 Interop.TransitionItemBase.SetDuration(SwigCPtr, MilliSecondsToSeconds(value));
47 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51 float ret = Interop.TransitionItemBase.GetDuration(SwigCPtr);
52 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
53 return SecondsToMilliSeconds(ret);
58 /// Gets or sets the delay in milliseconds of the transition.
64 Interop.TransitionItemBase.SetDelay(SwigCPtr, MilliSecondsToSeconds(value));
65 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
69 float ret = Interop.TransitionItemBase.GetDelay(SwigCPtr);
70 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71 return SecondsToMilliSeconds(ret);
76 /// Gets or sets the TimePeriod
78 public TimePeriod TimePeriod
82 Interop.TransitionItemBase.SetTimePeriod(SwigCPtr, value.SwigCPtr);
83 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88 /// Gets or sets the AlphaFunction
90 public AlphaFunction AlphaFunction
94 Interop.TransitionItemBase.SetAlphaFunction(SwigCPtr, value.SwigCPtr);
95 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99 AlphaFunction ret = new AlphaFunction(Interop.TransitionItemBase.GetAlphaFunction(SwigCPtr), true);
100 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106 /// Gets or sets whether the View moves with child or not.
108 public bool TransitionWithChild
112 Interop.TransitionItemBase.TransitionWithChild(SwigCPtr, value);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 /// Downcasts a handle to TransitionItemBase handle.<br />
119 /// If handle points to an TransitionItemBase object, the downcast produces a valid handle.<br />
120 /// If not, the returned handle is left uninitialized.<br />
122 /// <param name="handle">Handle to an object.</param>
123 /// <returns>Handle to an TransitionItemBase object or an uninitialized handle.</returns>
124 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
125 public static TransitionItemBase DownCast(BaseHandle handle)
129 throw new ArgumentNullException(nameof(handle));
131 TransitionItemBase ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TransitionItemBase;
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TransitionItemBase obj)
138 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
141 internal TransitionItemBase(TransitionItemBase handle) : this(Interop.TransitionItemBase.NewTransitionItemBase(TransitionItemBase.getCPtr(handle)), true)
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146 internal TransitionItemBase Assign(TransitionItemBase rhs)
148 TransitionItemBase ret = new TransitionItemBase(Interop.TransitionItemBase.Assign(SwigCPtr, TransitionItemBase.getCPtr(rhs)), false);
149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154 /// To make TransitionItemBase instance be disposed.
156 protected override void Dispose(DisposeTypes type)
165 /// This will not be public opened.
166 [EditorBrowsable(EditorBrowsableState.Never)]
167 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
169 if (swigCPtr.Handle == IntPtr.Zero || this.HasBody() == false)
171 Tizen.Log.Fatal("NUI", $"[ERROR] TransitionItemBase ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} HasBody={this.HasBody()}");
174 Interop.TransitionItemBase.Delete(swigCPtr);
177 private float MilliSecondsToSeconds(int millisec)
179 return (float)millisec / 1000.0f;
182 private int SecondsToMilliSeconds(float sec)
184 return (int)(sec * 1000);