From: Krzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics Date: Wed, 8 Sep 2021 18:19:42 +0000 (+0200) Subject: Remove animation comments X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fscalable_ui;p=profile%2Fiot%2Fapps%2Fnative%2Foobe.git Remove animation comments Change-Id: I8a8193c8daf2fe2d7f4416042f60415b757509e6 Signed-off-by: Krzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics --- diff --git a/Oobe/Oobe/Controls/ViewStack.cs b/Oobe/Oobe/Controls/ViewStack.cs deleted file mode 100644 index b64e709..0000000 --- a/Oobe/Oobe/Controls/ViewStack.cs +++ /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 -{ - /// - /// ViewStack implemenents stack based navigation in which all child views are stacked over each other - /// and only the most recent child added is visible. - /// - public class ViewStack : View - { - private List views = new List(); - private List viewsToRemove = new List(); - - 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; - } - - /// - /// Informs about transition animation end - /// - public event EventHandler TransitionFinished; - - /// - /// Number of pixels between stack right boundary and newly pushed child view left boundary, - /// which will be applied before starting page entering animation. - /// - /// - public int PagesRightPadding { get; set; } = 0; - - /// - /// Number of pixels between stack right boundary and current top child view left boundary, - /// which will be applied after finishing page leaving animation - /// - public int PagesLeftPadding { get; set; } = 0; - - /// - /// Duration of page entering and page leaving animations - /// - public int ScrollDuration { get; set; } = 125; - - /// - /// Get view currently stacked on Top of ViewStack - /// - public View Current - { - get - { - return views.Count > 0 ? views[views.Count - 1] : null; - } - } - - /// - /// Get view currently stacked under Current - /// - public View Previous - { - get - { - return views.Count > 1 ? views[views.Count - 2] : null; - } - } - - /// - /// Pop Current view with animation - /// - public void Pop() - { - if (Current != null) - { - FinishAnimations(); - RemoveAllDelayedViews(); - StartPageLeaveAnimation(Previous, Current); - StartShowAnimation(Previous); - AddViewToDelayRemove(Current); - views.Remove(Current); - } - } - - /// - /// Pushed new view on stack with animation. - /// - 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)); - } - } - } - } - } -} diff --git a/Oobe/Oobe/Managers/ProcessManager.cs b/Oobe/Oobe/Managers/ProcessManager.cs index c26078e..838d597 100644 --- a/Oobe/Oobe/Managers/ProcessManager.cs +++ b/Oobe/Oobe/Managers/ProcessManager.cs @@ -120,6 +120,7 @@ namespace Oobe } SetDone(); + Tizen.Log.Debug("oobe", "Finished oobe navigation - closing"); NUIApplication.Current.Exit(); } diff --git a/Oobe/Oobe/Oobe.csproj b/Oobe/Oobe/Oobe.csproj index 7525d0d..09e09f5 100644 --- a/Oobe/Oobe/Oobe.csproj +++ b/Oobe/Oobe/Oobe.csproj @@ -16,6 +16,7 @@ + diff --git a/Oobe/Oobe/ScalableUI/OrientationalView.cs b/Oobe/Oobe/ScalableUI/OrientationalView.cs index 49e7b9e..dca36e1 100644 --- a/Oobe/Oobe/ScalableUI/OrientationalView.cs +++ b/Oobe/Oobe/ScalableUI/OrientationalView.cs @@ -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 views = new List(); @@ -268,35 +258,6 @@ namespace ScalableUI } } - /// - /// Pop Current view with animation - /// - public void Pop() - { - if (Current != null) - { - FinishAnimations(); - RemoveAllDelayedViews(); - StartPageLeaveAnimation(Previous, Current); - StartShowAnimation(Previous); - AddViewToDelayRemove(Current); - views.Remove(Current); - } - } - - /// - /// Pushed new view on stack with animation. - /// - 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)); - // } - // } - // } - //} } } diff --git a/Oobe/Oobe/Views/MainView.cs b/Oobe/Oobe/Views/MainView.cs index 4db631e..500a601 100644 --- a/Oobe/Oobe/Views/MainView.cs +++ b/Oobe/Oobe/Views/MainView.cs @@ -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(); }