Text decorator - It consumes tap, double tap and long press events on handles. 89/78889/3
authorVictor Cebollada <v.cebollada@samsung.com>
Thu, 7 Jul 2016 08:17:08 +0000 (09:17 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Fri, 8 Jul 2016 14:47:42 +0000 (15:47 +0100)
* If these events are not consumed by the text-decorator
  they are sent to the text-control causing the selection
  of the word under the handle.

Change-Id: I888a4d17ea5a72806cb36786b2d4e8a04689b8b7
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali-toolkit/internal/text/decorator/text-decorator.cpp

index 74fc924..cc76691 100644 (file)
@@ -623,11 +623,18 @@ struct Decorator::Impl : public ConnectionTracker
 
   void SetupGestures()
   {
 
   void SetupGestures()
   {
+    // Will consume tap gestures on handles.
     mTapDetector = TapGestureDetector::New();
     mTapDetector = TapGestureDetector::New();
-    mTapDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnTap );
 
 
-    mPanGestureDetector = PanGestureDetector::New();
-    mPanGestureDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnPan );
+    // Will consume double tap gestures on handles.
+    mTapDetector.SetMaximumTapsRequired( 2u );
+
+    // Will consume long press gestures on handles.
+    mLongPressDetector = LongPressGestureDetector::New();
+
+    // Detects pan gestures on handles.
+    mPanDetector = PanGestureDetector::New();
+    mPanDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnPan );
   }
 
   void CreateActiveLayer()
   }
 
   void CreateActiveLayer()
@@ -695,8 +702,15 @@ struct Decorator::Impl : public ConnectionTracker
         grabHandle.actor.SetColor( mHandleColor );
 
         grabHandle.grabArea.TouchSignal().Connect( this, &Decorator::Impl::OnGrabHandleTouched );
         grabHandle.actor.SetColor( mHandleColor );
 
         grabHandle.grabArea.TouchSignal().Connect( this, &Decorator::Impl::OnGrabHandleTouched );
-        mTapDetector.Attach( grabHandle.grabArea );
-        mPanGestureDetector.Attach( grabHandle.grabArea );
+
+        // The grab handle's actor is attached to the tap and long press detectors in order to consume these events.
+        // Note that no callbacks are connected to any signal emitted by the tap and long press detectors.
+        mTapDetector.Attach( grabHandle.actor );
+        mLongPressDetector.Attach( grabHandle.actor );
+
+        // The grab handle's area is attached to the pan detector.
+        // The OnPan() method is connected to the signals emitted by the pan detector.
+        mPanDetector.Attach( grabHandle.grabArea );
 
         mActiveLayer.Add( grabHandle.actor );
       }
 
         mActiveLayer.Add( grabHandle.actor );
       }
@@ -755,10 +769,17 @@ struct Decorator::Impl : public ConnectionTracker
         primary.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
         primary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
 
         primary.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
         primary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
 
-        mTapDetector.Attach( primary.grabArea );
-        mPanGestureDetector.Attach( primary.grabArea );
         primary.grabArea.TouchSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
 
         primary.grabArea.TouchSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
 
+        // The handle's actor is attached to the tap and long press detectors in order to consume these events.
+        // Note that no callbacks are connected to any signal emitted by the tap and long press detectors.
+        mTapDetector.Attach( primary.actor );
+        mLongPressDetector.Attach( primary.actor );
+
+        // The handle's area is attached to the pan detector.
+        // The OnPan() method is connected to the signals emitted by the pan detector.
+        mPanDetector.Attach( primary.grabArea );
+
         primary.actor.Add( primary.grabArea );
 
         CreateHandleMarker( primary, mHandleImages[LEFT_SELECTION_HANDLE_MARKER][HANDLE_IMAGE_RELEASED], LEFT_SELECTION_HANDLE );
         primary.actor.Add( primary.grabArea );
 
         CreateHandleMarker( primary, mHandleImages[LEFT_SELECTION_HANDLE_MARKER][HANDLE_IMAGE_RELEASED], LEFT_SELECTION_HANDLE );
@@ -792,10 +813,17 @@ struct Decorator::Impl : public ConnectionTracker
         secondary.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
         secondary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
 
         secondary.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
         secondary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
 
-        mTapDetector.Attach( secondary.grabArea );
-        mPanGestureDetector.Attach( secondary.grabArea );
         secondary.grabArea.TouchSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
 
         secondary.grabArea.TouchSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
 
+        // The handle's actor is attached to the tap and long press detectors in order to consume these events.
+        // Note that no callbacks are connected to any signal emitted by the tap and long press detectors.
+        mTapDetector.Attach( secondary.actor );
+        mLongPressDetector.Attach( secondary.actor );
+
+        // The handle's area is attached to the pan detector.
+        // The OnPan() method is connected to the signals emitted by the pan detector.
+        mPanDetector.Attach( secondary.grabArea );
+
         secondary.actor.Add( secondary.grabArea );
 
         CreateHandleMarker( secondary, mHandleImages[RIGHT_SELECTION_HANDLE_MARKER][HANDLE_IMAGE_RELEASED], RIGHT_SELECTION_HANDLE  );
         secondary.actor.Add( secondary.grabArea );
 
         CreateHandleMarker( secondary, mHandleImages[RIGHT_SELECTION_HANDLE_MARKER][HANDLE_IMAGE_RELEASED], RIGHT_SELECTION_HANDLE  );
@@ -1085,14 +1113,6 @@ struct Decorator::Impl : public ConnectionTracker
     }
   }
 
     }
   }
 
-  void OnTap( Actor actor, const TapGesture& tap )
-  {
-    if( actor == mHandle[GRAB_HANDLE].actor )
-    {
-      // TODO
-    }
-  }
-
   void DoPan( HandleImpl& handle, HandleType type, const PanGesture& gesture )
   {
     if( Gesture::Started == gesture.state )
   void DoPan( HandleImpl& handle, HandleType type, const PanGesture& gesture )
   {
     if( Gesture::Started == gesture.state )
@@ -1637,8 +1657,10 @@ struct Decorator::Impl : public ConnectionTracker
 
   ControllerInterface& mController;
 
 
   ControllerInterface& mController;
 
-  TapGestureDetector  mTapDetector;
-  PanGestureDetector  mPanGestureDetector;
+  TapGestureDetector       mTapDetector;
+  PanGestureDetector       mPanDetector;
+  LongPressGestureDetector mLongPressDetector;
+
   Timer               mCursorBlinkTimer;          ///< Timer to signal cursor to blink
   Timer               mScrollTimer;               ///< Timer used to scroll the text when the grab handle is moved close to the edges.
 
   Timer               mCursorBlinkTimer;          ///< Timer to signal cursor to blink
   Timer               mScrollTimer;               ///< Timer used to scroll the text when the grab handle is moved close to the edges.