Revert "[NUI] Add direction & displacement into ScrollOutOfBound event."
authorJiyun Yang <ji.yang@samsung.com>
Fri, 27 Nov 2020 07:43:17 +0000 (16:43 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 27 Nov 2020 07:41:37 +0000 (16:41 +0900)
This reverts commit bd6e9d90575a3f6f6daebd4f1ca716fe86a24843.

src/Tizen.NUI.Components/Controls/ScrollableBase.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ScrollableBaseOutOfBoundSample.cs

index bd3a6d3..f652788 100755 (executable)
@@ -62,52 +62,39 @@ namespace Tizen.NUI.Components
     public class ScrollOutOfBoundEventArgs : EventArgs
     {
         /// <summary>
-        /// The direction to be touched.
+        /// The bound to be scrolled out of.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public enum Direction
+        public enum Bound
         {
             /// <summary>
-            /// Upwards.
+            /// Top bound.
             /// </summary>
             [EditorBrowsable(EditorBrowsableState.Never)]
-            Up,
+            Top,
 
             /// <summary>
-            /// Downwards.
+            /// Bottom bound.
             /// </summary>
             [EditorBrowsable(EditorBrowsableState.Never)]
-            Down,
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="direction">Current pan direction</param>
-        /// <param name="displacement">Current total displacement</param>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public ScrollOutOfBoundEventArgs(Direction direction, float displacement)
-        {
-            PanDirection = direction;
-            Displacement = displacement;
+            Bottom
         }
 
         /// <summary>
-        /// Current pan direction of ContentContainer.
+        /// Default constructor.
         /// </summary>
+        /// <param name="bound">Current scrollable bound</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public Direction PanDirection
+        public ScrollOutOfBoundEventArgs(Bound bound)
         {
-            get;
+            ScrollableBound = bound;
         }
 
         /// <summary>
-        /// Current total displacement of ContentContainer.
-        /// if its value is greater than 0, it is at the top/left;
-        /// if less than 0, it is at the bottom/right.
+        /// Current position of ContentContainer.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public float Displacement
+        public Bound ScrollableBound
         {
             get;
         }
@@ -1054,12 +1041,12 @@ namespace Tizen.NUI.Components
             isVerticalShadowShown = false;
         }
 
-        private void DragVerticalShadow(float totalPanDisplacement, float panDisplacement)
+        private void DragVerticalShadow(float displacement)
         {
             if (ScrollingDirection != Direction.Vertical)
                 return;
 
-            if (totalPanDisplacement > 0) // downwards
+            if ((int)displacement > 0) // downwards
             {
                 // check if reaching at the top.
                 if ((int)finalTargetPosition != 0)
@@ -1068,16 +1055,12 @@ namespace Tizen.NUI.Components
                 // save start displacement, and re-calculate displacement.
                 if (!isVerticalShadowShown)
                 {
-                    startShowShadowDisplacement = totalPanDisplacement;
+                    startShowShadowDisplacement = displacement;
+                    OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Bound.Top);
                 }
                 isVerticalShadowShown = true;
 
-                // trigger event
-                ScrollOutOfBoundEventArgs.Direction direction = panDisplacement > 0 ?
-                    ScrollOutOfBoundEventArgs.Direction.Down : ScrollOutOfBoundEventArgs.Direction.Up;
-                OnScrollOutOfBound(direction, totalPanDisplacement);
-
-                float newDisplacement = (int)totalPanDisplacement < (int)startShowShadowDisplacement ? 0 : totalPanDisplacement - startShowShadowDisplacement;
+                float newDisplacement = (int)displacement < (int)startShowShadowDisplacement ? 0 : displacement - startShowShadowDisplacement;
 
                 // scale limit of width is 60%.
                 float widthScale = newDisplacement / verticalShadowScaleHeightLimit;
@@ -1086,7 +1069,7 @@ namespace Tizen.NUI.Components
                 // scale limit of height is 300%.
                 verticalTopShadowView.SizeHeight = newDisplacement > verticalShadowScaleHeightLimit ? verticalShadowScaleHeightLimit : newDisplacement;
             }
-            else if (totalPanDisplacement < 0) // upwards
+            else if ((int)displacement < 0) // upwards
             {
                 // check if reaching at the bottom.
                 if (-(int)finalTargetPosition != (int)maxScrollDistance)
@@ -1095,16 +1078,12 @@ namespace Tizen.NUI.Components
                 // save start displacement, and re-calculate displacement.
                 if (!isVerticalShadowShown)
                 {
-                    startShowShadowDisplacement = totalPanDisplacement;
+                    startShowShadowDisplacement = displacement;
+                    OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Bound.Bottom);
                 }
                 isVerticalShadowShown = true;
 
-                // trigger event
-                ScrollOutOfBoundEventArgs.Direction direction = panDisplacement > 0 ?
-                    ScrollOutOfBoundEventArgs.Direction.Down : ScrollOutOfBoundEventArgs.Direction.Up;
-                OnScrollOutOfBound(direction, totalPanDisplacement);
-
-                float newDisplacement = (int)startShowShadowDisplacement < (int)totalPanDisplacement ? 0 : startShowShadowDisplacement - totalPanDisplacement;
+                float newDisplacement = (int)startShowShadowDisplacement < (int)displacement ? 0 : startShowShadowDisplacement - displacement;
 
                 // scale limit of width is 60%.
                 float widthScale = newDisplacement / verticalShadowScaleHeightLimit;
@@ -1163,9 +1142,9 @@ namespace Tizen.NUI.Components
             isVerticalShadowShown = false;
         }
 
-        private void OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Direction direction, float displacement)
+        private void OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Bound bound)
         {
-            ScrollOutOfBoundEventArgs args = new ScrollOutOfBoundEventArgs(direction, displacement);
+            ScrollOutOfBoundEventArgs args = new ScrollOutOfBoundEventArgs(bound);
             ScrollOutOfBound?.Invoke(this, args);
         }
 
