[NUI] Add Transition Group
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Transition / TransitionBase.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     /// TransitionBase class is a base class for all Transition.
26     /// Each Transition child classes inherits this base class.
27     /// </summary>
28     /// <remarks>
29     /// Transition changes propreties of View like Position, Scale, Orientation, and Opacity during transition.
30     /// </remarks>
31     /// <since_tizen> 9 </since_tizen>
32     public class TransitionBase : Disposable
33     {
34         private AlphaFunction alphaFunction = null;
35         private TimePeriod timePeriod = null;
36
37         /// <summary>
38         /// Create a TransitionBase
39         /// </summary>
40         /// <since_tizen> 9 </since_tizen>
41         public TransitionBase()
42         {
43         }
44
45         /// <summary>
46         /// Set/Get the alpha function for a transition.
47         /// </summary>
48         /// <since_tizen> 9 </since_tizen>
49         public AlphaFunction AlphaFunction
50         {
51             set
52             {
53                 alphaFunction = value;
54             }
55             get
56             {
57                 return alphaFunction;
58             }
59         }
60
61         /// <summary>
62         /// Set/Get time period that contains delay and duration.
63         /// </summary>
64         /// <since_tizen> 9 </since_tizen>
65         public TimePeriod TimePeriod
66         {
67             set
68             {
69                 timePeriod = value;
70             }
71             get
72             {
73                 return timePeriod;
74             }
75         }
76
77         internal TimePeriod GetTimePeriod()
78         {
79             return timePeriod ??= new TimePeriod(0);
80         }
81
82         internal AlphaFunction GetAlphaFunction()
83         {
84             return alphaFunction ??= new AlphaFunction(AlphaFunction.BuiltinFunctions.Default);
85         }
86
87         internal TransitionItemBase CreateTransition(View view, bool appearingTransition)
88         {
89             return CreateTransition(view, appearingTransition, GetTimePeriod(), GetAlphaFunction());
90         }
91
92         internal virtual TransitionItemBase CreateTransition(View view, bool appearingTransition, TimePeriod timePeriod, AlphaFunction alphaFunction)
93         {
94             return new TransitionItemBase(view, appearingTransition, timePeriod, alphaFunction);
95         }
96
97         [EditorBrowsable(EditorBrowsableState.Never)]
98         protected override void Dispose(DisposeTypes type)
99         {
100             alphaFunction?.Dispose();
101             timePeriod?.Dispose();
102             base.Dispose(type);
103         }
104     }
105 }