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 various kinds of Transitions such as App transition, Page transition, and so on.
29 /// <seealso cref="NUIApplication.TransitionOptions" />
30 /// <since_tizen> 9 </since_tizen>
31 public class TransitionOptions : IDisposable
33 private bool disposed = false;
34 private FrameProvider frameProvider;
35 private DefaultFrameBroker frameBroker;
36 private bool enableTransition = false;
37 private Window mainWindow;
38 private View animatedTarget;
41 /// Initializes the TransitionOptions class.
43 /// <param name="window">The window instance of NUI Window</param>
44 [EditorBrowsable(EditorBrowsableState.Never)]
45 public TransitionOptions(Window window)
51 /// Initializes the TransitionOptions class.
53 /// <since_tizen> 9 </since_tizen>
54 public TransitionOptions()
59 /// Set animated view of seamless animation.
61 [EditorBrowsable(EditorBrowsableState.Never)]
62 public View AnimatedTarget
66 return animatedTarget;
70 animatedTarget = value;
75 /// Gets or sets transition enable
77 [EditorBrowsable(EditorBrowsableState.Never)]
78 public bool EnableTransition
82 return enableTransition;
89 frameBroker = new DefaultFrameBroker(mainWindow);
90 frameBroker.mainView = animatedTarget;
91 frameBroker.AnimationInitialized += FrameBroker_TransitionAnimationInitialized;
92 frameBroker.AnimationFinished += FrameBroker_TransitionAnimationFinished;
95 enableTransition = value;
99 private void EnableProvider()
101 frameProvider = new FrameProvider(mainWindow);
102 frameProvider.Shown += FrameProvider_Shown;
103 frameProvider.Hidden += FrameProvider_Hidden;
107 /// String tag to find View pair to be used in Page transition.
108 /// If there is a View have same TransitionTag in a next or previous Page.
109 /// The View will be pair for transition.
110 /// This is property for Page Transition.
112 /// <since_tizen> 9 </since_tizen>
113 public string TransitionTag { set; get; } = null;
116 /// Property for Page transition.
117 /// A View could be transition with its child Views or without them.
118 /// Default value is false
120 /// <since_tizen> 9 </since_tizen>
121 public bool TransitionWithChild { set; get; } = false;
124 /// Gets or sets the forward animation of launching
126 [EditorBrowsable(EditorBrowsableState.Never)]
127 public TransitionAnimation ForwardAnimation
131 return frameBroker?.ForwardAnimation;
135 if (frameBroker != null)
137 frameBroker.ForwardAnimation = value;
143 /// Gets or sets the backward animation of launching
145 [EditorBrowsable(EditorBrowsableState.Never)]
146 public TransitionAnimation BackwardAnimation
151 return frameBroker?.BackwardAnimation;
155 if (frameBroker != null)
157 frameBroker.BackwardAnimation = value;
163 /// Emits the event when the animation is started.
165 [EditorBrowsable(EditorBrowsableState.Never)]
166 public delegate void AnimationEventHandler(bool direction);
169 /// Emits the event when the animation is started.
171 [EditorBrowsable(EditorBrowsableState.Never)]
172 public event AnimationEventHandler AnimationInitialized;
175 /// Emits the event when the animation is finished.
177 [EditorBrowsable(EditorBrowsableState.Never)]
178 public event AnimationEventHandler AnimationFinished;
180 private void FrameBroker_TransitionAnimationFinished(bool direction)
182 AnimationFinished?.Invoke(direction);
185 private void FrameBroker_TransitionAnimationInitialized(bool direction)
187 AnimationInitialized?.Invoke(direction);
191 /// Occurs whenever the window is shown on caller application.
193 [EditorBrowsable(EditorBrowsableState.Never)]
194 public event EventHandler CallerScreenShown;
197 /// Occurs whenever the window is hidden on caller application.
199 [EditorBrowsable(EditorBrowsableState.Never)]
200 public event EventHandler CallerScreenHidden;
202 private void FrameProvider_Shown(object sender, EventArgs e)
204 Bundle bundle = new Bundle();
205 //Set information of shared object
206 frameProvider?.NotifyShowStatus(bundle);
208 CallerScreenShown?.Invoke(this, e);
213 private void FrameProvider_Hidden(object sender, EventArgs e)
215 Bundle bundle = new Bundle();
216 //Set information of shared object
217 frameProvider?.NotifyHideStatus(bundle);
219 CallerScreenHidden?.Invoke(this, e);
224 internal void SendLaunchRequest(AppControl appControl)
226 this.frameBroker.SendLaunchRequest(appControl, true);
230 /// Hidden API (Inhouse API).
233 /// <param name="disposing"></param>
234 [EditorBrowsable(EditorBrowsableState.Never)]
235 protected virtual void Dispose(bool disposing)
239 if (frameBroker != null)
241 frameBroker.Dispose();
244 if (frameProvider != null)
246 frameProvider.Dispose();
253 /// Dispose for IDisposable pattern
255 [EditorBrowsable(EditorBrowsableState.Never)]
256 public void Dispose()
259 System.GC.SuppressFinalize(this);