From: Paul Wisbey Date: Mon, 11 Jul 2016 10:28:03 +0000 (-0700) Subject: Merge "Text decorator - It consumes tap, double tap and long press events on handles... X-Git-Tag: dali_1.1.43~13 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=71e9401257ac2b3612aef56b6b94303cb1d3a849;hp=287b68cccb9fdccf44de630575421f5b2e12ae35 Merge "Text decorator - It consumes tap, double tap and long press events on handles." into devel/master --- diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index 74fc924..cc76691 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -623,11 +623,18 @@ struct Decorator::Impl : public ConnectionTracker void SetupGestures() { + // Will consume tap gestures on handles. 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() @@ -695,8 +702,15 @@ struct Decorator::Impl : public ConnectionTracker 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 ); } @@ -755,10 +769,17 @@ struct Decorator::Impl : public ConnectionTracker 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 ); + // 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 ); @@ -792,10 +813,17 @@ struct Decorator::Impl : public ConnectionTracker 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 ); + // 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 ); @@ -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 ) @@ -1637,8 +1657,10 @@ struct Decorator::Impl : public ConnectionTracker 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.