/* * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.ComponentModel; using Tizen.Applications; using Tizen.NUI.BaseComponents; namespace Tizen.NUI { /// /// This TransitionOptions class is a class to control Transition motion. /// This class includes multiple options for the Transition. /// NUI supports a kind of Transitions such as App transition, Page transition, and so on. /// Some of options could be used only for the App transition or Page transition, but others could be used for multiple purpose. /// /// [EditorBrowsable(EditorBrowsableState.Never)] public class TransitionOptions : IDisposable { private bool disposed = false; private FrameProvider frameProvider; private DefaultFrameBroker frameBroker; private bool enableTransition = false; private Window mainWindow; private View animatedTarget; /// /// Initializes the TransitionOptions class. /// /// The window instance of NUI Window [EditorBrowsable(EditorBrowsableState.Never)] public TransitionOptions(Window window) { mainWindow = window; } /// /// Initializes the TransitionOptions class. /// [EditorBrowsable(EditorBrowsableState.Never)] public TransitionOptions() { } /// /// Set animated view of seamless animation. /// [EditorBrowsable(EditorBrowsableState.Never)] public View AnimatedTarget { get { return animatedTarget; } set { animatedTarget = value; } } /// /// Gets or sets transition enable /// [EditorBrowsable(EditorBrowsableState.Never)] public bool EnableTransition { get { return enableTransition; } set { if (value) { frameBroker = new DefaultFrameBroker(mainWindow); frameBroker.mainView = animatedTarget; frameBroker.AnimationInitialized += FrameBroker_TransitionAnimationInitialized; frameBroker.AnimationFinished += FrameBroker_TransitionAnimationFinished; EnableProvider(); } enableTransition = value; } } private void EnableProvider() { frameProvider = new FrameProvider(mainWindow); frameProvider.Shown += FrameProvider_Shown; frameProvider.Hidden += FrameProvider_Hidden; } /// /// During the Page transition, if two Views each of on the old top Page /// and new top Page have same TransitionTag, the View on the old top Page /// will be transition to the one of new top Page. /// [EditorBrowsable(EditorBrowsableState.Never)] public string TransitionTag { set; get; } = null; /// /// A View could be transition with its child Views or without them. /// Default value is false /// [EditorBrowsable(EditorBrowsableState.Never)] public bool TransitionWithChild { set; get; } = false; /// /// Gets or sets the forward animation of launching /// [EditorBrowsable(EditorBrowsableState.Never)] public TransitionAnimation ForwardAnimation { get { return frameBroker?.ForwardAnimation; } set { if (frameBroker != null) { frameBroker.ForwardAnimation = value; } } } /// /// Gets or sets the backward animation of launching /// [EditorBrowsable(EditorBrowsableState.Never)] public TransitionAnimation BackwardAnimation { get { return frameBroker?.BackwardAnimation; } set { if (frameBroker != null) { frameBroker.BackwardAnimation = value; } } } /// /// Emits the event when the animation is started. /// [EditorBrowsable(EditorBrowsableState.Never)] public delegate void AnimationEventHandler(bool direction); /// /// Emits the event when the animation is started. /// [EditorBrowsable(EditorBrowsableState.Never)] public event AnimationEventHandler AnimationInitialized; /// /// Emits the event when the animation is finished. /// [EditorBrowsable(EditorBrowsableState.Never)] public event AnimationEventHandler AnimationFinished; private void FrameBroker_TransitionAnimationFinished(bool direction) { AnimationFinished?.Invoke(direction); } private void FrameBroker_TransitionAnimationInitialized(bool direction) { AnimationInitialized?.Invoke(direction); } /// /// Occurs whenever the window is shown on caller application. /// [EditorBrowsable(EditorBrowsableState.Never)] public event EventHandler CallerScreenShown; /// /// Occurs whenever the window is hidden on caller application. /// [EditorBrowsable(EditorBrowsableState.Never)] public event EventHandler CallerScreenHidden; private void FrameProvider_Shown(object sender, EventArgs e) { Bundle bundle = new Bundle(); //Set information of shared object frameProvider?.NotifyShowStatus(bundle); CallerScreenShown?.Invoke(this, e); bundle.Dispose(); bundle = null; } private void FrameProvider_Hidden(object sender, EventArgs e) { Bundle bundle = new Bundle(); //Set information of shared object frameProvider?.NotifyHideStatus(bundle); CallerScreenHidden?.Invoke(this, e); bundle.Dispose(); bundle = null; } internal void SendLaunchRequest(AppControl appControl) { this.frameBroker.SendLaunchRequest(appControl, true); } /// /// Hidden API (Inhouse API). /// Dispose. /// /// [EditorBrowsable(EditorBrowsableState.Never)] protected virtual void Dispose(bool disposing) { if (!disposed) { if (frameBroker != null) { frameBroker.Dispose(); } if (frameProvider != null) { frameProvider.Dispose(); } disposed = true; } } /// /// Dispose for IDisposable pattern /// [EditorBrowsable(EditorBrowsableState.Never)] public void Dispose() { Dispose(true); System.GC.SuppressFinalize(this); } } }