[NUI] Interrupt pan when popup is popped (#1539)
authorneostom432 <31119276+neostom432@users.noreply.github.com>
Mon, 13 Apr 2020 10:00:13 +0000 (19:00 +0900)
committerGitHub <noreply@github.com>
Mon, 13 Apr 2020 10:00:13 +0000 (19:00 +0900)
Currently, panning is working even if there is popup over component.
As workaround, add PanGestureDetector to Popup to prevent panning.

Additionally, add View to ScrollableBase which is to interrupt touching during scrolling.

src/Tizen.NUI.Components/Controls/Popup.cs
src/Tizen.NUI.Components/Controls/ScrollableBase.cs
src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs

index 3cf1153..0ac8c8a 100755 (executable)
@@ -200,6 +200,7 @@ namespace Tizen.NUI.Components
         private ButtonGroup btGroup = null;
         private Window window = null;
         private Layer container = new Layer();
         private ButtonGroup btGroup = null;
         private Window window = null;
         private Layer container = new Layer();
+        private PanGestureDetector detector = new PanGestureDetector();
         static Popup() { }
 
         /// <summary>
         static Popup() { }
 
         /// <summary>
@@ -733,6 +734,7 @@ namespace Tizen.NUI.Components
 
         private void Initialize()
         {
 
         private void Initialize()
         {
+            detector.Attach(this);
             container.Add(this);
             LeaveRequired = true;
             PropertyChanged += PopupStylePropertyChanged;
             container.Add(this);
             LeaveRequired = true;
             PropertyChanged += PopupStylePropertyChanged;
index f85530a..a9b2f33 100755 (executable)
@@ -350,6 +350,7 @@ namespace Tizen.NUI.Components
         private PanGestureDetector mPanGestureDetector;
         private TapGestureDetector mTapGestureDetector;
         private View mScrollingChild;
         private PanGestureDetector mPanGestureDetector;
         private TapGestureDetector mTapGestureDetector;
         private View mScrollingChild;
+        private View mInterruptTouchingChild;
         private float multiplier =1.0f;
         private bool scrolling = false;
         private float ratioOfScreenWidthToCompleteScroll = 0.5f;
         private float multiplier =1.0f;
         private bool scrolling = false;
         private float ratioOfScreenWidthToCompleteScroll = 0.5f;
@@ -382,6 +383,18 @@ namespace Tizen.NUI.Components
             mScrollingChild = new View();
             mScrollingChild.Name = "DefaultScrollingChild";
 
             mScrollingChild = new View();
             mScrollingChild.Name = "DefaultScrollingChild";
 
+            //Interrupt touching when panning is started;
+            mInterruptTouchingChild = new View()
+            {
+                Name = "InterruptTouchingChild",
+                Size = new Size(Window.Instance.WindowSize),
+                BackgroundColor = Color.Transparent,
+            };
+
+            mInterruptTouchingChild.TouchEvent += (object source, View.TouchEventArgs args) => {
+                return true;
+            };
+
             Layout = new ScrollableBaseCustomLayout();
         }
 
             Layout = new ScrollableBaseCustomLayout();
         }
 
@@ -399,19 +412,17 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public override void OnChildAdd(View view)
         {
         [EditorBrowsable(EditorBrowsableState.Never)]
         public override void OnChildAdd(View view)
         {
-            if(mScrollingChild.Name != "DefaultScrollingChild")
+            if(view.Name != "InterruptTouchingChild")
             {
             {
-                propertyNotification.Notified -= OnPropertyChanged;
-                mScrollingChild.RemovePropertyNotification(propertyNotification);
-            }
-
-            mScrollingChild = view;
-            propertyNotification = mScrollingChild?.AddPropertyNotification("position", PropertyCondition.Step(1.0f));
-            propertyNotification.Notified += OnPropertyChanged;
+                if(mScrollingChild.Name != "DefaultScrollingChild")
+                {
+                    propertyNotification.Notified -= OnPropertyChanged;
+                    mScrollingChild.RemovePropertyNotification(propertyNotification);
+                }
 
 
-            {
-                if (Children.Count > 1)
-                    Log.Error("ScrollableBase", $"Only 1 child should be added to ScrollableBase.");
+                mScrollingChild = view;
+                propertyNotification = mScrollingChild?.AddPropertyNotification("position", PropertyCondition.Step(1.0f));
+                propertyNotification.Notified += OnPropertyChanged;
             }
         }
 
             }
         }
 
@@ -424,10 +435,13 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public override void OnChildRemove(View view)
         {
         [EditorBrowsable(EditorBrowsableState.Never)]
         public override void OnChildRemove(View view)
         {
-            propertyNotification.Notified -= OnPropertyChanged;
-            mScrollingChild.RemovePropertyNotification(propertyNotification);
+            if(view.Name != "InterruptTouchingChild")
+            {
+                propertyNotification.Notified -= OnPropertyChanged;
+                mScrollingChild.RemovePropertyNotification(propertyNotification);
 
 
-            mScrollingChild = new View();
+                mScrollingChild = new View();
+            }
         }
 
 
         }
 
 
@@ -736,6 +750,7 @@ namespace Tizen.NUI.Components
         {
             if (e.PanGesture.State == Gesture.StateType.Started)
             {
         {
             if (e.PanGesture.State == Gesture.StateType.Started)
             {
+                Add(mInterruptTouchingChild);
                 Debug.WriteLineIf(LayoutDebugScrollableBase, "Gesture Start");
                 if (scrolling && !SnapToPage)
                 {
                 Debug.WriteLineIf(LayoutDebugScrollableBase, "Gesture Start");
                 if (scrolling && !SnapToPage)
                 {
@@ -780,6 +795,8 @@ namespace Tizen.NUI.Components
                     }
                 }
                 totalDisplacementForPan = 0;
                     }
                 }
                 totalDisplacementForPan = 0;
+
+                Remove(mInterruptTouchingChild);
             }
         }
 
             }
         }
 
index 2d9daf8..e8862e9 100755 (executable)
@@ -109,6 +109,7 @@ namespace Tizen.NUI
                             Interop.Actor.Actor_Remove(View.getCPtr(childLayout.Owner.Parent), View.getCPtr(childLayout.Owner));
                             if (NDalicPINVOKE.SWIGPendingException.Pending)
                                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                             Interop.Actor.Actor_Remove(View.getCPtr(childLayout.Owner.Parent), View.getCPtr(childLayout.Owner));
                             if (NDalicPINVOKE.SWIGPendingException.Pending)
                                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                            childLayout.Owner.InternalParent = null;
                         }
                     }
 
                         }
                     }