Revert "[Tizen] Revert "Changes after touch consumed behaviour change""
authorSunghyun Kim <scholb.kim@samsung.com>
Wed, 23 Sep 2020 02:21:38 +0000 (11:21 +0900)
committerSunghyun Kim <scholb.kim@samsung.com>
Wed, 23 Sep 2020 02:21:38 +0000 (11:21 +0900)
This reverts commit 2d1bfc90245bb9327656144df94441d947502d16.

12 files changed:
dali-toolkit/internal/controls/buttons/button-impl.cpp
dali-toolkit/internal/controls/popup/popup-impl.cpp
dali-toolkit/internal/controls/popup/popup-impl.h [changed mode: 0755->0644]
dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp [changed mode: 0755->0644]
dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp [changed mode: 0755->0644]
dali-toolkit/internal/controls/slider/slider-impl.cpp [changed mode: 0755->0644]
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp [changed mode: 0755->0644]
dali-toolkit/internal/text/decorator/text-decorator.cpp
dali-toolkit/public-api/controls/control-impl.cpp [changed mode: 0755->0644]
docs/content/example-code/properties.cpp

index 3cdac41..6d45eed 100644 (file)
@@ -630,11 +630,7 @@ bool Button::OnAccessibilityActivated()
 
 bool Button::OnTouch( Actor actor, const TouchEvent& touch )
 {
-
-  // Only events are processed when the button is not disabled
-  auto result( false );
-
-  if( !IsDisabled() )
+  if( !IsDisabled() && (actor == touch.GetHitActor(0)) )
   {
     if ( 1 == touch.GetPointCount() )
     {
@@ -675,9 +671,8 @@ bool Button::OnTouch( Actor actor, const TouchEvent& touch )
       // Sets the button state to the default
       mButtonPressedState = UNPRESSED;
     }
-    result = true;
   }
-  return result;
+  return false;
 }
 
 bool Button::OnKeyboardEnter()
index eb16bab..b95e648 100644 (file)
@@ -330,14 +330,14 @@ void Popup::OnInitialize()
   mPopupLayout.SetFitHeight( 0 ); // Set row to fit.
   mPopupLayout.SetFitHeight( 1 ); // Set row to fit.
 
-  mPopupLayout.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
-
   mPopupContainer.Add( mPopupLayout );
 
   // Any content after this point which is added to Self() will be re-parented to mContent.
   mAlterAddedChild = true;
 
   SetAsKeyboardFocusGroup( true );
+
+  SetupTouch();
 }
 
 Popup::~Popup()
@@ -593,9 +593,6 @@ void Popup::SetPopupBackgroundImage( Actor image )
   mPopupBackgroundImage.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
   mPopupBackgroundImage.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
 
-  // OnDialogTouched only consumes the event. It prevents the touch event to be caught by the backing.
-  mPopupBackgroundImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
-
   // Set the popup border to be slightly larger than the layout contents.
   UpdateBackgroundPositionAndSize();
 
@@ -938,7 +935,6 @@ Toolkit::Control Popup::CreateBacking()
 
   // Default to being transparent.
   backing.SetProperty( Actor::Property::COLOR_ALPHA, 0.0f );
-  backing.TouchedSignal().Connect( this, &Popup::OnBackingTouched );
   backing.WheelEventSignal().Connect( this, &Popup::OnBackingWheelEvent );
   return backing;
 }
@@ -1119,7 +1115,11 @@ const std::string& Popup::GetTailRightImage() const
 
 void Popup::SetTouchTransparent( bool enabled )
 {
-  mTouchTransparent = enabled;
+  if( mTouchTransparent != enabled )
+  {
+    mTouchTransparent = enabled;
+    SetupTouch();
+  }
 }
 
 const bool Popup::IsTouchTransparent() const
@@ -1534,26 +1534,18 @@ bool Popup::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra
 
 bool Popup::OnBackingTouched( Actor actor, const TouchEvent& touch )
 {
-  // Allow events to pass through if touch transparency is enabled.
-  if( mTouchTransparent )
-  {
-    return false;
-  }
-
-  if( touch.GetPointCount() > 0 )
+  // Allow events to pass through if the backing isn't the hit-actor
+  if( (touch.GetHitActor(0) == actor) &&
+      (touch.GetPointCount() > 0) &&
+      (touch.GetState( 0 ) == PointState::DOWN))
   {
-    if( touch.GetState( 0 ) == PointState::DOWN )
-    {
-      // Guard against destruction during signal emission.
-      Toolkit::Popup handle( GetOwner() );
+    // Guard against destruction during signal emission.
+    Toolkit::Popup handle( GetOwner() );
 
-      mTouchedOutsideSignal.Emit();
-    }
+    mTouchedOutsideSignal.Emit();
   }
 
-  // Block anything behind backing becoming touched.
-  mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
-  return true;
+  return false;
 }
 
 bool Popup::OnBackingWheelEvent( Actor actor, const WheelEvent& event )
@@ -1564,22 +1556,13 @@ bool Popup::OnBackingWheelEvent( Actor actor, const WheelEvent& event )
     return false;
   }
 