@@ -1209,7 +1188,7 @@ namespace Tizen.NUI.Components
                         ScrollBy(panGesture.Displacement.Y, false);
                     }
                     totalDisplacementForPan += panGesture.Displacement.Y;
-                    DragVerticalShadow(totalDisplacementForPan, panGesture.Displacement.Y);
+                    DragVerticalShadow(totalDisplacementForPan);
                 }
                 Debug.WriteLineIf(LayoutDebugScrollableBase, "OnPanGestureDetected Continue totalDisplacementForPan:" + totalDisplacementForPan);
             }
index 390bbfd..08fa5e4 100755 (executable)
@@ -35,7 +35,6 @@ namespace Tizen.NUI.Samples
                 Position = new Position(300, 100),
                 Size = new Size(400, 300),
                 ScrollingDirection = Components.ScrollableBase.Direction.Vertical,
-                EnableOverShootingEffect = true,
             };
             mScrollableBase.ScrollOutOfBound += OnScrollOutOfBound;
 
@@ -64,19 +63,13 @@ namespace Tizen.NUI.Samples
 
         private void OnScrollOutOfBound(object sender, Components.ScrollOutOfBoundEventArgs e)
         {
-            if (e.Displacement > 100)
+            if (e.ScrollableBound == Components.ScrollOutOfBoundEventArgs.Bound.Top)
             {
-                if (e.PanDirection == Components.ScrollOutOfBoundEventArgs.Direction.Down)
-                {
-                    items[0].Text = $"Reached at the top, panned displacement is {e.Displacement}.";
-                }
+                items[0].Text = "Reached at the top.";
             }
-            else if (0 - e.Displacement > 100)
+            else
             {
-                if (e.PanDirection == Components.ScrollOutOfBoundEventArgs.Direction.Up)
-                {
-                    items[4].Text = $"Reached at the bottom, panned displacement is {e.Displacement}.";
-                }
+                items[4].Text = "Reached at the bottom.";
             }
         }