[NUI] Add frameBroker default setting value (#2113)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Thu, 22 Oct 2020 07:01:59 +0000 (16:01 +0900)
committerGitHub <noreply@github.com>
Thu, 22 Oct 2020 07:01:59 +0000 (16:01 +0900)
Add APIs by hidden in TransitionAnimation
 - GetDefaultSize
 - GetDefaultPosition
 - GetDefaultParentOrigin
 - GetDefaultPivotPoint
These functions set the default value of Calle's main imageView.

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI/src/internal/FrameBroker/DefaultFrameBroker.cs
src/Tizen.NUI/src/public/TransitionAnimations/TransitionAnimations.cs
test/Tizen.NUI.Seamless/NUIBrokerSample/NUIBrokerSample.cs
test/Tizen.NUI.Seamless/NUIBrokerSample/TransitionEffect/SeamlessAnimator.cs [deleted file]
test/Tizen.NUI.Seamless/NUIBrokerSample/TransitionEffect/SeamlessBackwardAnimation.cs [new file with mode: 0755]
test/Tizen.NUI.Seamless/NUIBrokerSample/TransitionEffect/SeamlessForwardAnimation.cs [new file with mode: 0755]
test/Tizen.NUI.Seamless/NUIBrokerSample/UICreator.cs
test/Tizen.NUI.Seamless/NUIMusicPlayer/UICreator.cs

index 3d65302ad0b9af3d7e04e652f722ed386b2afbef..7aeac652dfd3d5f3135c9879f8da6f5f4dce74b5 100755 (executable)
@@ -26,6 +26,7 @@ namespace Tizen.NUI
     {
         private Window window;
         private ImageView providerImage;
+        private bool isAnimating;
 
         public delegate void AnimationEventHandler();
         internal event AnimationEventHandler AnimationInitialized;
@@ -34,10 +35,16 @@ namespace Tizen.NUI
         internal DefaultFrameBroker(Window window) : base(window)
         {
             this.window = window;
+            isAnimating = false;
         }
 
         protected override void OnFrameResumed(FrameData frame)
         {
+            if(isAnimating)
+            {
+                return;
+            }
+            isAnimating = true;
             base.OnFrameResumed(frame);
             if (AnimationInitialized != null)
             {
@@ -61,10 +68,13 @@ namespace Tizen.NUI
             if (animation)
             {
                 providerImage = frame.Image;
-                providerImage.Size = window.Size;
-                window.Add(providerImage);
+                providerImage.PositionUsesPivotPoint = true;
+                providerImage.PivotPoint = animation.GetDefaultPivotPoint();
+                providerImage.ParentOrigin = animation.GetDefaultParentOrigin();
+                providerImage.Position = animation.GetDefaultPosition();
+                providerImage.Size = animation.GetDefaultSize();
 
-                providerImage.PositionX = animation.GetDefaultInitValue();
+                window.Add(providerImage);
 
                 animation.PlayAnimateTo(providerImage);
             }
@@ -74,6 +84,7 @@ namespace Tizen.NUI
             }
         }
 
+
         private TransitionAnimation forwardAnimation;
         internal TransitionAnimation ForwardAnimation 
         { 
@@ -116,6 +127,7 @@ namespace Tizen.NUI
                 providerImage = null;
             }
             FinishAnimation();
+            isAnimating = false;
         }
     }
 }
index 7e9769c476fcae2061fdc5e25902524dbc81246d..7d60a33bb4058c3f3c5cdd2e9b7b45b5d0803bcd 100755 (executable)
@@ -21,10 +21,42 @@ namespace Tizen.NUI
 
         }
 
