Remove animation comments scalable_ui
authorKrzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics <k.wieclaw@samsung.com>
Wed, 8 Sep 2021 18:19:42 +0000 (20:19 +0200)
committerKrzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics <k.wieclaw@samsung.com>
Wed, 8 Sep 2021 18:36:27 +0000 (20:36 +0200)
Change-Id: I8a8193c8daf2fe2d7f4416042f60415b757509e6
Signed-off-by: Krzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics <k.wieclaw@samsung.com>
Oobe/Oobe/Controls/ViewStack.cs [deleted file]
Oobe/Oobe/Managers/ProcessManager.cs
Oobe/Oobe/Oobe.csproj
Oobe/Oobe/ScalableUI/OrientationalView.cs
Oobe/Oobe/Views/MainView.cs

diff --git a/Oobe/Oobe/Controls/ViewStack.cs b/Oobe/Oobe/Controls/ViewStack.cs
deleted file mode 100644 (file)
index b64e709..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * 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.Collections.Generic;
-using Tizen.NUI;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Components;
-
-namespace Oobe.Controls
-{
-    /// <summary>
-    /// ViewStack implemenents stack based navigation in which all child views are stacked over each other
-    /// and only the most recent child added is visible.
-    /// </summary>
-    public class ViewStack : View
-    {
-        private List<View> views = new List<View>();
-        private List<View> viewsToRemove = new List<View>();
-
-        private Animation pageEnterAnimation;
-        private Animation pageLeaveAnimation;
-        private Animation opacityEffectAnimation;
-
-        public ViewStack()
-            : base()
-        {
-            ClippingMode = ClippingModeType.ClipToBoundingBox;
-            pageEnterAnimation = new Animation();
-            pageLeaveAnimation = new Animation();
-            opacityEffectAnimation = new Animation();
-            pageEnterAnimation.Finished += OnPageEntered;
-            pageLeaveAnimation.Finished += OnPageLeave;
-        }
-
-        /// <summary>
-        /// Informs about transition animation end
-        /// </summary>
-        public event EventHandler TransitionFinished;
-
-        /// <summary>
-        /// Number of pixels between stack right boundary and newly pushed child view left boundary,
-        /// which will be applied before starting page entering animation.
-        /// </summary>
-        /// <value></value>
-        public int PagesRightPadding { get; set; } = 0;
-
-        /// <summary>
-        /// Number of pixels between stack right boundary and current top child view left boundary,
-        /// which will be applied after finishing page leaving animation
-        /// </summary>
-        public int PagesLeftPadding { get; set; } = 0;
-
-        /// <summary>
-        /// Duration of page entering and page leaving animations
-        /// </summary>
-        public int ScrollDuration { get; set; } = 125;
-
-        /// <summary>
-        /// Get view currently stacked on Top of ViewStack
-        /// </summary>
-        public View Current
-        {
-            get
-            {
-                return views.Count > 0 ? views[views.Count - 1] : null;
-            }
-        }
-
-        /// <summary>
-        /// Get view currently stacked under Current
-        /// </summary>
-        public View Previous
-        {
-            get
-            {
-                return views.Count > 1 ? views[views.Count - 2] : null;
-            }
-        }
-
-        /// <summary>
-        /// Pop Current view with animation
-        /// </summary>
-        public void Pop()
-        {
-            if (Current != null)
-            {
-                FinishAnimations();
-                RemoveAllDelayedViews();
-                StartPageLeaveAnimation(Previous, Current);
-                StartShowAnimation(Previous);
-                AddViewToDelayRemove(Current);
-                views.Remove(Current);
-            }
-        }
-
-        /// <summary>
-        /// Pushed new view on stack with animation.
-        /// </summary>
-        public void Push(View view)
-        {
-            FinishAnimations();
-            RemoveAllDelayedViews();
-            Add(view);
-            views.Add(view);
-            StartPageEnterAnimation(Previous, Current);
-            StartHideAnimation(Previous);
-        }
-
-        protected override void Dispose(Tizen.NUI.DisposeTypes type)
-        {
-            if (disposed)
-            {
-                return;
-            }
-
-            if (type == DisposeTypes.Explicit)
-            {
-                pageEnterAnimation.Dispose();
-                pageLeaveAnimation.Dispose();
-            }
-
-            base.Dispose(type);
-        }
-
-        private static void FinishAnimation(Animation anim)
-        {
-            if (anim != null)
-            {
-                if (anim.State == Animation.States.Playing)
-                {
-                    anim.Stop(Animation.EndActions.StopFinal);
-                }
-
-                anim.Clear();
-            }
-        }
-
-        private void AddViewToDelayRemove(View view)
-        {
-            if (view)
-            {
-                viewsToRemove.Add(view);
-            }
-        }
-
-        private void RemoveAllDelayedViews()
-        {
-            foreach (View view in viewsToRemove)
-            {
-                // hide view to resolve issue with rendering artifacts
-                view.Hide();
-                Remove(view);
-                view.Dispose();
-            }
-
-            viewsToRemove.Clear();
-        }
-
-        private void FinishAnimations()
-        {
-            FinishAnimation(pageLeaveAnimation);
-            FinishAnimation(pageEnterAnimation);
-            FinishAnimation(opacityEffectAnimation);
-        }
-
-        private void StartPageLeaveAnimation(View back, View front)
-        {
-            pageLeaveAnimation.Duration = ScrollDuration;
-            pageLeaveAnimation.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine);
-
-            if (back != null)
-            {
-                // place 'back' out of viewport (should be already there)
-                // run animation to place 'back' in viewport
-                pageLeaveAnimation.AnimateTo(back, "PositionX", 0, null);
-            }
-
-            if (front != null)
-            {
-                // place 'front' in viewport (should be already there)
-                // run animation to place 'front' out of viewport
-                pageLeaveAnimation.AnimateTo(front, "PositionX", Size2D.Width + PagesRightPadding);
-            }
-
-            pageLeaveAnimation.Play();
-        }
-
-        private void StartPageEnterAnimation(View back, View front)
-        {
-            pageEnterAnimation.Duration = ScrollDuration;
-            pageEnterAnimation.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine);
-
-            if (back != null)
-            {
-                // place back in viewport (should be already there)
-                // run anim to place 'back' out of viewport
-                int diff = Position2D.X - PagesLeftPadding;
-                pageEnterAnimation.AnimateTo(back, "PositionX", diff);
-            }
-
-            if (front != null)
-            {
-                // place 'front' out of viewport
-                front.Position2D.X = Size2D.Width + PagesRightPadding;
-
-                // run anim to place 'front' on viewport
-                pageEnterAnimation.AnimateTo(front, "PositionX", 0, null);
-            }
-
-            pageEnterAnimation.Play();
-        }
-
-        private void OnPageEntered(object sender, EventArgs args)
-        {
-            TransitionFinished?.Invoke(this, new EventArgs());
-        }
-
-        private void OnPageLeave(object sender, EventArgs args)
-        {
-            RemoveAllDelayedViews();
-            TransitionFinished?.Invoke(this, new EventArgs());
-        }
-
-        private void StartHideAnimation(View view)
-        {
-            StartOpacityAnimation(view, 1.0f, 0.0f);
-        }
-
-        private void StartShowAnimation(View view)
-        {
-            StartOpacityAnimation(view, 0.0f, 1.0f);
-        }
-
-        private void StartOpacityAnimation(View view, float from, float to)
-        {
-            if (view != null)
-            {
-                opacityEffectAnimation.Duration = ScrollDuration;
-                view.Opacity = from;
-                opacityEffectAnimation.AnimateTo(view, "Opacity", to);
-                opacityEffectAnimation.Play();
-            }
-        }
-
-        private class ViewStackBaseCustomLayout : LayoutGroup
-        {
-            protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
-            {
-                ViewStack stack = this.Owner as ViewStack;
-
-                if (!stack)
-                {
-                    return;
-                }
-
-                int totalWidth = stack.Size2D.Width;
-                int totalHeight = stack.Size2D.Height;
-
-                SetMeasuredDimensions(
-                        ResolveSizeAndState(new LayoutLength(totalWidth), widthMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK),
-                        ResolveSizeAndState(new LayoutLength(totalHeight), heightMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK));
-            }
-
-            protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
-            {
-                ViewStack stack = this.Owner as ViewStack;
-
-                if (!changed || !stack)
-                {
-                    return;
-                }
-
-                int totalWidth = stack.Size2D.Width;
-                int totalHeight = stack.Size2D.Height;
-
-                foreach (LayoutItem childLayout in LayoutChildren)
-                {
-                    if (childLayout.Owner == stack.Current)
-                    {
-                        childLayout.Layout(
-                            new LayoutLength(0),
-                            new LayoutLength(0),
-                            new LayoutLength(totalWidth),
-                            new LayoutLength(totalHeight));
-                    }
-                    else
-                    {
-                        childLayout.Layout(
-                            new LayoutLength(-stack.PagesLeftPadding),
-                            new LayoutLength(0),
-                            new LayoutLength(totalWidth - stack.PagesLeftPadding),
-                            new LayoutLength(totalHeight));
-                    }
-                }
-            }
-        }
-    }
-}
index c26078e0294e85c065ce46d7901085313edc8ca3..838d597d30560a4afaed5acd93096c87db938b9c 100644 (file)
@@ -120,6 +120,7 @@ namespace Oobe
             }
 
             SetDone();
