2 * Copyright (c) 2021 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.ComponentModel;
19 using Tizen.Applications;
20 using Tizen.NUI.BaseComponents;
25 /// This TransitionOptions class is a class to control Transition motion.
26 /// This class includes multiple options for the Transition.
27 /// NUI supports a kind of Transitions such as App transition, Page transition, and so on.
28 /// Some of options could be used only for the App transition or Page transition, but others could be used for multiple purpose.
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;
37 private bool enableTransition = false;
38 private Window mainWindow;
39 private View animatedTarget;
42 /// Initializes the TransitionOptions class.
44 /// <param name="window">The window instance of NUI Window</param>
45 [EditorBrowsable(EditorBrowsableState.Never)]
46 public TransitionOptions(Window window)
52 /// Initializes the TransitionOptions class.
54 [EditorBrowsable(EditorBrowsableState.Never)]
55 public TransitionOptions()
60 /// Set animated view of seamless animation.
62 [EditorBrowsable(EditorBrowsableState.Never)]
63 public View AnimatedTarget
67 return animatedTarget;
71 animatedTarget = value;
76 /// Gets or sets transition enable
78 [EditorBrowsable(EditorBrowsableState.Never)]
79 public bool EnableTransition
83 return enableTransition;
90 frameBroker = new DefaultFrameBroker(mainWindow);
91 frameBroker.mainView = animatedTarget;
92 frameBroker.AnimationInitialized += FrameBroker_TransitionAnimationInitialized;
93 frameBroker.AnimationFinished += FrameBroker_TransitionAnimationFinished;
96 enableTransition = value;
100 private void EnableProvider()
102 frameProvider = new FrameProvider(mainWindow);
103 frameProvider.Shown += FrameProvider_Shown;
104 frameProvider.Hidden += FrameProvider_Hidden;
108 /// During the Page transition, if two Views each of on the old top Page
109 /// and new top Page have same TransitionTag, the View on the old top Page
110 /// will be transition to the one of new top Page.
112 [EditorBrowsable(EditorBrowsableState.Never)]
113 public string TransitionTag { set; get; } = null;
116 /// A View could be transition with its child Views or without them.
117 /// Default value is false
119 [EditorBrowsable(EditorBrowsableState.Never)]
120 public bool TransitionWithChild { set; get; } = false;
123 /// Gets or sets the forward animation of launching
125 [EditorBrowsable(EditorBrowsableState.Never)]
126 public TransitionAnimation ForwardAnimation
130 return frameBroker?.ForwardAnimation;
134 if (frameBroker != null)
136 frameBroker.ForwardAnimation = value;
142 /// Gets or sets the backward animation of launching
144 [EditorBrowsable(EditorBrowsableState.Never)]
145 public TransitionAnimation BackwardAnimation
150 return frameBroker?.BackwardAnimation;
154 if (frameBroker != null)
156 frameBroker.BackwardAnimation = value;
162 /// Emits the event when the animation is started.
164 [EditorBrowsable(EditorBrowsableState.Never)]
165 public delegate void AnimationEventHandler(bool direction);
168 /// Emits the event when the animation is started.
170 [EditorBrowsable(EditorBrowsableState.Never)]
171 public event AnimationEventHandler AnimationInitialized;
174 /// Emits the event when the animation is finished.
176 [EditorBrowsable(EditorBrowsableState.Never)]
177 public event AnimationEventHandler AnimationFinished;
179 private void FrameBroker_TransitionAnimationFinished(bool direction)
181 AnimationFinished?.Invoke(direction);
184 private void FrameBroker_TransitionAnimationInitialized(bool direction)
186 AnimationInitialized?.Invoke(direction);
190 /// Occurs whenever the window is shown on caller application.
192 [EditorBrowsable(EditorBrowsableState.Never)]
193 public event EventHandler CallerScreenShown;
196 /// Occurs whenever the window is hidden on caller application.
198 [EditorBrowsable(EditorBrowsableState.Never)]
199 public event EventHandler CallerScreenHidden;
201 private void FrameProvider_Shown(object sender, EventArgs e)
203 Bundle bundle = new Bundle();
204 //Set information of shared object
205 frameProvider?.NotifyShowStatus(bundle);
207 CallerScreenShown?.Invoke(this, e);
212 private void FrameProvider_Hidden(object sender, EventArgs e)
214 Bundle bundle = new Bundle();
215 //Set information of shared object
216 frameProvider?.NotifyHideStatus(bundle);
218 CallerScreenHidden?.Invoke(this, e);
223 internal void SendLaunchRequest(AppControl appControl)
225 this.frameBroker.SendLaunchRequest(appControl, true);
229 /// Hidden API (Inhouse API).
232 /// <param name="disposing"></param>
233 [EditorBrowsable(EditorBrowsableState.Never)]
234 protected virtual void Dispose(bool disposing)
238 if (frameBroker != null)
240 frameBroker.Dispose();
243 if (frameProvider != null)
245 frameProvider.Dispose();
252 /// Dispose for IDisposable pattern
254 [EditorBrowsable(EditorBrowsableState.Never)]
255 public void Dispose()
258 System.GC.SuppressFinalize(this);