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.NUI.BaseComponents;
25 internal class DefaultFrameBroker : FrameBrokerBase
27 private Window window;
28 private ImageView providerImage;
30 public delegate void AnimationEventHandler();
31 internal event AnimationEventHandler AnimationInitialized;
32 internal event AnimationEventHandler AnimationFinished;
34 internal DefaultFrameBroker(Window window) : base(window)
39 protected override void OnFrameResumed(FrameData frame)
41 base.OnFrameResumed(frame);
42 if (AnimationInitialized != null)
44 AnimationInitialized();
47 if (frame.DirectionForward)
49 PlayAnimateTo(frame, ForwardAnimation);
53 PlayAnimateTo(frame, BackwardAnimation);
59 private void PlayAnimateTo(FrameData frame, TransitionAnimation animation)
63 providerImage = frame.Image;
64 providerImage.Size = window.Size;
65 window.Add(providerImage);
67 if (animation is SlideIn)
69 SlideIn slideIn = animation as SlideIn;
70 providerImage.PositionX = slideIn.GetDefaultInitValue();
73 animation.PlayAnimateTo(providerImage);
81 private TransitionAnimation forwardAnimation;
82 internal TransitionAnimation ForwardAnimation
86 return forwardAnimation;
90 forwardAnimation = value;
91 forwardAnimation.Finished += Ani_Finished;
95 private TransitionAnimation backwardAnimation;
96 internal TransitionAnimation BackwardAnimation
100 return backwardAnimation;
104 backwardAnimation = value;
105 backwardAnimation.Finished += Ani_Finished;
109 private void Ani_Finished(object sender, EventArgs e)
111 if (AnimationFinished != null)
116 if (providerImage != null)
118 providerImage.Unparent();
119 providerImage.Dispose();
120 providerImage = null;