+            Tizen.Log.Debug("oobe", "Finished oobe navigation - closing");
             NUIApplication.Current.Exit();
         }
 
index 7525d0d68e74dbd56e19ed738ffd8afb47661eaa..09e09f5612ebc15f8fa3c3ff2bab43163b0a16d1 100644 (file)
@@ -16,6 +16,7 @@
   </PropertyGroup>
 
   <ItemGroup>
+    <Folder Include="Controls\" />
     <Folder Include="lib\" />
     <Folder Include="res\" />
     <AdditionalFiles Include="../stylecop.json" />
index 49e7b9ed1c12ceca323d98d861a97dcc8b23eda0..dca36e1b3843c0db6ad3b115221945258911e89d 100644 (file)
@@ -11,7 +11,7 @@ namespace ScalableUI
     public class OrientationalView : Tizen.NUI.BaseComponents.View
     {
         public enum Mode
-        {
+        { 
             Stacking,
             Splitting,
         };
@@ -179,41 +179,31 @@ namespace ScalableUI
 
         private async void AddStacking(View child)
         {
-            Push(child);
-            //int width = Size2D.Width - (Padding.Start + Padding.End);
-            //int height = Size2D.Height - (Padding.Top + Padding.Bottom);
-
-            //if (ChildCount > 1)
-            //{
-            //    var prev = Children.Skip(Children.Count - 2).First();
-
-            //    // fade out current item
-            //    await Animation.AnimateTo(prev, "Opacity", 0.0f);
-            //    prev.Hide();
-            //}
-
-            //// show next item behind the screen
-            //child.Size2D = new Size2D(width, height);
-            //child.Position2D = new Position2D(Size2D.Width, Padding.Top);
-            //child.Show();
-
-            //// animate next item to correct position
-            //await Animation.AnimateTo(child, "PositionX", (int)Padding.Start);
+            FinishAnimations();
+            RemoveAllDelayedViews();
+            base.Add(child);
+            views.Add(child);
+            StartPageEnterAnimation(Previous, Current);
+            StartHideAnimation(Previous);
         }
 
         private async Task RemoveStacking(View child)
         {
-            Pop();
-            //var last = Children.Last();
-            //await Animation.AnimateTo(last, "PositionX", Size2D.Width);
-            //last.Hide();
-
-            //var prev = Children.Skip(Children.Count - 2).First();
-            //if (prev != null)
-            //{
-            //    prev.Show();
-            //    await Animation.AnimateTo(prev, "Opacity", 1.0f);
-            //}
+            if (Current == child)
+            {
+                FinishAnimations();
+                RemoveAllDelayedViews();
+                StartPageLeaveAnimation(Previous, Current);
+                StartShowAnimation(Previous);
+                AddViewToDelayRemove(Current);
+                views.Remove(Current);
+
+            }
+            else
+            {
+                views.Remove(child);
+            }
+
         }
 
         private List<View> views = new List<View>();
@@ -268,35 +258,6 @@ namespace ScalableUI
             }
         }
 