-  // Consume wheel event in dimmed backing actor.
-  mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
   return true;
 }
 
 bool Popup::OnDialogTouched( Actor actor, const TouchEvent& touch )
 {
-  // Allow events to pass through if touch transparency is enabled.
-  if( mTouchTransparent )
-  {
-    return false;
-  }
-
-  // Consume event (stops backing actor receiving touch events)
-  mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
-  return true;
+  // Only connecting this so the backing does not become the default hit-actor and inadvertently closes the popup
+  return false;
 }
 
 void Popup::OnSceneConnection( int depth )
@@ -1975,6 +1958,26 @@ Actor Popup::GetNextKeyboardFocusableActor( Actor currentFocusedActor, Toolkit::
   return nextFocusableActor;
 }
 
+void Popup::SetupTouch()
+{
+  if( ! mTouchTransparent )
+  {
+    // Connect all the signals and set us up to consume all touch events
+    mBacking.TouchedSignal().Connect( this, &Popup::OnBackingTouched );
+    mPopupBackgroundImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
+    mPopupLayout.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
+    mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
+  }
+  else
+  {
+    // We are touch transparent so disconnect all signals and ensure our layer does not consumed all touch events
+    mBacking.TouchedSignal().Disconnect( this, &Popup::OnBackingTouched );
+    mPopupBackgroundImage.TouchedSignal().Disconnect( this, &Popup::OnDialogTouched );
+    mPopupLayout.TouchedSignal().Disconnect( this, &Popup::OnDialogTouched );
+    mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, false );
+  }
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
old mode 100755 (executable)
new mode 100644 (file)
index dc99f93..a7f7120
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_POPUP_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * 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.
@@ -499,6 +499,12 @@ private:
    */
   void AddFocusableChildrenRecursive( Actor parent, std::vector< Actor >& focusableActors );
 
+  /**
+   * Sets up the touch signals connections as required.
+   * @note This must be called after all the members have been created.
+   */
+  void SetupTouch();
+
 private:
 
   // Undefined.
old mode 100755 (executable)
new mode 100644 (file)
index 6f96bef..c442fb8
@@ -1145,7 +1145,7 @@ bool ItemView::OnTouch( Actor actor, const TouchEvent& touch )
     RemoveAnimation(mScrollAnimation);
   }
 
-  return true; // consume since we're potentially scrolling
+  return false; // Do not consume as we're potentially scrolling (detecting pan gestures)
 }
 
 void ItemView::OnPan( const PanGesture& gesture )
old mode 100755 (executable)
new mode 100644 (file)
index 7a88106..1273cd1
@@ -2129,7 +2129,7 @@ bool ScrollView::OnTouch( Actor actor, const TouchEvent& touch )
     mScrollInterrupted = false;
   }
 
-  return true;
+  return false;
 }
 
 bool ScrollView::OnWheelEvent( Actor actor, const WheelEvent& event)
old mode 100755 (executable)
new mode 100644 (file)
index 638f115..742311a
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * 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.
@@ -240,7 +240,7 @@ bool Slider::OnTouch(Actor actor, const TouchEvent& touch)
     }
   }
 
-  return true;
+  return false;
 }
 
 void Slider::OnPan( Actor actor, const PanGesture& gesture )
index 0159b22..7576bc1 100644 (file)
@@ -1865,7 +1865,7 @@ void TextEditor::OnSceneConnection( int depth )
 
 bool TextEditor::OnTouched( Actor actor, const TouchEvent& touch )
 {
-  return true;
+  return false;
 }
 
 void TextEditor::OnIdleSignal()
index b849409..6952c74 100644 (file)
@@ -1898,7 +1898,7 @@ void TextField::OnSceneConnection( int depth )
 
 bool TextField::OnTouched( Actor actor, const TouchEvent& touch )
 {
-  return true;
+  return false;
 }
 
 void TextField::OnIdleSignal()
old mode 100755 (executable)
new mode 100644 (file)
index d1ad520..994932e
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * 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.
@@ -211,7 +211,7 @@ bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchEvent& data
     }
     mPointDown = false;
   }
-  return true;
+  return false;
 }
 
 const std::string& DragAndDropDetector::GetContent() const
index ae4140f..2a57d4d 100644 (file)
@@ -1388,8 +1388,7 @@ struct Decorator::Impl : public ConnectionTracker
       SetHandleImage( GRAB_HANDLE );
     }
 
-    // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
-    return true;
+    return false;
   }
 
   bool OnHandleOneTouched( Actor actor, const TouchEvent& touch )
@@ -1419,8 +1418,7 @@ struct Decorator::Impl : public ConnectionTracker
       SetHandleImage( LEFT_SELECTION_HANDLE );
     }
 
-    // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
-    return true;
+    return false;
   }
 
   bool OnHandleTwoTouched( Actor actor, const TouchEvent& touch )
@@ -1450,8 +1448,7 @@ struct Decorator::Impl : public ConnectionTracker
       SetHandleImage( RIGHT_SELECTION_HANDLE );
     }
 
-    // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
-    return true;
+    return false;
   }
 
   void HandleResetPosition( PropertyNotification& source )
index c840964..61be376 100644 (file)
@@ -113,7 +113,7 @@ public:
     valueText << touchedCount;
     mTagText.SetProperty( TextLabel::Property::TEXT, valueText.str() );
 
-    return true; // Consumed
+    return true; // Consumed meaning any gestures will be cancelled
   }
   // C++ EXAMPLE END