Merge "Fix mGestureRecognizer leak" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pan-gesture / pan-gesture-processor.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/event/events/pan-gesture/pan-gesture-processor.h>
20
21 #if defined(DEBUG_ENABLED)
22 #include <sstream>
23 #endif
24
25 // EXTERNAL INCLUDES
26 #include <algorithm>
27
28 // INTERNAL INCLUDES
29 #include <dali/public-api/actors/actor.h>
30 #include <dali/public-api/common/dali-common.h>
31 #include <dali/public-api/events/pan-gesture.h>
32 #include <dali/public-api/math/vector2.h>
33 #include <dali/internal/event/events/pan-gesture/pan-gesture-event.h>
34 #include <dali/integration-api/debug.h>
35 #include <dali/internal/event/common/scene-impl.h>
36 #include <dali/internal/event/render-tasks/render-task-impl.h>
37 #include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
38 #include <dali/internal/event/events/multi-point-event-util.h>
39 #include <dali/internal/event/events/pan-gesture/pan-gesture-recognizer.h>
40 #include <dali/internal/event/events/gesture-requests.h>
41
42 namespace Dali
43 {
44
45 namespace Internal
46 {
47
48 namespace // unnamed namespace
49 {
50
51 #if defined(DEBUG_ENABLED)
52 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_PAN_PROCESSOR" );
53
54 const char * GESTURE_STATES[ 6 ] =
55 {
56   "Clear",
57   "Started",
58   "Continuing",
59   "Finished",
60   "Cancelled",
61   "Possible"
62 };
63
64 #endif // defined(DEBUG_ENABLED)
65
66 const unsigned long MAXIMUM_TIME_WITH_VALID_LAST_VELOCITY( 50u );
67
68 /**
69  * Functor which checks whether the specified actor is attached to the gesture detector.
70  * If the actor is attached, it also checks whether the number of touches of the current pan event
71  * are within the range of that expected by the detector.
72  * It returns true if it is no longer attached or the touches are out of range.
73  * This can be used in remove_if functions.
74  */
75 struct IsNotAttachedAndOutsideTouchesRangeFunctor
76 {
77   /**
78    * Constructor
79    * @param[in]  actor                 The actor to check whether it is attached.
80    * @param[in]  touches               The number of touches in the current pan event.
81    * @param[in]  outsideRangeEmitters  Reference to container where emitters outside of the touches range should be added.
82    */
83   IsNotAttachedAndOutsideTouchesRangeFunctor(Actor* actor, unsigned int touches, GestureDetectorContainer& outsideRangeEmitters)
84   : actorToCheck(actor),
85     numberOfTouches(touches),
86     outsideTouchesRangeEmitters(outsideRangeEmitters)
87   {
88   }
89
90   /**
91    * Returns true if not attached, false if it is still attached.
92    * Additionally, checks if the number of touches has changed and stops sending the pan to a particular
93    * detector if it exceeds the range of that detector.
94    * @param[in]  detector  The detector to check.
95    * @return true, if not attached, false otherwise.
96    */
97   bool operator()(GestureDetector* detector) const
98   {
99     bool remove(!detector->IsAttached(*actorToCheck));
100
101     if (!remove)
102     {
103       PanGestureDetector* panDetector( static_cast< PanGestureDetector* >( detector ) );
104
105       // Ensure number of touch points is within the range of our emitter. If it isn't then remove
106       // this emitter and add it to the outsideTouchesRangeEmitters container
107       if ( (numberOfTouches < panDetector->GetMinimumTouchesRequired()) ||
108            (numberOfTouches > panDetector->GetMaximumTouchesRequired()) )
109       {
110         remove = true;
111         outsideTouchesRangeEmitters.push_back(detector);
112       }
113     }
114
115     return remove;
116   }
117
118   Actor* actorToCheck; ///< The actor to check whether it is attached or not.
119   unsigned int numberOfTouches; ///< The number of touches in the pan event.
120   GestureDetectorContainer& outsideTouchesRangeEmitters; ///< Emitters that are outside of the range of current pan.
121 };
122
123 } // unnamed namespace
124
125 PanGestureProcessor::PanGestureProcessor( SceneGraph::UpdateManager& updateManager )
126 : GestureProcessor( Gesture::Pan ),
127   mPanGestureDetectors(),
128   mCurrentPanEmitters(),
129   mCurrentRenderTask(),
130   mPossiblePanPosition(),
131   mMinTouchesRequired( 1 ),
132   mMaxTouchesRequired( 1 ),
133   mCurrentPanEvent( nullptr ),
134   mSceneObject( SceneGraph::PanGesture::New() ) // Create scene object to store pan information.
135 {
136   // Pass ownership to scene-graph; scene object lives for the lifecycle of UpdateManager
137   updateManager.SetPanGestureProcessor( mSceneObject );
138 }
139
140 PanGestureProcessor::~PanGestureProcessor()
141 {
142   mSceneObject = nullptr; // mSceneObject is owned and destroyed by update manager (there is only one of these for now)
143 }
144
145 void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent )
146 {
147 #if defined(DEBUG_ENABLED)
148   DALI_LOG_TRACE_METHOD( gLogFilter );
149
150   DALI_LOG_INFO( gLogFilter, Debug::General, "    Pan Event\n");
151   DALI_LOG_INFO( gLogFilter, Debug::General, "      State: %s  Touches: %d  Time: %d  TimeDelta: %d\n",
152                                              GESTURE_STATES[panEvent.state], panEvent.numberOfTouches, panEvent.time, panEvent.timeDelta);
153   DALI_LOG_INFO( gLogFilter, Debug::General, "      Positions: Current: (%.0f, %.0f), Previous: (%.0f, %.0f)\n",
154                                              panEvent.currentPosition.x, panEvent.currentPosition.y, panEvent.previousPosition.x, panEvent.previousPosition.y);
155 #endif
156
157   switch( panEvent.state )
158   {
159     case Gesture::Possible:
160     {
161       mCurrentPanEmitters.clear();
162       ResetActor();
163
164       HitTestAlgorithm::Results hitTestResults;
165       if( HitTest( scene, panEvent.currentPosition, hitTestResults ) )
166       {
167         SetActor( &GetImplementation( hitTestResults.actor ) );
168         mPossiblePanPosition = panEvent.currentPosition;
169       }
170       break;
171     }
172
173     case Gesture::Started:
174     {
175       // Requires a core update
176       mNeedsUpdate = true;
177
178       // The pan gesture should only be sent to the gesture detector which first received it so that
179       // it can be told when the gesture ends as well.
180
181       HitTestAlgorithm::Results hitTestResults;
182       HitTest( scene, panEvent.previousPosition, hitTestResults ); // Hit Test previous position
183
184       if ( hitTestResults.actor )
185       {
186         // If the current hit actor is different from the one we touched down on then set accordingly & update initial pan position
187         if( &GetImplementation( hitTestResults.actor ) != GetCurrentGesturedActor() )
188         {
189           mPossiblePanPosition = panEvent.previousPosition;
190           SetActor( &GetImplementation( hitTestResults.actor ) );
191         }
192
193         // Record the current render-task for Screen->Actor coordinate conversions
194         mCurrentRenderTask = hitTestResults.renderTask;
195
196         // Set mCurrentPanEvent to use inside overridden methods called in ProcessAndEmit()
197         mCurrentPanEvent = &panEvent;
198         ProcessAndEmit( hitTestResults );
199         mCurrentPanEvent = nullptr;
200       }
201       else
202       {
203         ResetActor();
204         mCurrentPanEmitters.clear();
205       }
206       break;
207     }
208
209     case Gesture::Continuing:
210     {
211       // Requires a core update
212       mNeedsUpdate = true;
213
214       DALI_FALLTHROUGH;
215     }
216
217     case Gesture::Finished:
218     case Gesture::Cancelled:
219     {
220       // Only send subsequent pan gesture signals if we processed the pan gesture when it started.
221       // Check if actor is still touchable.
222
223       Actor* currentGesturedActor = GetCurrentGesturedActor();
224       if ( currentGesturedActor )
225       {
226         if ( currentGesturedActor->IsHittable() && !mCurrentPanEmitters.empty() && mCurrentRenderTask )
227         {
228           GestureDetectorContainer outsideTouchesRangeEmitters;
229
230           // Removes emitters that no longer have the actor attached
231           // Also remove emitters whose touches are outside the range of the current pan event and add them to outsideTouchesRangeEmitters
232           GestureDetectorContainer::iterator endIter = std::remove_if( mCurrentPanEmitters.begin(), mCurrentPanEmitters.end(),
233                                                                        IsNotAttachedAndOutsideTouchesRangeFunctor(currentGesturedActor, panEvent.numberOfTouches, outsideTouchesRangeEmitters) );
234           mCurrentPanEmitters.erase( endIter, mCurrentPanEmitters.end() );
235
236           Vector2 actorCoords;
237
238           if ( !outsideTouchesRangeEmitters.empty() || !mCurrentPanEmitters.empty() )
239           {
240             currentGesturedActor->ScreenToLocal( *mCurrentRenderTask.Get(), actorCoords.x, actorCoords.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
241
242             // EmitPanSignal checks whether we have a valid actor and whether the container we are passing in has emitters before it emits the pan.
243             EmitPanSignal( currentGesturedActor, outsideTouchesRangeEmitters, panEvent, actorCoords, Gesture::Finished, mCurrentRenderTask);
244             EmitPanSignal( currentGesturedActor, mCurrentPanEmitters, panEvent, actorCoords, panEvent.state, mCurrentRenderTask);
245           }
246
247           if ( mCurrentPanEmitters.empty() )
248           {
249             // If we have no emitters attached then clear pan actor as well.
250             ResetActor();
251           }
252
253           // Clear current gesture detectors if pan gesture has ended or been cancelled.
254           if ( ( panEvent.state == Gesture::Finished ) || ( panEvent.state == Gesture::Cancelled ) )
255           {
256             mCurrentPanEmitters.clear();
257             ResetActor();
258           }
259         }
260         else
261         {
262           mCurrentPanEmitters.clear();
263           ResetActor();
264         }
265       }
266       break;
267     }
268
269     case Gesture::Clear:
270     {
271       DALI_ABORT( "Incorrect state received from Integration layer: Clear\n" );
272       break;
273     }
274   }
275 }
276
277 void PanGestureProcessor::AddGestureDetector( PanGestureDetector* gestureDetector, Scene& scene, int32_t minDistance, int32_t minPanEvents )
278 {
279   bool firstRegistration(mPanGestureDetectors.empty());
280
281   mPanGestureDetectors.push_back(gestureDetector);
282
283   if (firstRegistration)
284   {
285     mMinTouchesRequired = gestureDetector->GetMinimumTouchesRequired();
286     mMaxTouchesRequired = gestureDetector->GetMaximumTouchesRequired();
287
288     PanGestureRequest request;
289     request.minTouches = mMinTouchesRequired;
290     request.maxTouches = mMaxTouchesRequired;
291
292     Size size = scene.GetSize();
293     mGestureRecognizer = new PanGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const PanGestureRequest&>(request), minDistance, minPanEvents);
294   }
295   else
296   {
297     UpdateDetection();
298   }
299 }
300
301 void PanGestureProcessor::RemoveGestureDetector( PanGestureDetector* gestureDetector )
302 {
303   if (!mCurrentPanEmitters.empty())
304   {
305     // Check if the removed detector was one that is currently being panned and remove it from emitters.
306     GestureDetectorContainer::iterator endIter = std::remove( mCurrentPanEmitters.begin(), mCurrentPanEmitters.end(), gestureDetector );
307     mCurrentPanEmitters.erase( endIter, mCurrentPanEmitters.end() );
308
309     // If we no longer have any emitters, then we should clear mCurrentGesturedActor as well
310     if ( mCurrentPanEmitters.empty() )
311     {
312       ResetActor();
313     }
314   }
315
316   // Find the detector...
317   PanGestureDetectorContainer::iterator endIter = std::remove( mPanGestureDetectors.begin(), mPanGestureDetectors.end(), gestureDetector );
318   DALI_ASSERT_DEBUG( endIter != mPanGestureDetectors.end() );
319
320   // ...and remove it
321   mPanGestureDetectors.erase(endIter, mPanGestureDetectors.end());
322
323   if (mPanGestureDetectors.empty())
324   {
325     mGestureRecognizer = nullptr;
326   }
327   else
328   {
329     UpdateDetection();
330   }
331 }
332
333 void PanGestureProcessor::GestureDetectorUpdated( PanGestureDetector* gestureDetector )
334 {
335   DALI_ASSERT_DEBUG(find(mPanGestureDetectors.begin(), mPanGestureDetectors.end(), gestureDetector) != mPanGestureDetectors.end());
336
337   UpdateDetection();
338 }
339
340 bool PanGestureProcessor::SetPanGestureProperties( const PanGesture& pan )
341 {
342   // If we are currently processing a pan gesture then just ignore
343   if ( mCurrentPanEmitters.empty() && mSceneObject )
344   {
345     // We update the scene object directly rather than sending a message.
346     // Sending a message could cause unnecessary delays, the scene object ensure thread safe behaviour.
347     mSceneObject->AddGesture( pan );
348
349     if( Gesture::Started == pan.state || Gesture::Continuing == pan.state )
350     {
351       mNeedsUpdate = true;
352     }
353   }
354
355   return mNeedsUpdate;
356 }
357
358 void PanGestureProcessor::EnableProfiling()
359 {
360   mSceneObject->EnableProfiling();
361 }
362
363 void PanGestureProcessor::SetPredictionMode(int mode)
364 {
365   if( (mode < 0)
366       || (mode >= SceneGraph::PanGesture::NUM_PREDICTION_MODES) )
367   {
368     mode = SceneGraph::PanGesture::DEFAULT_PREDICTION_MODE;
369   }
370   SceneGraph::PanGesture::PredictionMode modeEnum = static_cast<SceneGraph::PanGesture::PredictionMode>(mode);
371   mSceneObject->SetPredictionMode(modeEnum);
372 }
373
374 void PanGestureProcessor::SetPredictionAmount(unsigned int amount)
375 {
376   mSceneObject->SetPredictionAmount(amount);
377 }
378
379 void PanGestureProcessor::SetMaximumPredictionAmount(unsigned int amount)
380 {
381   mSceneObject->SetMaximumPredictionAmount(amount);
382 }
383
384 void PanGestureProcessor::SetMinimumPredictionAmount(unsigned int amount)
385 {
386   mSceneObject->SetMinimumPredictionAmount(amount);
387 }
388
389 void PanGestureProcessor::SetPredictionAmountAdjustment(unsigned int amount)
390 {
391   mSceneObject->SetPredictionAmountAdjustment(amount);
392 }
393
394 void PanGestureProcessor::SetSmoothingMode(int mode)
395 {
396   if( (mode < 0)
397       || (mode >= SceneGraph::PanGesture::NUM_SMOOTHING_MODES) )
398   {
399     mode = SceneGraph::PanGesture::DEFAULT_SMOOTHING_MODE;
400   }
401   SceneGraph::PanGesture::SmoothingMode modeEnum = static_cast<SceneGraph::PanGesture::SmoothingMode>(mode);
402   mSceneObject->SetSmoothingMode(modeEnum);
403 }
404
405 void PanGestureProcessor::SetSmoothingAmount(float amount)
406 {
407   mSceneObject->SetSmoothingAmount(amount);
408 }
409
410 void PanGestureProcessor::SetUseActualTimes( bool value )
411 {
412   mSceneObject->SetUseActualTimes( value );
413 }
414
415 void PanGestureProcessor::SetInterpolationTimeRange( int value )
416 {
417   mSceneObject->SetInterpolationTimeRange( value );
418 }
419
420 void PanGestureProcessor::SetScalarOnlyPredictionEnabled( bool value )
421 {
422   mSceneObject->SetScalarOnlyPredictionEnabled( value );
423 }
424
425 void PanGestureProcessor::SetTwoPointPredictionEnabled( bool value )
426 {
427   mSceneObject->SetTwoPointPredictionEnabled( value );
428 }
429
430 void PanGestureProcessor::SetTwoPointInterpolatePastTime( int value )
431 {
432   mSceneObject->SetTwoPointInterpolatePastTime( value );
433 }
434
435 void PanGestureProcessor::SetTwoPointVelocityBias( float value )
436 {
437   mSceneObject->SetTwoPointVelocityBias( value );
438 }
439
440 void PanGestureProcessor::SetTwoPointAccelerationBias( float value )
441 {
442   mSceneObject->SetTwoPointAccelerationBias( value );
443 }
444
445 void PanGestureProcessor::SetMultitapSmoothingRange( int value )
446 {
447   mSceneObject->SetMultitapSmoothingRange( value );
448 }
449
450 const SceneGraph::PanGesture& PanGestureProcessor::GetSceneObject() const
451 {
452   return *mSceneObject;
453 }
454
455 void PanGestureProcessor::UpdateDetection()
456 {
457   DALI_ASSERT_DEBUG(!mPanGestureDetectors.empty());
458
459   unsigned int minimumRequired = UINT_MAX;
460   unsigned int maximumRequired = 0;
461
462   for ( PanGestureDetectorContainer::iterator iter = mPanGestureDetectors.begin(), endIter = mPanGestureDetectors.end(); iter != endIter; ++iter )
463   {
464     PanGestureDetector* detector(*iter);
465
466     if( detector )
467     {
468       unsigned int minimum = detector->GetMinimumTouchesRequired();
469       if (minimum < minimumRequired)
470       {
471         minimumRequired = minimum;
472       }
473
474       unsigned int maximum = detector->GetMaximumTouchesRequired();
475       if (maximum > maximumRequired)
476       {
477         maximumRequired = maximum;
478       }
479     }
480   }
481
482   if ( (minimumRequired != mMinTouchesRequired)||(maximumRequired != mMaxTouchesRequired) )
483   {
484     mMinTouchesRequired = minimumRequired;
485     mMaxTouchesRequired = maximumRequired;
486
487     PanGestureRequest request;
488     request.minTouches = mMinTouchesRequired;
489     request.maxTouches = mMaxTouchesRequired;
490     mGestureRecognizer->Update(request);
491   }
492 }
493
494 void PanGestureProcessor::EmitPanSignal( Actor* actor,
495                                          const GestureDetectorContainer& gestureDetectors,
496                                          const PanGestureEvent& panEvent,
497                                          Vector2 localCurrent,
498                                          Gesture::State state,
499                                          RenderTaskPtr renderTask )
500 {
501   if ( actor && !gestureDetectors.empty() )
502   {
503     PanGesture pan(state);
504     pan.time = panEvent.time;
505
506     pan.numberOfTouches = panEvent.numberOfTouches;
507     pan.screenPosition = panEvent.currentPosition;
508     pan.position = localCurrent;
509
510     RenderTask& renderTaskImpl( *renderTask.Get() );
511
512     Vector2 localPrevious;
513     actor->ScreenToLocal( renderTaskImpl, localPrevious.x, localPrevious.y, panEvent.previousPosition.x, panEvent.previousPosition.y );
514
515     pan.displacement = localCurrent - localPrevious;
516     Vector2 previousPos( panEvent.previousPosition );
517     if ( state == Gesture::Started )
518     {
519       previousPos = mPossiblePanPosition;
520     }
521
522     pan.screenDisplacement = panEvent.currentPosition - previousPos;
523
524     // Avoid dividing by 0
525     if ( panEvent.timeDelta > 0 )
526     {
527       pan.velocity.x = pan.displacement.x / static_cast<float>( panEvent.timeDelta );
528       pan.velocity.y = pan.displacement.y / static_cast<float>( panEvent.timeDelta );
529
530       pan.screenVelocity.x = pan.screenDisplacement.x / static_cast<float>( panEvent.timeDelta );
531       pan.screenVelocity.y = pan.screenDisplacement.y / static_cast<float>( panEvent.timeDelta );
532     }
533
534     // When the gesture ends, we may incorrectly get a ZERO velocity (as we have lifted our finger without any movement)
535     // so we should use the last recorded velocity instead in this scenario.
536     if ( ( state == Gesture::Finished ) && ( pan.screenVelocity == Vector2::ZERO ) &&
537          ( panEvent.timeDelta < MAXIMUM_TIME_WITH_VALID_LAST_VELOCITY ) )
538     {
539       pan.velocity = mLastVelocity;
540       pan.screenVelocity = mLastScreenVelocity;
541     }
542     else
543     {
544       // Store the current velocity for future iterations.
545       mLastVelocity = pan.velocity;
546       mLastScreenVelocity = pan.screenVelocity;
547     }
548
549     if ( mSceneObject )
550     {
551       // We update the scene object directly rather than sending a message.
552       // Sending a message could cause unnecessary delays, the scene object ensure thread safe behaviour.
553       mSceneObject->AddGesture( pan );
554     }
555
556     Dali::Actor actorHandle( actor );
557
558     const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
559     for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter )
560     {
561       static_cast< PanGestureDetector* >( *iter )->EmitPanGestureSignal( actorHandle, pan );
562     }
563   }
564 }
565
566 void PanGestureProcessor::OnGesturedActorStageDisconnection()
567 {
568   mCurrentPanEmitters.clear();
569 }
570
571 bool PanGestureProcessor::CheckGestureDetector( GestureDetector* detector, Actor* actor )
572 {
573   DALI_ASSERT_DEBUG( mCurrentPanEvent );
574
575   bool retVal( false );
576   PanGestureDetector* panDetector( static_cast< PanGestureDetector* >( detector ) );
577
578   if ( ( mCurrentPanEvent->numberOfTouches >= panDetector->GetMinimumTouchesRequired() ) &&
579        ( mCurrentPanEvent->numberOfTouches <= panDetector->GetMaximumTouchesRequired() ) )
580   {
581     // Check if the detector requires directional panning.
582     if ( panDetector->RequiresDirectionalPan() && mCurrentRenderTask )
583     {
584       // It does, calculate the angle of the pan in local actor coordinates and ensures it fits
585       // the detector's criteria.
586       RenderTask& renderTaskImpl = *mCurrentRenderTask.Get();
587
588       Vector2 startPosition, currentPosition;
589       actor->ScreenToLocal( renderTaskImpl, startPosition.x,   startPosition.y,   mPossiblePanPosition.x,              mPossiblePanPosition.y );
590       actor->ScreenToLocal( renderTaskImpl, currentPosition.x, currentPosition.y, mCurrentPanEvent->currentPosition.x, mCurrentPanEvent->currentPosition.y );
591       Vector2 displacement( currentPosition - startPosition );
592
593       Radian angle( atanf( displacement.y / displacement.x ) );
594
595       /////////////////////////////
596       //            |            //
597       //            |            //
598       //   Q3 (-,-) | Q4 (+,-)   //
599       //            |            //
600       //    ----------------- +x //
601       //            |            //
602       //   Q2 (-,+) | Q1 (+,+)   //
603       //            |            //
604       //            |            //
605       //           +y            //
606       /////////////////////////////
607       // Quadrant 1: As is
608       // Quadrant 2: 180 degrees + angle
609       // Quadrant 3: angle - 180 degrees
610       // Quadrant 4: As is
611       /////////////////////////////
612
613       if ( displacement.x < 0.0f )
614       {
615         if ( displacement.y >= 0.0f )
616         {
617           // Quadrant 2
618           angle.radian += Math::PI;
619         }
620         else
621         {
622           // Quadrant 3
623           angle.radian -= Math::PI;
624         }
625       }
626
627       if ( panDetector->CheckAngleAllowed( angle ) )
628       {
629         retVal = true;
630       }
631     }
632     else
633     {
634       // Directional panning not required so we can use this actor and gesture detector.
635       retVal = true;
636     }
637   }
638   return retVal;
639 }
640
641 void PanGestureProcessor::EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
642 {
643   DALI_ASSERT_DEBUG ( mCurrentPanEvent );
644
645   mCurrentPanEmitters.clear();
646   ResetActor();
647
648   actor->ScreenToLocal( *mCurrentRenderTask.Get(), actorCoordinates.x, actorCoordinates.y, mCurrentPanEvent->currentPosition.x, mCurrentPanEvent->currentPosition.y );
649
650   EmitPanSignal( actor, gestureDetectors, *mCurrentPanEvent, actorCoordinates, mCurrentPanEvent->state, mCurrentRenderTask );
651
652   if ( actor->OnStage() )
653   {
654     mCurrentPanEmitters = gestureDetectors;
655     SetActor( actor );
656   }
657 }
658
659 } // namespace Internal
660
661 } // namespace Dali