-        /// <summary>
-        /// Pop Current view with animation
-        /// </summary>
-        public void Pop()
-        {
-            if (Current != null)
-            {
-                FinishAnimations();
-                RemoveAllDelayedViews();
-                StartPageLeaveAnimation(Previous, Current);
-                StartShowAnimation(Previous);
-                AddViewToDelayRemove(Current);
-                views.Remove(Current);
-            }
-        }
-
-        /// <summary>
-        /// Pushed new view on stack with animation.
-        /// </summary>
-        public void Push(View view)
-        {
-            FinishAnimations();
-            RemoveAllDelayedViews();
-            Add(view);
-            views.Add(view);
-            StartPageEnterAnimation(Previous, Current);
-            StartHideAnimation(Previous);
-        }
-
         protected override void Dispose(Tizen.NUI.DisposeTypes type)
         {
             if (disposed)
@@ -340,7 +301,7 @@ namespace ScalableUI
             {
                 // hide view to resolve issue with rendering artifacts
                 view.Hide();
-                Remove(view);
+                base.Remove(view);
                 view.Dispose();
             }
 
@@ -432,58 +393,5 @@ namespace ScalableUI
                 opacityEffectAnimation.Play();
             }
         }
-
-        //private class ViewStackBaseCustomLayout : LayoutGroup
-        //{
-        //    protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
-        //    {
-        //        OrientationalView stack = this.Owner as OrientationalView;
-
-        //        if (!stack)
-        //        {
-        //            return;
-        //        }
-
-        //        int totalWidth = stack.Size2D.Width;
-        //        int totalHeight = stack.Size2D.Height;
-
-        //        SetMeasuredDimensions(
-        //                ResolveSizeAndState(new LayoutLength(totalWidth), widthMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK),
-        //                ResolveSizeAndState(new LayoutLength(totalHeight), heightMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK));
-        //    }
-
-        //    protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
-        //    {
-        //        OrientationalView stack = this.Owner as OrientationalView;
-
-        //        if (!changed || !stack)
-        //        {
-        //            return;
-        //        }
-
-        //        int totalWidth = stack.Size2D.Width;
-        //        int totalHeight = stack.Size2D.Height;
-
-        //        foreach (LayoutItem childLayout in LayoutChildren)
-        //        {
-        //            if (childLayout.Owner == stack.Current)
-        //            {
-        //                childLayout.Layout(
-        //                    new LayoutLength(0),
-        //                    new LayoutLength(0),
-        //                    new LayoutLength(totalWidth),
-        //                    new LayoutLength(totalHeight));
-        //            }
-        //            else
-        //            {
-        //                childLayout.Layout(
-        //                    new LayoutLength(-stack.PagesLeftPadding),
-        //                    new LayoutLength(0),
-        //                    new LayoutLength(totalWidth - stack.PagesLeftPadding),
-        //                    new LayoutLength(totalHeight));
-        //            }
-        //        }
-        //    }
-        //}
     }
 }