-        internal virtual int GetDefaultInitValue()
+        /// <summary>
+        /// Return default size of main view.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual Size GetDefaultSize()
+        {
+            return new Size(0, 0);
+        }
+
+        /// <summary>
+        /// Return default position of main view.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual Position GetDefaultPosition()
+        {
+            return new Position(0, 0);
+        }
+
+        /// <summary>
+        /// Return default position of main view.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual Position GetDefaultParentOrigin()
+        {
+            return ParentOrigin.Center;
+        }
+
+        /// <summary>
+        /// Return default position of main view.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual Position GetDefaultPivotPoint()
         {
-            return 0;
+            return PivotPoint.Center;
         }
+
     }
 
     /// <summary>
@@ -55,10 +87,24 @@ namespace Tizen.NUI
             defaultInitValue = -Window.Instance.GetWindowSize().Width;
         }
 
-        internal override int GetDefaultInitValue()
+        /// <summary>
+        /// Return default position of main view.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public override Position GetDefaultPosition()
+        {
+            return new Position(defaultInitValue, 0);
+        }
+
+        /// <summary>
+        /// Return default size of main view.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual Size GetDefaultSize()
         {
-            return defaultInitValue;
+            return Window.Instance.GetWindowSize();
         }
+
     }
 
 
@@ -91,9 +137,22 @@ namespace Tizen.NUI
             defaultInitValue = 0;
         }
 
-        internal override int GetDefaultInitValue()
+        /// <summary>
+        /// Return default position of main view.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public override Position GetDefaultPosition()
+        {
+            return new Position(defaultInitValue, 0);
+        }
+
+        /// <summary>
+        /// Return default size of main view.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual Size GetDefaultSize()
         {
-            return defaultInitValue;
+            return Window.Instance.GetWindowSize();
         }
     }
 }
