[NUI] Add NeedGesturePropagation (#3130)
authorJoogabYun <40262755+JoogabYun@users.noreply.github.com>
Mon, 7 Jun 2021 03:03:43 +0000 (12:03 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 8 Jun 2021 05:35:32 +0000 (14:35 +0900)
This is used when the parent view wants to listen to gesture events.

src/Tizen.NUI.Components/Controls/ScrollableBase.cs
src/Tizen.NUI/src/internal/Interop/Interop.Actor.cs
src/Tizen.NUI/src/public/Events/LongPressGestureDetector.cs
src/Tizen.NUI/src/public/Events/PanGestureDetector.cs
src/Tizen.NUI/src/public/Events/PinchGestureDetector.cs
src/Tizen.NUI/src/public/Events/RotationGestureDetector.cs
src/Tizen.NUI/src/public/Events/TapGestureDetector.cs

index 30f871d..9405f47 100755 (executable)
@@ -1325,6 +1325,10 @@ namespace Tizen.NUI.Components
         private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e)
         {
             OnPanGesture(e.PanGesture);
+            if(!((SnapToPage && scrollAnimation != null && scrollAnimation.State == Animation.States.Playing) || e.PanGesture.State == Gesture.StateType.Started))
+            {
+                e.Handled = !((int)finalTargetPosition == 0 || -(int)finalTargetPosition == (int)maxScrollDistance);
+            }
         }
 
         private void OnPanGesture(PanGesture panGesture)
@@ -1371,6 +1375,7 @@ namespace Tizen.NUI.Components
                     DragOverShootingShadow(totalDisplacementForPan, panGesture.Displacement.Y);
                 }
                 Debug.WriteLineIf(LayoutDebugScrollableBase, "OnPanGestureDetected Continue totalDisplacementForPan:" + totalDisplacementForPan);
+
             }
             else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled)
             {
index 9cfc106..70e24a5 100755 (executable)
@@ -140,6 +140,9 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_GetSuggestedMinimumHeight")]
             public static extern float GetSuggestedMinimumHeight(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_SetNeedGesturePropagation")]
+            public static extern float SetNeedGesturePropagation(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2);
         }
     }
 }
index 4d4bad1..b615f33 100755 (executable)
@@ -241,6 +241,7 @@ namespace Tizen.NUI
         {
             private View view;
             private LongPressGesture longPressGesture;
+            private bool handled = true;
 
             /// <summary>
             /// View the attached view.
@@ -277,6 +278,22 @@ namespace Tizen.NUI
                     longPressGesture = value;
                 }
             }
+
+            /// <summary>
+            /// Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing.
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public bool Handled
+            {
+                get => handled;
+                set
+                {
+                    handled = value;
+                    Interop.Actor.SetNeedGesturePropagation(View.getCPtr(view), !value);
+                    if (NDalicPINVOKE.SWIGPendingException.Pending)
+                        throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                }
+            }
         }
     }
 }
index f7228c8..22243f0 100755 (executable)
@@ -565,6 +565,7 @@ namespace Tizen.NUI
         {
             private View view;
             private PanGesture panGesture;
+            private bool handled = true;
 
             /// <summary>
             /// The attached view.
@@ -601,6 +602,22 @@ namespace Tizen.NUI
                     panGesture = value;
                 }
             }
+
+            /// <summary>
+            /// Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing.
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public bool Handled
+            {
+                get => handled;
+                set
+                {
+                    handled = value;
+                    Interop.Actor.SetNeedGesturePropagation(View.getCPtr(view), !value);
+                    if (NDalicPINVOKE.SWIGPendingException.Pending)
+                        throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                }
+            }
         }
 
         internal class Property
index 9998ee7..dd73d11 100755 (executable)
@@ -163,6 +163,7 @@ namespace Tizen.NUI
         {
             private View view;
             private PinchGesture pinchGesture;
+            private bool handled = true;
 
             /// <summary>
             /// The attached view.
@@ -199,6 +200,22 @@ namespace Tizen.NUI
                     pinchGesture = value;
                 }
             }
+
+            /// <summary>
+            /// Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing.
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public bool Handled
+            {
+                get => handled;
+                set
+                {
+                    handled = value;
+                    Interop.Actor.SetNeedGesturePropagation(View.getCPtr(view), !value);
+                    if (NDalicPINVOKE.SWIGPendingException.Pending)
+                        throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                }
+            }
         }
     }
 }
index c7b64a1..f3fb3dd 100755 (executable)
@@ -163,6 +163,7 @@ namespace Tizen.NUI
         {
             private View view;
             private RotationGesture rotationGesture;
+            private bool handled = true;
 
             /// <summary>
             /// The attached view.
@@ -199,6 +200,22 @@ namespace Tizen.NUI
                     rotationGesture = value;
                 }
             }
+
+            /// <summary>
+            /// Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing.
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public bool Handled
+            {
+                get => handled;
+                set
+                {
+                    handled = value;
+                    Interop.Actor.SetNeedGesturePropagation(View.getCPtr(view), !value);
+                    if (NDalicPINVOKE.SWIGPendingException.Pending)
+                        throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                }
+            }
         }
 
     }
index 0701419..a657615 100755 (executable)
@@ -214,6 +214,7 @@ namespace Tizen.NUI
 
             if (_detectedEventHandler != null)
             {
+                e.Handled = true;
                 //here we send all data to user event handlers
                 _detectedEventHandler(this, e);
             }
@@ -229,6 +230,7 @@ namespace Tizen.NUI
         {
             private View _view;
             private TapGesture _tapGesture;
+            private bool handled = true;
 
             /// <summary>
             /// The attached view.
@@ -265,6 +267,22 @@ namespace Tizen.NUI
                     _tapGesture = value;
                 }
             }
+
+            /// <summary>
+            /// Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing.
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public bool Handled
+            {
+                get => handled;
+                set
+                {
+                    handled = value;
+                    Interop.Actor.SetNeedGesturePropagation(View.getCPtr(_view), !value);
+                    if (NDalicPINVOKE.SWIGPendingException.Pending)
+                        throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                }
+            }
         }
     }
 }