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