[NUI] Add fade transition
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Navigation / Page.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 using System;
18 using System.ComponentModel;
19
20 namespace Tizen.NUI.Components
21 {
22     /// <summary>
23     /// PageAppearingEventArgs is a class to record page appearing event arguments which will be sent to user.
24     /// </summary>
25     [EditorBrowsable(EditorBrowsableState.Never)]
26     public class PageAppearingEventArgs : EventArgs
27     {
28     }
29
30     /// <summary>
31     /// PageDisappearingEventArgs is a class to record page disappearing event arguments which will be sent to user.
32     /// </summary>
33     [EditorBrowsable(EditorBrowsableState.Never)]
34     public class PageDisappearingEventArgs : EventArgs
35     {
36     }
37
38     /// <summary>
39     /// PageAppearedEventArgs is a class to record page appeared event arguments which will be sent to user.
40     /// </summary>
41     [EditorBrowsable(EditorBrowsableState.Never)]
42     public class PageAppearedEventArgs : EventArgs
43     {
44     }
45
46     /// <summary>
47     /// PageDisappearedEventArgs is a class to record page disappeared event arguments which will be sent to user.
48     /// </summary>
49     [EditorBrowsable(EditorBrowsableState.Never)]
50     public class PageDisappearedEventArgs : EventArgs
51     {
52     }
53
54     /// <summary>
55     /// The Page class is a class which is an element of navigation.
56     /// </summary>
57     /// <since_tizen> 9 </since_tizen>
58     public abstract class Page : Control
59     {
60         private const int DefaultTransitionDuration = 500;
61
62         private Navigator navigator = null;
63
64         // Default transition is Fade.
65         private TransitionBase appearingTransition = new Fade()
66         {
67             TimePeriod = new TimePeriod(DefaultTransitionDuration),
68             AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
69         };
70
71         private TransitionBase disappearingTransition = new Fade()
72         {
73             TimePeriod = new TimePeriod(DefaultTransitionDuration),
74             AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
75         };
76
77         /// <summary>
78         /// Creates a new instance of a Page.
79         /// </summary>
80         /// <since_tizen> 9 </since_tizen>
81         public Page() : base()
82         {
83         }
84
85         /// <summary>
86         /// Navigator which has pushed the Page into its stack.
87         /// If this Page has not been pushed into any Navigator, then Navigator is null.
88         /// </summary>
89         /// <since_tizen> 9 </since_tizen>
90         public Navigator Navigator
91         {
92             get
93             {
94                 return navigator;
95             }
96             internal set
97             {
98                 if (navigator == value)
99                 {
100                     return;
101                 }
102
103                 navigator = value;
104             }
105         }
106
107         /// <summary>
108         /// Transition properties for the transition of Views in this page during this page is pushed to Navigator.
109         /// </summary>
110         [EditorBrowsable(EditorBrowsableState.Never)]
111         public TransitionBase AppearingTransition
112         {
113             set
114             {
115                 appearingTransition = value;
116             }
117             get
118             {
119                 return appearingTransition;
120             }
121         }
122
123         /// <summary>
124         /// Transition properties for the transition of Views in this page during this page is popped from Navigator.
125         /// </summary>
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         public TransitionBase DisappearingTransition
128         {
129             set
130             {
131                 disappearingTransition = value;
132             }
133             get
134             {
135                 return disappearingTransition;
136             }
137         }
138
139         /// <summary>
140         /// An event for the page appearing signal which can be used to subscribe or unsubscribe the event handler provided by the user.
141         /// </summary>
142         [EditorBrowsable(EditorBrowsableState.Never)]
143         public event EventHandler<PageAppearingEventArgs> Appearing;
144
145         /// <summary>
146         /// An event for the page disappearing signal which can be used to subscribe or unsubscribe the event handler provided by the user.
147         /// </summary>
148         [EditorBrowsable(EditorBrowsableState.Never)]
149         public event EventHandler<PageDisappearingEventArgs> Disappearing;
150
151         /// <summary>
152         /// An event for the page appeared signal which can be used to subscribe or unsubscribe the event handler provided by the user.
153         /// </summary>
154         [EditorBrowsable(EditorBrowsableState.Never)]
155         public event EventHandler<PageAppearedEventArgs> Appeared;
156
157         /// <summary>
158         /// An event for the page disappeared signal which can be used to subscribe or unsubscribe the event handler provided by the user.
159         /// </summary>
160         [EditorBrowsable(EditorBrowsableState.Never)]
161         public event EventHandler<PageDisappearedEventArgs> Disappeared;
162
163         internal void InvokeAppearing()
164         {
165             Appearing?.Invoke(this, new PageAppearingEventArgs());
166         }
167
168         internal void InvokeDisappearing()
169         {
170             Disappearing?.Invoke(this, new PageDisappearingEventArgs());
171         }
172
173         internal void InvokeAppeared()
174         {
175             Appeared?.Invoke(this, new PageAppearedEventArgs());
176         }
177
178         internal void InvokeDisappeared()
179         {
180             Disappeared?.Invoke(this, new PageDisappearedEventArgs());
181         }
182     }
183 }