[NUI] Add/change scroll event (#1330)
authorneostom432 <31119276+neostom432@users.noreply.github.com>
Tue, 21 Jan 2020 02:20:01 +0000 (11:20 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 21 Jan 2020 02:20:01 +0000 (11:20 +0900)
* [NUI] Add/change scroll event

ScrollStartDragEvent      - Emitted when panning is start
ScrollEndDragEvent        - Emitted when panning is end
ScrollAnimationStartEvent - Emitted when scroll animation is start
ScrollAnimationEndEvent   - Emitted when scroll animation is end

* [NUI] change name of scroll event and its comment

Co-authored-by: krown <neostom432@nate.com>
src/Tizen.NUI.Components/Controls/ScrollableBase.cs

index 1e64db7..42b780b 100755 (executable)
@@ -281,20 +281,39 @@ namespace Tizen.NUI.Components
         }
 
         /// <summary>
-        /// An event emitted when the scrolling starts, user can subscribe or unsubscribe to this event handler.<br />
+        /// An event emitted when user starts dragging ScrollableBase, user can subscribe or unsubscribe to this event handler.<br />
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public event EventHandler<ScrollEventArgs> ScrollStartedEvent;
+        public event EventHandler<ScrollEventArgs> ScrollDragStartEvent;
 
         /// <summary>
-        /// An event emitted when the scrolling ends, user can subscribe or unsubscribe to this event handler.<br />
+        /// An event emitted when user stops dragging ScrollableBase, user can subscribe or unsubscribe to this event handler.<br />
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public event EventHandler<ScrollEventArgs> ScrollEndedEvent;
+        public event EventHandler<ScrollEventArgs> ScrollDragEndEvent;
+
+
+        /// <summary>
+        /// An event emitted when the scrolling slide animation starts, user can subscribe or unsubscribe to this event handler.<br />
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public event EventHandler<ScrollEventArgs> ScrollAnimationStartEvent;
+
+        /// <summary>
+        /// An event emitted when the scrolling slide animation ends, user can subscribe or unsubscribe to this event handler.<br />
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public event EventHandler<ScrollEventArgs> ScrollAnimationEndEvent;
+
+
 
         private Animation scrollAnimation;
         private float maxScrollDistance;
@@ -362,16 +381,28 @@ namespace Tizen.NUI.Components
             mScrollingChild = new View();
         }
 
-        private void OnScrollStart()
+        private void OnScrollDragStart()
+        {
+            ScrollEventArgs eventArgs = new ScrollEventArgs();
+            ScrollDragStartEvent?.Invoke(this, eventArgs);
+        }
+
+        private void OnScrollDragEnd()
+        {
+            ScrollEventArgs eventArgs = new ScrollEventArgs();
+            ScrollDragEndEvent?.Invoke(this, eventArgs);
+        }
+
+        private void OnScrollAnimationStart()
         {
             ScrollEventArgs eventArgs = new ScrollEventArgs();
-            ScrollStartedEvent?.Invoke(this, eventArgs);
+            ScrollAnimationStartEvent?.Invoke(this, eventArgs);
         }
 
-        private void OnScrollEnd()
+        private void OnScrollAnimationEnd()
         {
             ScrollEventArgs eventArgs = new ScrollEventArgs();
-            ScrollEndedEvent?.Invoke(this, eventArgs);
+            ScrollAnimationEndEvent?.Invoke(this, eventArgs);
         }
 
         private void StopScroll()
@@ -382,7 +413,7 @@ namespace Tizen.NUI.Components
                 {
                     Debug.WriteLineIf(LayoutDebugScrollableBase, "StopScroll Animation Playing");
                     scrollAnimation.Stop(Animation.EndActions.Cancel);
-                    OnScrollEnd();
+                    OnScrollAnimationEnd();
                 }
                 scrollAnimation.Clear();
             }
@@ -417,7 +448,7 @@ namespace Tizen.NUI.Components
             scrollAnimation.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine);
             scrollAnimation.AnimateTo(mScrollingChild, (ScrollingDirection == Direction.Horizontal) ? "PositionX" : "PositionY", axisPosition);
             scrolling = true;
-            OnScrollStart();
+            OnScrollAnimationStart();
             scrollAnimation.Play();
         }
 
@@ -625,6 +656,7 @@ namespace Tizen.NUI.Components
                 }
                 maxScrollDistance = CalculateMaximumScrollDistance();
                 totalDisplacementForPan = 0.0f;
+                OnScrollDragStart();
             }
             else if (e.PanGesture.State == Gesture.StateType.Continuing)
             {
@@ -647,6 +679,7 @@ namespace Tizen.NUI.Components
                 float flickDisplacement = CalculateDisplacementFromVelocity(axisVelocity);
 
                 Debug.WriteLineIf(LayoutDebugScrollableBase, "FlickDisplacement:" + flickDisplacement + "TotalDisplacementForPan:" + totalDisplacementForPan);
+                OnScrollDragEnd();
 
                 if (flickDisplacement > 0 | flickDisplacement < 0)// Flick detected
                 {
@@ -680,7 +713,7 @@ namespace Tizen.NUI.Components
         private void ScrollAnimationFinished(object sender, EventArgs e)
         {
             scrolling = false;
-            OnScrollEnd();
+            OnScrollAnimationEnd();
         }
 
     }