[NUI] Add InterceptTouchEvent (#2098)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / TransitionOptions / TransitionOptions.cs
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
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.Collections.Generic;
19 using System.ComponentModel;
20 using System.Text;
21 using Tizen.Applications;
22
23 namespace Tizen.NUI
24 {
25     /// <summary>
26     /// Setting screen transition options.
27     /// </summary>
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class TransitionOptions : IDisposable
30     {
31         private FrameProvider frameProvider;
32         private DefaultFrameBroker frameBroker;
33
34         private bool enableTransition = false;
35         private Window mainWindow;
36         private string sharedId;
37
38         /// <summary>
39         /// Initializes the TransitionOptions class.
40         /// </summary>
41         /// <param name="window">The window instance of NUI Window</param>
42         [EditorBrowsable(EditorBrowsableState.Never)]
43         public TransitionOptions(Window window)
44         {
45             mainWindow = window;
46         }
47
48         /// <summary>
49         /// Gets or sets transition enable
50         /// </summary>
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public bool EnableTransition
53         {
54             get
55             {
56                 return enableTransition;
57             }
58
59             set
60             {
61                 if (value)
62                 {
63                     frameBroker = new DefaultFrameBroker(mainWindow);
64                     frameBroker.AnimationInitialized += FrameBroker_TransitionAnimationInitialized;
65                     frameBroker.AnimationFinished += FrameBroker_TransitionAnimationFinished;
66                     EnableProvider();
67                 }
68                 enableTransition = value;
69             }
70         }
71
72         private void EnableProvider()
73         {
74             frameProvider = new FrameProvider(mainWindow);
75             frameProvider.Shown += FrameProvider_Shown;
76             frameProvider.Hidden += FrameProvider_Hidden;
77         }
78
79         /// <summary>
80         /// Gets or sets the Shared object Id
81         /// </summary>
82         [EditorBrowsable(EditorBrowsableState.Never)]
83         public String SharedId
84         {
85             set
86             {
87                 sharedId = value;
88             }
89             get
90             {
91                 return sharedId;
92             }
93         }
94
95         /// <summary>
96         /// Gets or sets the forward animation of launching
97         /// </summary>
98         [EditorBrowsable(EditorBrowsableState.Never)]
99         public TransitionAnimation ForwardAnimation
100         {
101             get
102             {
103                 return frameBroker?.ForwardAnimation;
104             }
105             set
106             {
107                 if (frameBroker != null)
108                 {
109                     frameBroker.ForwardAnimation = value;
110                 }
111             }
112         }
113
114         /// <summary>
115         /// Gets or sets the backward animation of launching
116         /// </summary>
117         [EditorBrowsable(EditorBrowsableState.Never)]
118         public TransitionAnimation BackwardAnimation
119
120         {
121             get
122             {
123                 return frameBroker?.BackwardAnimation;
124             }
125             set
126             {
127                 if (frameBroker != null)
128                 {
129                     frameBroker.BackwardAnimation = value;
130                 }
131             }
132         }
133         
134         /// <summary>
135         /// Emits the event when the animation is started.
136         /// </summary>
137         [EditorBrowsable(EditorBrowsableState.Never)]
138         public event EventHandler AnimationInitialized;
139
140         /// <summary>
141         /// Emits the event when the animation is finished.
142         /// </summary>
143         [EditorBrowsable(EditorBrowsableState.Never)]
144         public event EventHandler AnimationFinished;
145
146
147         /// <summary>
148         /// Dispose for IDisposable pattern
149         /// </summary>
150         [EditorBrowsable(EditorBrowsableState.Never)]
151         public void Dispose()
152         {
153             if (frameBroker != null)
154             {
155                 frameBroker.Dispose();
156             }
157
158             if (frameProvider != null)
159             {
160                 frameProvider.Dispose();
161             }
162         }
163
164         private void FrameBroker_TransitionAnimationFinished()
165         {
166             AnimationFinished?.Invoke(this, EventArgs.Empty);
167         }
168
169         private void FrameBroker_TransitionAnimationInitialized()
170         {
171             AnimationInitialized?.Invoke(this, EventArgs.Empty);
172         }
173
174         /// <summary>
175         /// Occurs whenever the window is shown on caller application.
176         /// </summary>
177         [EditorBrowsable(EditorBrowsableState.Never)]
178         public event EventHandler CallerScreenShown;
179
180         /// <summary>
181         /// Occurs whenever the window is hidden on caller application.
182         /// </summary>
183         [EditorBrowsable(EditorBrowsableState.Never)]
184         public event EventHandler CallerScreenHidden;
185
186         private void FrameProvider_Shown(object sender, EventArgs e)
187         {
188             Bundle bundle = new Bundle();
189             //Set information of shared object
190             frameProvider?.NotifyShowStatus(bundle);
191
192             CallerScreenShown?.Invoke(this, e);
193         }
194
195         private void FrameProvider_Hidden(object sender, EventArgs e)
196         {
197             Bundle bundle = new Bundle();
198             //Set information of shared object
199             frameProvider?.NotifyHideStatus(bundle);
200
201             CallerScreenHidden?.Invoke(this, e);
202         }
203
204         internal void SendLaunchRequest(AppControl appControl)
205         {
206             this.frameBroker.SendLaunchRequest(appControl, false);
207         }
208     }
209 }