-struct PanGestureProcessor::PanEventFunctor : public GestureProcessor::Functor
-{
- /**
- * Constructor
- * @param[in] panEvent The current gesture event.
- * @param[in] processor Reference to the processor.
- */
- PanEventFunctor( const Integration::PanGestureEvent& panEvent, PanGestureProcessor& processor )
- : panEvent( panEvent ),
- processor( processor )
- {
- }
-
- /**
- * Check if the detector meets the current gesture event parameters.
- */
- virtual bool operator() ( GestureDetector* detector, Actor* actor )
- {
- bool retVal( false );
-
- PanGestureDetector* panDetector( static_cast< PanGestureDetector* >( detector ) );
-
- if ( ( panEvent.numberOfTouches >= panDetector->GetMinimumTouchesRequired() ) &&
- ( panEvent.numberOfTouches <= panDetector->GetMaximumTouchesRequired() ) )
- {
- // Check if the detector requires directional panning.
- if ( panDetector->RequiresDirectionalPan() && processor.mCurrentRenderTask )
- {
- // It does, calculate the angle of the pan in local actor coordinates and ensures it fits
- // the detector's criteria.
- RenderTask& renderTaskImpl( GetImplementation( processor.mCurrentRenderTask ) );
-
- Vector2 startPosition, currentPosition;
- actor->ScreenToLocal( renderTaskImpl, startPosition.x, startPosition.y, processor.mPossiblePanPosition.x, processor.mPossiblePanPosition.y );
- actor->ScreenToLocal( renderTaskImpl, currentPosition.x, currentPosition.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
- Vector2 displacement( currentPosition - startPosition );
-
- Radian angle( atan( displacement.y / displacement.x ) );
-
- /////////////////////////////
- // | //
- // | //
- // Q3 (-,-) | Q4 (+,-) //
- // | //
- // ----------------- +x //
- // | //
- // Q2 (-,+) | Q1 (+,+) //
- // | //
- // | //
- // +y //
- /////////////////////////////
- // Quadrant 1: As is
- // Quadrant 2: 180 degrees + angle
- // Quadrant 3: angle - 180 degrees
- // Quadrant 4: As is
- /////////////////////////////
-
- if ( displacement.x < 0.0f )
- {
- if ( displacement.y >= 0.0f )
- {
- // Quadrant 2
- angle += Math::PI;
- }
- else
- {
- // Quadrant 3
- angle -= Math::PI;
- }
- }
-
- if ( panDetector->CheckAngleAllowed( angle ) )
- {
- retVal = true;
- }
- }
- else
- {
- // Directional panning not required so we can use this actor and gesture detector.
- retVal = true;
- }
- }
-
- return retVal;
- }
-
- /**
- * Gestured actor and gesture detectors that meet the gesture's parameters found, emit and save required information.
- */
- virtual void operator() ( Dali::Actor actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
- {
- PanGestureDetectorContainer derivedContainer;
- DownCastContainer<PanGestureDetector>( gestureDetectors, derivedContainer );
-
- processor.mCurrentPanEmitters.clear();
- processor.ResetActor();
-
- Actor* actorImpl( &GetImplementation( actor ) );
- actorImpl->ScreenToLocal( GetImplementation(processor.mCurrentRenderTask), actorCoordinates.x, actorCoordinates.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
-
- processor.EmitPanSignal( actor, derivedContainer, panEvent, actorCoordinates, panEvent.state, processor.mCurrentRenderTask );
-
- if ( actorImpl->OnStage() )
- {
- processor.mCurrentPanEmitters = derivedContainer;
- processor.SetActor( actor );
- }
- }
-
- const Integration::PanGestureEvent& panEvent;
- PanGestureProcessor& processor;
-};
-
-PanGestureProcessor::PanGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager )
-: mStage( stage ),