index 7a728171b580bcc3d33957e8f159524b6c69ba35..60cee1a57e4ee57ded669faa33ec92e2113a2df5 100755 (executable)
@@ -8,6 +8,9 @@ namespace NUIBrokerSample
     class Program : NUIApplication
     {
         private UICreator uiCreator;
+        private SeamlessForwardAnimation fAnimation;
+        private SeamlessBackwardAnimation bAnimation;
+
         protected override void OnCreate()
         {
             base.OnCreate();
@@ -24,12 +27,26 @@ namespace NUIBrokerSample
 
             TransitionOptions = new TransitionOptions(GetDefaultWindow());
             TransitionOptions.EnableTransition = true;
-            TransitionOptions.ForwardAnimation = new SlideIn(1300);
-            TransitionOptions.BackwardAnimation = new SlideOut(1300);
 
+            fAnimation = new SeamlessForwardAnimation(uiCreator, 600);
+            bAnimation = new SeamlessBackwardAnimation(uiCreator, 600);
+            TransitionOptions.ForwardAnimation = fAnimation;
+            //TransitionOptions.BackwardAnimation = bAnimation;
+
+            TransitionOptions.AnimationInitialized += TransitionOptions_AnimationInitialized;
             //(launchBroker as SeamlessAnimator)?.SetUICreator(uiCreator);
         }
 
+        private void TransitionOptions_AnimationInitialized(object sender, EventArgs e)
+        {
+            fAnimation.InitAnimation();
+            //bAnimation.InitAnimation();
+        }
+
+        protected override void OnResume()
+        {
+            base.OnResume();
+        }
 
         protected override void OnPause()
         {
diff --git a/test/Tizen.NUI.Seamless/NUIBrokerSample/TransitionEffect/SeamlessAnimator.cs b/test/Tizen.NUI.Seamless/NUIBrokerSample/TransitionEffect/SeamlessAnimator.cs
deleted file mode 100755 (executable)
index ca754c5..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Tizen.NUI;
-using Tizen.NUI.BaseComponents;
-
-namespace NUIBrokerSample
-{
-    class SeamlessAnimation : TransitionAnimation
-    {
-        private Size DEFAULT_POPUP_SIZE = new Size(470, 600);
-
-        private Window window;
-
-        private Position DefaultIconPos;
-        private Position DefaultAddIconPos;
-        private Position DefaultMainPos;
-        private Position DefaultSubPos;
-        private Position DefaultMainViewPos;
-
-        private ImageView imgView = null;
-        private Animation transitionAnimation = null;
-        private bool isForward = false;
-
-
-        private UICreator uiCreator;
-
-        public SeamlessAnimation(int durationMilliSeconds) : base(durationMilliSeconds)
-        {
-        }
-
-        protected void TestAnimation()
-        {
-            DestroyImagView();
-            ResetAnimation();
-//            ResetImageView(frame.Image);
-
-            isForward = true;
-            if (isForward == true)
-            {
-                StoreInitDate();
-
-                transitionAnimation.AnimateTo(uiCreator.AnimationView, "Size", new Size(window.Size), 50, 600);
-                transitionAnimation.AnimateTo(uiCreator.AnimationView, "Position", new Position(0, 0), 50, 600);
-                transitionAnimation.AnimateTo(imgView, "Size", new Size(window.Size), 200, 600);
-
-                transitionAnimation.AnimateTo(uiCreator.IconView, "Position", new Position(0, 150), 0, 300);
-                transitionAnimation.AnimateTo(uiCreator.AddView, "Position", new Position(30, 180), 0, 300);
-
-                transitionAnimation.AnimateTo(uiCreator.IconView, "Scale", new Vector3(1.3f, 1.3f, 1.0f), 0, 300);
-                transitionAnimation.AnimateTo(uiCreator.AddView, "Scale", new Vector3(0.7f, 0.7f, 1.0f), 0, 300);
-
-                uiCreator.MainView.Hide();
-                uiCreator.MainProfileText.Hide();
-                uiCreator.SubProfileText.Hide();
-            }
-            else
-            {
-                transitionAnimation.AnimateTo(uiCreator.AnimationView, "Size", DEFAULT_POPUP_SIZE, 50, 600);
-                transitionAnimation.AnimateTo(uiCreator.AnimationView, "Position", DefaultMainViewPos, 50, 600);
-                transitionAnimation.AnimateTo(imgView, "Size", DEFAULT_POPUP_SIZE, 200, 600);
-
-                transitionAnimation.AnimateTo(uiCreator.IconView, "Position", DefaultIconPos, 400, 600);
-                transitionAnimation.AnimateTo(uiCreator.AddView, "Position", DefaultAddIconPos, 400, 600);
-
-                transitionAnimation.AnimateTo(uiCreator.IconView, "Scale", new Vector3(1.0f, 1.0f, 1.0f), 400, 600);
-                transitionAnimation.AnimateTo(uiCreator.IconView, "Scale", new Vector3(1.0f, 1.0f, 1.0f), 400, 600);
-
-            }
-
-            transitionAnimation.Finished += Ani_Finished;
-            transitionAnimation.Play();
-            //StartAnimation();
-        }
-
-        private void Ani_Finished(object sender, EventArgs e)
-        {
-            //FinishAnimation();
-            Timer timer = new Timer(30);
-            timer.Tick += Timer_Tick;
-            timer.Start();
-        }
-
-        private bool Timer_Tick(object source, Timer.TickEventArgs e)
-        {
-            DestroyImagView();
-            if (!isForward)
-            {
-                uiCreator.MainView.Show();
-                uiCreator.MainProfileText.Show();
-                uiCreator.SubProfileText.Show();
-            }
-            return false;
-        }
-
-        private void ResetAnimation()
-        {
-            if (transitionAnimation != null)
-            {
-                transitionAnimation.Reset();
-                transitionAnimation.Clear();
-                transitionAnimation.Dispose();
-                transitionAnimation = null;
-            }
-            transitionAnimation = new Animation(600);
-            transitionAnimation.DefaultAlphaFunction = GetSineInOut80();
-        }
-
-        private void DestroyImagView()
-        {
-            if(imgView != null)
-            {
-                imgView.LowerToBottom();
-                imgView.Hide();
-                imgView.Unparent();
-                imgView.Dispose();
-                imgView = null;
-            }
-        }
-
-        private void ResetImageView(ImageView imgFrame)
-        {
-            imgView = imgFrame;
-            imgView.ParentOrigin = ParentOrigin.TopCenter;
-            imgView.PivotPoint = PivotPoint.TopCenter;
-            imgView.PositionUsesPivotPoint = true;
-            imgView.CornerRadius = 50.0f;
-
-            uiCreator.AnimationView.Add(imgView);
-            imgView.LowerToBottom();
-        }
-
-        private void StoreInitDate()
-        {
-            DefaultIconPos = uiCreator.IconView.Position;
-            DefaultAddIconPos = uiCreator.AddView.Position;
-            DefaultMainPos = uiCreator.MainProfileText.Position;
-            DefaultSubPos = uiCreator.SubProfileText.Position;
-            DefaultMainViewPos = uiCreator.MainView.Position;
-
-            imgView.Size = DEFAULT_POPUP_SIZE;
-            uiCreator.AnimationView.Size = DEFAULT_POPUP_SIZE;
-        }
-
-        internal AlphaFunction GetSineInOut80()
-        {
-            return new AlphaFunction(new Vector2(0.45f, 0.43f), new Vector2(0.41f, 1.0f));
-        }
-    }
-}
diff --git a/test/Tizen.NUI.Seamless/NUIBrokerSample/TransitionEffect/SeamlessBackwardAnimation.cs b/test/Tizen.NUI.Seamless/NUIBrokerSample/TransitionEffect/SeamlessBackwardAnimation.cs
new file mode 100755 (executable)
index 0000000..e97532e
--- /dev/null
@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+
+namespace NUIBrokerSample
+{
+    class SeamlessBackwardAnimation : TransitionAnimation
+    {
+        private Size DEFAULT_POPUP_SIZE = new Size(470, 600);
+
+        private Window window;
+
+        private Position DefaultIconPos;
+        private Position DefaultAddIconPos;
+        private Position DefaultMainPos;
+        private Position DefaultSubPos;
+        private Position DefaultMainViewPos;
+        
+        private int durationMilliSeconds;
+        private UICreator uiCreator;
+
+        public SeamlessBackwardAnimation(UICreator uiCreator, int durationMilliSeconds) : base(durationMilliSeconds)
+        {
+            this.durationMilliSeconds = durationMilliSeconds;
+            window = Window.Instance;
+            this.uiCreator = uiCreator;
+
+            int propertyCount = 4;
+            Properties = new string[propertyCount];
+            DestValue = new string[propertyCount];
+            StartTime = new int[propertyCount];
+            EndTime = new int[propertyCount];
+            for (int i = 0; i < propertyCount; i++)
+            {
+                StartTime[i] = 200;
+                EndTime[i] = durationMilliSeconds;
+            }
+
+            DefaultAlphaFunction = GetSineInOut80();
+
+        }
+        private void SetupAnimationData()
+        {
+            Properties[0] = "SizeWidth";
+            DestValue[0] = DEFAULT_POPUP_SIZE.Width.ToString();
+
+            Properties[1] = "SizeHeight";
+            DestValue[1] = DEFAULT_POPUP_SIZE.Height.ToString();
+
+            Properties[2] = "PositionX";
+            DestValue[2] = DefaultMainViewPos.X.ToString();
+
+            Properties[3] = "PositionY";
+            DestValue[3] = DefaultMainViewPos.Y.ToString();
+
+        }
+
+        public void InitAnimation()
+        {
+            Animation ani = new Animation(durationMilliSeconds);
+            ani.DefaultAlphaFunction = GetSineInOut80();
+
+            StoreInitDate();
+            SetupAnimationData();
+
+            this.AnimateTo(uiCreator.AnimationView, "Size", DEFAULT_POPUP_SIZE, 50, 600);
+            this.AnimateTo(uiCreator.AnimationView, "Position", DefaultMainViewPos, 50, 600);
+            //this.AnimateTo(imgView, "Size", DEFAULT_POPUP_SIZE, 200, 600);
+
+            this.AnimateTo(uiCreator.IconView, "Position", DefaultIconPos, 400, 600);
+            this.AnimateTo(uiCreator.AddView, "Position", DefaultAddIconPos, 400, 600);
+
+            this.AnimateTo(uiCreator.IconView, "Scale", new Vector3(1.0f, 1.0f, 1.0f), 400, 600);
+            this.AnimateTo(uiCreator.IconView, "Scale", new Vector3(1.0f, 1.0f, 1.0f), 400, 600);
+
+            ani.Finished += Ani_Finished;
+            ani.Play();
+        }
+
+        private void Ani_Finished(object sender, EventArgs e)
+        {
+            //FinishAnimation();
+            Timer timer = new Timer(30);
+            timer.Tick += Timer_Tick;
+            timer.Start();
+        }
+
+        private bool Timer_Tick(object source, Timer.TickEventArgs e)
+        {
+            uiCreator.MainView.Show();
+            uiCreator.MainProfileText.Show();
+            uiCreator.SubProfileText.Show();
+            return false;
+        }
+
+        private void StoreInitDate()
+        {
+            DefaultIconPos = uiCreator.IconView.Position;
+            DefaultAddIconPos = uiCreator.AddView.Position;
+            DefaultMainPos = uiCreator.MainProfileText.Position;
+            DefaultSubPos = uiCreator.SubProfileText.Position;
+            DefaultMainViewPos = uiCreator.MainView.Position;
+
+            uiCreator.AnimationView.Size = DEFAULT_POPUP_SIZE;
+        }
+
+        internal AlphaFunction GetSineInOut80()
+        {
+            return new AlphaFunction(new Vector2(0.45f, 0.43f), new Vector2(0.41f, 1.0f));
+        }
+
+        
+        public override Position GetDefaultPosition()
+        {
+            return DefaultMainViewPos;
+        }
+
+        public override Size GetDefaultSize()
+        {
+            return new Size(0, 0);
+        }
+
+        public override Position GetDefaultParentOrigin()
+        {
+            return ParentOrigin.TopCenter;
+        }
+
+        public override Position GetDefaultPivotPoint()
+        {
+            return PivotPoint.TopCenter;
+        }
+
+    }
+}
diff --git a/test/Tizen.NUI.Seamless/NUIBrokerSample/TransitionEffect/SeamlessForwardAnimation.cs b/test/Tizen.NUI.Seamless/NUIBrokerSample/TransitionEffect/SeamlessForwardAnimation.cs
new file mode 100755 (executable)
index 0000000..961ad30
--- /dev/null
@@ -0,0 +1,122 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+
+namespace NUIBrokerSample
+{
+    class SeamlessForwardAnimation : TransitionAnimation
+    {
+        private Size DEFAULT_POPUP_SIZE = new Size(470, 600);
+
+        private Window window;
+
+        private Position DefaultIconPos;
+        private Position DefaultAddIconPos;
+        private Position DefaultMainViewPos;
+
+        private int durationMilliSeconds;
+        private UICreator uiCreator;
+
+        public SeamlessForwardAnimation(UICreator uiCreator, int durationMilliSeconds) : base(durationMilliSeconds)
+        {
+            this.durationMilliSeconds = durationMilliSeconds;
+            window = Window.Instance;
+            this.uiCreator = uiCreator;
+
+            int propertyCount = 4;
+            Properties = new string[propertyCount];
+            DestValue = new string[propertyCount];
+            StartTime = new int[propertyCount];
+            EndTime = new int[propertyCount];
+            for (int i = 0; i < propertyCount; i++)
+            {
+                StartTime[i] = 200;
+                EndTime[i] = durationMilliSeconds;
+            }
+
+            Properties[0] = "SizeWidth";
+            DestValue[0] = Window.Instance.WindowSize.Width.ToString();
+
+            Properties[1] = "SizeHeight";
+            DestValue[1] = Window.Instance.WindowSize.Height.ToString();
+
+            Properties[2] = "PositionX";
+            DestValue[2] = "0";
+
+            Properties[3] = "PositionY";
+            DestValue[3] = "0";
+
+            DefaultAlphaFunction = GetSineInOut80();
+
+        }
+
+        public void InitAnimation()
+        {
+            Animation ani = new Animation(durationMilliSeconds);
+            ani.DefaultAlphaFunction = GetSineInOut80();
+
+            StoreInitDate();
+            uiCreator.MainView.Hide();
+            //ani.AnimateTo(uiCreator.AnimationView, "Size", new Size(window.Size), 50, 600);
+            ani.AnimateTo(uiCreator.AnimationView, "Position", new Position(0, 0), 50, 600);
+
+            ani.AnimateTo(uiCreator.IconView, "Position", new Position(0, 150), 0, 300);
+            ani.AnimateTo(uiCreator.AddView, "Position", new Position(30, 180), 0, 300);
+
+            ani.AnimateTo(uiCreator.IconView, "Scale", new Vector3(1.3f, 1.3f, 1.0f), 0, 300);
+            ani.AnimateTo(uiCreator.AddView, "Scale", new Vector3(0.7f, 0.7f, 1.0f), 0, 300);
+            
+            ani.Finished += Ani_Finished;
+            ani.Play();
+        }
+
+        private void Ani_Finished(object sender, EventArgs e)
+        {
+            uiCreator.AnimationView.Position = DefaultMainViewPos;
+            uiCreator.IconView.Position = DefaultIconPos;
+            uiCreator.IconView.Scale = new Vector3(1.0f, 1.0f, 1.0f);
+            uiCreator.AddView.Position = DefaultAddIconPos;
+            uiCreator.AddView.Scale = new Vector3(1.0f, 1.0f, 1.0f);
+            uiCreator.AnimationView.Size = new Size(470, 600);
+            uiCreator.MainView.Show();
+        }
+
+        private void StoreInitDate()
+        {
+            DefaultIconPos = new Position(-160, 80); //uiCreator.IconView.Position;
+            DefaultAddIconPos = new Position(160, 80); //uiCreator.AddView.Position;
+
+            DefaultMainViewPos = uiCreator.MainView.Position;
+            uiCreator.AnimationView.Size = DEFAULT_POPUP_SIZE;
+        }
+
+        internal AlphaFunction GetSineInOut80()
+        {
+            return new AlphaFunction(new Vector2(0.45f, 0.43f), new Vector2(0.41f, 1.0f));
+        }
+
+        
+        public override Position GetDefaultPosition()
+        {
+            return DefaultMainViewPos;
+        }
+
+        public override Size GetDefaultSize()
+        {
+            return new Size(0, 0);
+        }
+
+        public override Position GetDefaultParentOrigin()
+        {
+            return ParentOrigin.TopCenter;
+        }
+
+        public override Position GetDefaultPivotPoint()
+        {
+            return PivotPoint.TopCenter;
+        }
+
+    }
+}
index 3e84d6d754fc7a0fc4e231236572fb70dc45d20f..f24900dba89fd74dbfff515deaa482d902d03013 100755 (executable)
@@ -42,7 +42,7 @@ namespace NUIBrokerSample
         public UICreator(NUIApplication app)
         {
             application = app;
-            CreateMobileSize();
+            CreateFHubSize();
         }
         private void CreateMobileSize()
         {
index b9f25615380d2e15ab70e0b1109c6f7e536d339d..ed4df3c77f593606cf5bc91e3c82a520c52561e7 100755 (executable)
@@ -28,8 +28,7 @@ namespace NUIMusicPlayer
 
         public UICreator()
         {
-            //CreateFHubSize();
-            CreateMobileSize();
+            CreateFHubSize();
         }
         public void CreateMobileSize()
         {