2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
19 using System.ComponentModel;
21 using Tizen.Applications;
22 using Tizen.NUI.BaseComponents;
27 /// Setting screen transition options.
28 /// This is used to describe the transition of NUIApplication.
30 /// <seealso cref="NUIApplication.TransitionOptions" />
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public class TransitionOptions : IDisposable
34 private bool disposed = false;
35 private FrameProvider frameProvider;
36 private DefaultFrameBroker frameBroker;
38 private bool enableTransition = false;
39 private Window mainWindow;
40 private View animatedTarget;
41 private string sharedId;
44 /// Initializes the TransitionOptions class.
46 /// <param name="window">The window instance of NUI Window</param>
47 [EditorBrowsable(EditorBrowsableState.Never)]
48 public TransitionOptions(Window window)
55 /// Set animated view of seamless animation.
57 [EditorBrowsable(EditorBrowsableState.Never)]
58 public View AnimatedTarget
62 return animatedTarget;
66 animatedTarget = value;
71 /// Gets or sets transition enable
73 [EditorBrowsable(EditorBrowsableState.Never)]
74 public bool EnableTransition
78 return enableTransition;
85 frameBroker = new DefaultFrameBroker(mainWindow);
86 frameBroker.mainView = animatedTarget;
87 frameBroker.AnimationInitialized += FrameBroker_TransitionAnimationInitialized;
88 frameBroker.AnimationFinished += FrameBroker_TransitionAnimationFinished;
91 enableTransition = value;
95 private void EnableProvider()
97 frameProvider = new FrameProvider(mainWindow);
98 frameProvider.Shown += FrameProvider_Shown;
99 frameProvider.Hidden += FrameProvider_Hidden;
103 /// Gets or sets the Shared object Id
105 [EditorBrowsable(EditorBrowsableState.Never)]
106 public String SharedId
119 /// Gets or sets the forward animation of launching
121 [EditorBrowsable(EditorBrowsableState.Never)]
122 public TransitionAnimation ForwardAnimation
126 return frameBroker?.ForwardAnimation;
130 if (frameBroker != null)
132 frameBroker.ForwardAnimation = value;
138 /// Gets or sets the backward animation of launching
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public TransitionAnimation BackwardAnimation
146 return frameBroker?.BackwardAnimation;
150 if (frameBroker != null)
152 frameBroker.BackwardAnimation = value;
158 /// Emits the event when the animation is started.
160 [EditorBrowsable(EditorBrowsableState.Never)]
161 public delegate void AnimationEventHandler(bool direction);
164 /// Emits the event when the animation is started.
166 [EditorBrowsable(EditorBrowsableState.Never)]
167 public event AnimationEventHandler AnimationInitialized;
170 /// Emits the event when the animation is finished.
172 [EditorBrowsable(EditorBrowsableState.Never)]
173 public event AnimationEventHandler AnimationFinished;
175 private void FrameBroker_TransitionAnimationFinished(bool direction)
177 AnimationFinished?.Invoke(direction);
180 private void FrameBroker_TransitionAnimationInitialized(bool direction)
182 AnimationInitialized?.Invoke(direction);
186 /// Occurs whenever the window is shown on caller application.
188 [EditorBrowsable(EditorBrowsableState.Never)]
189 public event EventHandler CallerScreenShown;
192 /// Occurs whenever the window is hidden on caller application.
194 [EditorBrowsable(EditorBrowsableState.Never)]
195 public event EventHandler CallerScreenHidden;
197 private void FrameProvider_Shown(object sender, EventArgs e)
199 Bundle bundle = new Bundle();
200 //Set information of shared object
201 frameProvider?.NotifyShowStatus(bundle);
203 CallerScreenShown?.Invoke(this, e);
208 private void FrameProvider_Hidden(object sender, EventArgs e)
210 Bundle bundle = new Bundle();
211 //Set information of shared object
212 frameProvider?.NotifyHideStatus(bundle);
214 CallerScreenHidden?.Invoke(this, e);
219 internal void SendLaunchRequest(AppControl appControl)
221 this.frameBroker.SendLaunchRequest(appControl, true);
225 /// Hidden API (Inhouse API).
228 /// <param name="disposing"></param>
229 [EditorBrowsable(EditorBrowsableState.Never)]
230 protected virtual void Dispose(bool disposing)
234 if (frameBroker != null)
236 frameBroker.Dispose();
239 if (frameProvider != null)
241 frameProvider.Dispose();
248 /// Dispose for IDisposable pattern
250 [EditorBrowsable(EditorBrowsableState.Never)]
251 public void Dispose()
254 System.GC.SuppressFinalize(this);