index 4db631e22bc49d3b5b5a2f538517e1cdeb146d50..500a6012e162827aa17f47a489fb44c6382d855a 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 using System;
-using Oobe.Controls;
 using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Components;
@@ -29,44 +28,29 @@ namespace Oobe.Views
     {
         private const int TransitionTime = 750;
         private readonly Extents stackMargin = new Extents(48, 48, 48, 48);
-        //private ViewStack stack;
         private ScalableUI.OrientationalView orientational;
         private Pagination pagination;
+        private bool firstPushed = false;
 
         public MainView(Window win)
             : base()
         {
-            Size2D stackSize = new Size2D(
-                    win.WindowSize.Width - stackMargin.Start - stackMargin.End,
-                    win.WindowSize.Height - stackMargin.Top - stackMargin.Bottom);
-
             BackgroundImage = NUIApplication.Current.DirectoryInfo.Resource + "0_BG_dark.png";
             MaxMargin = 0.25f;
+            //Padding = stackMargin;
+
+            Size2D orientationalSize = new Size2D(
+                (int)(this.Size.Width - stackMargin.Start - stackMargin.End),
+                (int)(this.Size.Height - stackMargin.Top - stackMargin.Bottom));
 
-            /* For testing other resolutions
-            stackSize.Width = 1280 - stackMargin.Start - stackMargin.End;
-            stackSize.Height = 720 - stackMargin.Top - stackMargin.Bottom;
-            */
-
-            //stack = new ViewStack()
-            //{
-            //    ScrollDuration = TransitionTime,
-            //    Position2D = new Position2D(stackMargin.Start, stackMargin.Top),
-            //    Size2D = stackSize,
-            //    PagesRightPadding = stackMargin.Start,
-            //    PagesLeftPadding = (int)(0.5f * stackSize.Width),
-            //    ClippingMode = ClippingModeType.Disabled,
-            //};
+            Tizen.Log.Debug("oobe", $"OrientationalSize: {orientationalSize.Width} {orientationalSize.Height}");
+            Tizen.Log.Debug("oobe", $"this.Size: {this.Size.Width} {this.Size.Height}");
 
             orientational = new ScalableUI.OrientationalView
             {
                 LandscapeMode = ScalableUI.OrientationalView.Mode.Stacking,
-                PositionUsesPivotPoint = true,
-                ParentOrigin = Position.ParentOriginCenter,
-                PivotPoint = Position.PivotPointCenter,
-                //Position2D = new Position2D(0, 0),
-                Padding = stackMargin,
-                Size2D = this.Size
+                Size = orientationalSize,
+                Position2D = new Position2D(0, 0),
             };
 
             Add(orientational);
@@ -84,7 +68,6 @@ namespace Oobe.Views
             };
             pagination.IndicatorSpacing = 12;
 
-            //Add(stack);
             Add(pagination);
         }
 
@@ -115,16 +98,18 @@ namespace Oobe.Views
             view.HeightResizePolicy = ResizePolicyType.FillToParent;
             view.WidthResizePolicy = ResizePolicyType.FillToParent;
 
-            pagination.SelectedIndex = pagination.SelectedIndex + 1;
+            if (firstPushed)
+            {
+                pagination.SelectedIndex = pagination.SelectedIndex + 1;
+            }
+            firstPushed = true;
             orientational.Add(view);
-            //stack.Push(view);
         }
 
         public void Pop()
         {
             pagination.SelectedIndex = pagination.SelectedIndex - 1;
             orientational.RemoveLastAdded();
-            //stack.Pop();
         }
 
         protected override void Dispose(DisposeTypes type)
@@ -136,7 +121,6 @@ namespace Oobe.Views
 
             if (type == DisposeTypes.Explicit)
             {
-                //stack.Dispose();
                 pagination.Dispose();
                 orientational.Dispose();
             }