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;
29 private bool isAnimating;
31 public delegate void AnimationEventHandler();
32 internal event AnimationEventHandler AnimationInitialized;
33 internal event AnimationEventHandler AnimationFinished;
35 internal DefaultFrameBroker(Window window) : base(window)
41 protected override void OnFrameResumed(FrameData frame)
48 base.OnFrameResumed(frame);
49 if (AnimationInitialized != null)
51 AnimationInitialized();
54 if (frame.DirectionForward)
56 PlayAnimateTo(frame, ForwardAnimation);
60 PlayAnimateTo(frame, BackwardAnimation);
66 private void PlayAnimateTo(FrameData frame, TransitionAnimation animation)
70 providerImage = frame.Image;
71 providerImage.PositionUsesPivotPoint = true;
72 providerImage.PivotPoint = animation.GetDefaultPivotPoint();
73 providerImage.ParentOrigin = animation.GetDefaultParentOrigin();
74 providerImage.Position = animation.GetDefaultPosition();
75 providerImage.Size = animation.GetDefaultSize();
77 window.Add(providerImage);
79 animation.PlayAnimateTo(providerImage);
88 private TransitionAnimation forwardAnimation;
89 internal TransitionAnimation ForwardAnimation
93 return forwardAnimation;
97 forwardAnimation = value;
98 forwardAnimation.Finished += Ani_Finished;
102 private TransitionAnimation backwardAnimation;
103 internal TransitionAnimation BackwardAnimation
107 return backwardAnimation;
111 backwardAnimation = value;
112 backwardAnimation.Finished += Ani_Finished;
116 private void Ani_Finished(object sender, EventArgs e)
118 if (AnimationFinished != null)
123 if (providerImage != null)
125 providerImage.Unparent();
126 providerImage.Dispose();
127 providerImage = null;