[NUI] View Transition with page switching
[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 namespace Tizen.NUI
19 {
20     using System;
21     using System.ComponentModel;
22
23     using Tizen.NUI.BaseComponents;
24
25     /// <summary>
26     /// TransitionItem is an object to set Transition of View pair those have same TransitionTag.
27     /// TransitionItem object is required for each View pair and this is added to the TransitionSet to play.
28     /// </summary>
29     internal class TransitionItem : TransitionItemBase
30     {
31         /// <summary>
32         /// Creates an initialized transition.<br />
33         /// </summary>
34         /// <remarks>DurationmSeconds must be greater than zero.</remarks>
35         public TransitionItem(View source, View destination, TimePeriod timePeriod, AlphaFunction alphaFunction) : this(Interop.TransitionItem.New(source.SwigCPtr, destination.SwigCPtr, timePeriod.SwigCPtr), true)
36         {
37             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
38             AlphaFunction = alphaFunction;
39         }
40
41         internal TransitionItem(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
42         {
43         }
44
45         /// <summary>
46         /// Sets the source View will be shown after transition finished.
47         /// </summary>
48         public bool ShowSourceAfterFinished
49         {
50             set
51             {
52                 Interop.TransitionItem.ShowSourceAfterFinished(SwigCPtr, value);
53                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54             }
55         }
56
57         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TransitionItem obj)
58         {
59             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
60         }
61
62         internal TransitionItem(TransitionItem handle) : this(Interop.TransitionItem.NewTransitionItem(TransitionItem.getCPtr(handle)), true)
63         {
64             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
65         }
66
67         internal TransitionItem Assign(TransitionItem rhs)
68         {
69             TransitionItem ret = new TransitionItem(Interop.TransitionItem.Assign(SwigCPtr, TransitionItem.getCPtr(rhs)), false);
70             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71             return ret;
72         }
73
74         /// <summary>
75         /// To make transition instance be disposed.
76         /// </summary>
77         protected override void Dispose(DisposeTypes type)
78         {
79             if (disposed)
80             {
81                 return;
82             }
83             base.Dispose(type);
84         }
85
86         /// This will not be public opened.
87         [EditorBrowsable(EditorBrowsableState.Never)]
88         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
89         {
90             if (swigCPtr.Handle == IntPtr.Zero || this.HasBody() == false)
91             {
92                 Tizen.Log.Fatal("NUI", $"[ERROR] TransitionItem ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} HasBody={this.HasBody()}");
93                 return;
94             }
95             Interop.TransitionItem.Delete(swigCPtr);
96         }
97     }
98 }