[problem] Functor usage is confusing and they need to be stack-allocated at the start of every
gesture.
[cause] N/A
[solution] Use deriving methods instead which is a bit clearer and does not require stack allocation
when the gesture starts.
Change-Id: I099eed5677914301559c5ff7ca55a170b5a99816
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
ResetActor();
}
-void GestureProcessor::GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors, Functor& functor )
+void GestureProcessor::GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors )
{
while ( actor )
{
{
GestureDetector* current(*iter);
- // Check whether the gesture detector satisfies the current gesture's parameters.
- if ( functor( current, actor ) )
+ // Check deriving class for whether the current gesture satisfies the gesture detector's parameters.
+ if ( CheckGestureDetector( current, actor ) )
{
gestureDetectors.push_back(current);
}
}
}
-void GestureProcessor::ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults, Functor& functor )
+void GestureProcessor::ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults )
{
if ( hitTestResults.actor )
{
while ( actor )
{
GestureDetectorContainer gestureDetectors;
- GetGesturedActor( actor, gestureDetectors, functor );
+ GetGesturedActor( actor, gestureDetectors );
if ( actor && !gestureDetectors.empty() )
{
if ( actor == hitTestActor )
{
- // Our gesture detector's attached actor WAS the hit actor so we can call the emitting functor.
- functor( actor, gestureDetectors, hitTestResults.actorCoordinates );
+ // Our gesture detector's attached actor WAS the hit actor so we can can emit the signal.
+ EmitGestureSignal( actor, gestureDetectors, hitTestResults.actorCoordinates );
break; // We have found AND emitted a signal on the gestured actor, break out.
}
else
float distance( 0.0f );
if( actor->RayActorTest( hitTestResults.rayOrigin, hitTestResults.rayDirection, hitPointLocal, distance ) )
{
- // One of the hit actor's parents was the gestured actor so call the emitting functor.
- functor( actor, gestureDetectors, Vector2( hitPointLocal.x, hitPointLocal.y ) );
+ // One of the parents was the gestured actor so we can emit the signal for that actor.
+ EmitGestureSignal( actor, gestureDetectors, Vector2( hitPointLocal.x, hitPointLocal.y ) );
break; // We have found AND emitted a signal on the gestured actor, break out.
}
}
*/
class GestureProcessor : public ProxyObject::Observer
{
-protected: // Construction & Destruction
+protected:
+
+ // Construction & Destruction
/**
* Protected constructor. Cannot create an instance of GestureProcessor
*/
virtual ~GestureProcessor();
- // Types for deriving classes
-
- /**
- * Functor to use in GetGesturedActor() and ProcessAndEmit() methods.
- */
- struct Functor
- {
- /**
- * This operator should be overridden to check if the gesture detector meets the parameters of the current gesture.
- * @param[in] detector The gesture detector to check.
- * @param[in] actor The actor that has been gestured.
- * @return true, if it meets the parameters, false otherwise.
- */
- virtual bool operator() ( GestureDetector* detector, Actor* actor ) = 0;
-
- /**
- * This operator should be overridden to emit the gesture signal on the provided container of gesture detectors along with the actor
- * the gesture has occurred on.
- * @param[in] actor The actor which has been gestured.
- * @param[in] gestureDetectors The detectors that should emit the signal.
- * @param[in] actorCoordinates The local actor coordinates where the gesture took place.
- */
- virtual void operator() ( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) = 0;
- };
-
- // Methods for deriving classes
+ // Methods to be used by deriving classes
/**
* Given the hit actor, this walks up the actor tree to determine the actor that is connected to one (or several) gesture detectors.
*
* @param[in,out] actor The gestured actor. When this function returns, this is the actor that has been hit by the gesture.
* @param[out] gestureDetectors A container containing all the gesture detectors that have the hit actor attached and satisfy the functor parameters.
- * @param[in] functor Used to check if a gesture-detector matches the criteria the gesture detector requires.
*
+ * @note Uses CheckGestureDetector() to check if a the current gesture matches the criteria the gesture detector requires.
* @pre gestureDetectors should be empty.
*/
- void GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors, Functor& functor );
+ void GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors );
/**
* Calls the emission method in the deriving class for matching gesture-detectors with the hit-actor (or one of its parents).
*
* @param[in] hitTestResults The Hit Test Results.
- * @param[in] functor Used to check if a gesture-detector matches the criteria the gesture detector requires and for emitting the signal.
*
+ * @note Uses the CheckGestureDetector() to check if the gesture matches the criteria of the given gesture detector
+ * and EmitGestureSignal() to emit the signal.
* @pre Hit Testing should already be done.
*/
- void ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults, Functor& functor );
+ void ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults );
/**
* Hit test the screen coordinates, and place the results in hitTestResults.
*/
Actor* GetCurrentGesturedActor();
+private:
+
// For derived classes to override
/**
*/
virtual void OnGesturedActorStageDisconnection() = 0;
-private:
+ /**
+ * Called by the ProcessAndEmit() & GetGesturedActor() methods to check if the provided
+ * gesture-detector meets the parameters of the current gesture.
+ *
+ * @param[in] detector The gesture detector to check.
+ * @param[in] actor The actor that has been gestured.
+ *
+ * @return true, if the detector meets the parameters, false otherwise.
+ */
+ virtual bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) = 0;
+
+ /**
+ * Called by the ProcessAndEmit() method when the gesture meets all applicable criteria and
+ * should be overridden by deriving classes to emit the gesture signal on gesture-detectors
+ * provided for the actor the gesture has occurred on.
+ *
+ * @param[in] actor The actor which has been gestured.
+ * @param[in] gestureDetectors The detectors that should emit the signal.
+ * @param[in] actorCoordinates The local actor coordinates where the gesture took place.
+ */
+ virtual void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) = 0;
// Undefined
+
GestureProcessor( const GestureProcessor& );
GestureProcessor& operator=( const GestureProcessor& );
-private:
+ // SceneObject overrides
/**
* This will never get called as we do not observe objects that have not been added to the scene.
*/
virtual void ProxyDestroyed(ProxyObject& proxy);
- // Signal Handlers
-
- /**
- * Signal handler called when the actor is removed from the stage.
- * @param[in] actor The actor removed from the stage.
- */
- void OnStageDisconnection( Dali::Actor actor );
-
private: // Data
Gesture::Type mType; ///< Type of GestureProcessor
} // unnamed namespace
-struct LongPressGestureProcessor::LongPressEventFunctor : public GestureProcessor::Functor
-{
- /**
- * Constructor
- * @param[in] event The current gesture event.
- * @param[in] processor Reference to the processor.
- */
- LongPressEventFunctor( const Integration::LongPressGestureEvent& event, LongPressGestureProcessor& processor )
- : longPressEvent( event ),
- processor( processor )
- {
- }
-
- /**
- * Check if the detector meets the current gesture event parameters.
- */
- virtual bool operator() ( GestureDetector* detector, Actor* )
- {
- LongPressGestureDetector* longPressDetector ( static_cast< LongPressGestureDetector* >( detector ) );
-
- return ( longPressDetector->GetMinimumTouchesRequired() <= longPressEvent.numberOfTouches ) &&
- ( longPressDetector->GetMaximumTouchesRequired() >= longPressEvent.numberOfTouches );
- }
-
- /**
- * Gestured actor and gesture detectors that meet the gesture's parameters found, emit and save required information.
- */
- virtual void operator() ( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
- {
- // Clear actor as
- processor.mCurrentEmitters.clear();
- processor.ResetActor();
-
- EmitLongPressSignal( actor, gestureDetectors, longPressEvent, actorCoordinates );
-
- if ( actor->OnStage() )
- {
- processor.mCurrentEmitters = gestureDetectors;
- processor.SetActor( actor );
- }
- }
-
- const Integration::LongPressGestureEvent& longPressEvent;
- LongPressGestureProcessor& processor;
-};
-
LongPressGestureProcessor::LongPressGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager)
: GestureProcessor( Gesture::LongPress ),
mStage( stage ),
mCurrentEmitters(),
mCurrentRenderTask(),
mMinTouchesRequired( 1 ),
- mMaxTouchesRequired( 1 )
+ mMaxTouchesRequired( 1 ),
+ mCurrentLongPressEvent( NULL )
{
}
// Record the current render-task for Screen->Actor coordinate conversions
mCurrentRenderTask = hitTestResults.renderTask;
- LongPressEventFunctor functor( longPressEvent, *this );
- ProcessAndEmit( hitTestResults, functor );
+ // Set mCurrentLongPressEvent to use inside overridden methods called from ProcessAndEmit()
+ mCurrentLongPressEvent = &longPressEvent;
+ ProcessAndEmit( hitTestResults );
+ mCurrentLongPressEvent = NULL;
}
else
{
mCurrentEmitters.clear();
}
+bool LongPressGestureProcessor::CheckGestureDetector( GestureDetector* detector, Actor* actor )
+{
+ DALI_ASSERT_DEBUG( mCurrentLongPressEvent );
+
+ LongPressGestureDetector* longPressDetector ( static_cast< LongPressGestureDetector* >( detector ) );
+
+ return ( longPressDetector->GetMinimumTouchesRequired() <= mCurrentLongPressEvent->numberOfTouches ) &&
+ ( longPressDetector->GetMaximumTouchesRequired() >= mCurrentLongPressEvent->numberOfTouches );
+}
+
+void LongPressGestureProcessor::EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
+{
+ DALI_ASSERT_DEBUG( mCurrentLongPressEvent );
+
+ mCurrentEmitters.clear();
+ ResetActor();
+
+ EmitLongPressSignal( actor, gestureDetectors, *mCurrentLongPressEvent, actorCoordinates );
+
+ if ( actor->OnStage() )
+ {
+ mCurrentEmitters = gestureDetectors;
+ SetActor( actor );
+ }
+}
+
} // namespace Internal
} // namespace Dali
*/
void OnGesturedActorStageDisconnection();
+ /**
+ * @copydoc GestureProcessor::CheckGestureDetector()
+ */
+ bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
+
+ /**
+ * @copydoc GestureProcessor::EmitGestureSignal()
+ */
+ void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
+
private:
Stage& mStage;
unsigned int mMinTouchesRequired;
unsigned int mMaxTouchesRequired;
- struct LongPressEventFunctor;
+ const Integration::LongPressGestureEvent* mCurrentLongPressEvent; ///< Pointer to current longPressEvent, used when calling ProcessAndEmit()
};
} // namespace Internal
} // unnamed namespace
-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() ( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
- {
- processor.mCurrentPanEmitters.clear();
- processor.ResetActor();
-
- actor->ScreenToLocal( GetImplementation(processor.mCurrentRenderTask), actorCoordinates.x, actorCoordinates.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
-
- processor.EmitPanSignal( actor, gestureDetectors, panEvent, actorCoordinates, panEvent.state, processor.mCurrentRenderTask );
-
- if ( actor->OnStage() )
- {
- processor.mCurrentPanEmitters = gestureDetectors;
- processor.SetActor( actor );
- }
- }
-
- const Integration::PanGestureEvent& panEvent;
- PanGestureProcessor& processor;
-};
-
PanGestureProcessor::PanGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager )
: GestureProcessor( Gesture::Pan ),
mStage( stage ),
mPossiblePanPosition(),
mMinTouchesRequired( 1 ),
mMaxTouchesRequired( 1 ),
+ mCurrentPanEvent( NULL ),
mSceneObject( SceneGraph::PanGesture::New() ) // Create scene object to store pan information.
{
// Pass ownership to scene-graph
// Record the current render-task for Screen->Actor coordinate conversions
mCurrentRenderTask = hitTestResults.renderTask;
- PanEventFunctor functor( panEvent, *this );
- ProcessAndEmit( hitTestResults, functor );
+ // Set mCurrentPanEvent to use inside overridden methods called in ProcessAndEmit()
+ mCurrentPanEvent = &panEvent;
+ ProcessAndEmit( hitTestResults );
+ mCurrentPanEvent = NULL;
}
else
{
mCurrentPanEmitters.clear();
}
+bool PanGestureProcessor::CheckGestureDetector( GestureDetector* detector, Actor* actor )
+{
+ DALI_ASSERT_DEBUG( mCurrentPanEvent );
+
+ bool retVal( false );
+ PanGestureDetector* panDetector( static_cast< PanGestureDetector* >( detector ) );
+
+ if ( ( mCurrentPanEvent->numberOfTouches >= panDetector->GetMinimumTouchesRequired() ) &&
+ ( mCurrentPanEvent->numberOfTouches <= panDetector->GetMaximumTouchesRequired() ) )
+ {
+ // Check if the detector requires directional panning.
+ if ( panDetector->RequiresDirectionalPan() && mCurrentRenderTask )
+ {
+ // It does, calculate the angle of the pan in local actor coordinates and ensures it fits
+ // the detector's criteria.
+ RenderTask& renderTaskImpl( GetImplementation( mCurrentRenderTask ) );
+
+ Vector2 startPosition, currentPosition;
+ actor->ScreenToLocal( renderTaskImpl, startPosition.x, startPosition.y, mPossiblePanPosition.x, mPossiblePanPosition.y );
+ actor->ScreenToLocal( renderTaskImpl, currentPosition.x, currentPosition.y, mCurrentPanEvent->currentPosition.x, mCurrentPanEvent->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;
+}
+
+void PanGestureProcessor::EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
+{
+ DALI_ASSERT_DEBUG ( mCurrentPanEvent );
+
+ mCurrentPanEmitters.clear();
+ ResetActor();
+
+ actor->ScreenToLocal( GetImplementation(mCurrentRenderTask), actorCoordinates.x, actorCoordinates.y, mCurrentPanEvent->currentPosition.x, mCurrentPanEvent->currentPosition.y );
+
+ EmitPanSignal( actor, gestureDetectors, *mCurrentPanEvent, actorCoordinates, mCurrentPanEvent->state, mCurrentRenderTask );
+
+ if ( actor->OnStage() )
+ {
+ mCurrentPanEmitters = gestureDetectors;
+ SetActor( actor );
+ }
+}
+
} // namespace Internal
} // namespace Dali
*/
void OnGesturedActorStageDisconnection();
+ /**
+ * @copydoc GestureProcessor::CheckGestureDetector()
+ */
+ bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
+
+ /**
+ * @copydoc GestureProcessor::EmitGestureSignal()
+ */
+ void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
+
private:
Stage& mStage;
Vector2 mLastVelocity; ///< The last recorded velocity in local actor coordinates.
Vector2 mLastScreenVelocity; ///< The last recorded velocity in screen coordinates.
- struct PanEventFunctor;
-
+ const Integration::PanGestureEvent* mCurrentPanEvent; ///< Pointer to current PanEvent, used when calling ProcessAndEmit()
SceneGraph::PanGesture* mSceneObject; ///< Not owned, but we write to it directly
};
} // unnamed namespace
-struct PinchGestureProcessor::PinchEventFunctor : public GestureProcessor::Functor
-{
- /**
- * Constructor
- * @param[in] pinchEvent The current gesture event.
- * @param[in] processor Reference to the processor.
- */
- PinchEventFunctor( const Integration::PinchGestureEvent& pinchEvent, PinchGestureProcessor& processor )
- : pinchEvent( pinchEvent ),
- processor( processor )
- {
- }
-
- /**
- * Check if the detector meets the current gesture event parameters.
- */
- virtual bool operator() ( GestureDetector*, Actor* )
- {
- return true;
- }
-
- /**
- * Gestured actor and gesture detectors that meet the gesture's parameters found, emit and save required information.
- */
- virtual void operator() ( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
- {
- EmitPinchSignal( actor, gestureDetectors, pinchEvent, actorCoordinates );
-
- if ( actor->OnStage() )
- {
- processor.mCurrentPinchEmitters = gestureDetectors;
- processor.SetActor( actor );
- }
- }
-
- const Integration::PinchGestureEvent& pinchEvent;
- PinchGestureProcessor& processor;
-};
-
PinchGestureProcessor::PinchGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager )
: GestureProcessor( Gesture::Pinch ),
mStage(stage),
mGestureManager(gestureManager),
mGestureDetectors(),
- mCurrentPinchEmitters()
+ mCurrentPinchEmitters(),
+ mCurrentPinchEvent(NULL)
{
}
// Record the current render-task for Screen->Actor coordinate conversions
mCurrentRenderTask = hitTestResults.renderTask;
- PinchEventFunctor functor( pinchEvent, *this ); // Sets mCurrentGesturedActor
- ProcessAndEmit( hitTestResults, functor );
+ // Set mCurrentPanEvent to use inside overridden methods called from ProcessAndEmit()
+ mCurrentPinchEvent = &pinchEvent;
+ ProcessAndEmit( hitTestResults );
+ mCurrentPinchEvent = NULL;
}
break;
}
mCurrentPinchEmitters.clear();
}
+bool PinchGestureProcessor::CheckGestureDetector( GestureDetector* detector, Actor* actor )
+{
+ // No special case required for pinch.
+ return true;
+}
+
+void PinchGestureProcessor::EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
+{
+ DALI_ASSERT_DEBUG( mCurrentPinchEvent );
+
+ EmitPinchSignal( actor, gestureDetectors, *mCurrentPinchEvent, actorCoordinates );
+
+ if ( actor->OnStage() )
+ {
+ mCurrentPinchEmitters = gestureDetectors;
+ SetActor( actor );
+ }
+}
+
} // namespace Internal
} // namespace Dali
*/
void OnGesturedActorStageDisconnection();
+ /**
+ * @copydoc GestureProcessor::CheckGestureDetector()
+ */
+ bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
+
+ /**
+ * @copydoc GestureProcessor::EmitGestureSignal()
+ */
+ void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
+
private:
Stage& mStage;
GestureDetectorContainer mCurrentPinchEmitters;
Dali::RenderTask mCurrentRenderTask;
- struct PinchEventFunctor;
+ const Integration::PinchGestureEvent* mCurrentPinchEvent; ///< Pointer to current PinchEvent, used when calling ProcessAndEmit()
};
} // namespace Internal
} // unnamed namespace
-struct TapGestureProcessor::TapEventFunctor : public GestureProcessor::Functor
-{
- /**
- * Constructor
- * @param[in] tapEvent The current gesture event.
- */
- TapEventFunctor( const Integration::TapGestureEvent& tapEvent )
- : tapEvent(tapEvent)
- {
- }
-
- /**
- * Check if the detector meets the current gesture event parameters.
- */
- virtual bool operator() ( GestureDetector* detector, Actor* )
- {
- TapGestureDetector* tapDetector ( static_cast< TapGestureDetector* >( detector ) );
-
- return tapDetector->GetTapsRequired() == tapEvent.numberOfTaps &&
- tapDetector->GetTouchesRequired() == tapEvent.numberOfTouches;
- }
-
- /**
- * Gestured actor and gesture detectors that meet the gesture's parameters found, emit and save required information.
- */
- virtual void operator() ( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
- {
- EmitTapSignal( actor, gestureDetectors, tapEvent, actorCoordinates );
- }
-
- const Integration::TapGestureEvent& tapEvent;
-};
-
TapGestureProcessor::TapGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager)
: GestureProcessor( Gesture::Tap ),
mStage( stage ),
mMinTapsRequired( 1 ),
mMaxTapsRequired( 1 ),
mMinTouchesRequired( 1 ),
- mMaxTouchesRequired( 1 )
+ mMaxTouchesRequired( 1 ),
+ mCurrentTapEvent( NULL )
{
}
if ( hitTestResults.actor && ( GetCurrentGesturedActor() == &GetImplementation( hitTestResults.actor ) ) )
{
- TapEventFunctor functor( tapEvent );
- ProcessAndEmit( hitTestResults, functor );
+ // Set mCurrentTapEvent to use inside overridden methods called from ProcessAndEmit()
+ mCurrentTapEvent = &tapEvent;
+ ProcessAndEmit( hitTestResults );
+ mCurrentTapEvent = NULL;
}
ResetActor();
}
}
+bool TapGestureProcessor::CheckGestureDetector( GestureDetector* detector, Actor* actor )
+{
+ DALI_ASSERT_DEBUG( mCurrentTapEvent );
+
+ TapGestureDetector* tapDetector ( static_cast< TapGestureDetector* >( detector ) );
+
+ return ( tapDetector->GetTapsRequired() == mCurrentTapEvent->numberOfTaps ) &&
+ ( tapDetector->GetTouchesRequired() == mCurrentTapEvent->numberOfTouches );
+}
+
+void TapGestureProcessor::EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
+{
+ DALI_ASSERT_DEBUG( mCurrentTapEvent );
+
+ EmitTapSignal( actor, gestureDetectors, *mCurrentTapEvent, actorCoordinates );
+}
+
} // namespace Internal
} // namespace Dali
*/
void OnGesturedActorStageDisconnection() { /* Nothing to do */ }
+ /**
+ * @copydoc GestureProcessor::CheckGestureDetector()
+ */
+ bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
+
+ /**
+ * @copydoc GestureProcessor::EmitGestureSignal()
+ */
+ void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
+
private:
Stage& mStage;
unsigned int mMinTouchesRequired;
unsigned int mMaxTouchesRequired;
- struct TapEventFunctor;
+ const Integration::TapGestureEvent* mCurrentTapEvent; ///< Pointer to current TapEvent, used when calling ProcessAndEmit()
};
} // namespace Internal