* @param[in] localCenter Relative to the actor attached to the detector.
*/
void EmitPinchSignal(
- Dali::Actor actor,
- PinchGestureDetectorContainer& gestureDetectors,
+ Actor* actor,
+ const GestureDetectorContainer& gestureDetectors,
const Integration::PinchGestureEvent& pinchEvent,
Vector2 localCenter)
{
pinch.localCenterPoint = localCenter;
- for ( PinchGestureDetectorContainer::iterator iter = gestureDetectors.begin(), endIter = gestureDetectors.end(); iter != endIter; ++iter )
+ Dali::Actor actorHandle( actor );
+ const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
+ for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter )
{
- (*iter)->EmitPinchGestureSignal(actor, pinch);
+ static_cast< PinchGestureDetector* >( *iter )->EmitPinchGestureSignal( actorHandle, pinch );
}
}
* @param[in] detector The detector to check.
* @return true, if not attached, false otherwise.
*/
- bool operator()(const PinchGestureDetector* detector) const
+ bool operator()(const GestureDetector* detector) const
{
return !detector->IsAttached(*actorToCheck);
}
} // 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() ( Dali::Actor actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
- {
- PinchGestureDetectorContainer derivedContainer;
- DownCastContainer<PinchGestureDetector>( gestureDetectors, derivedContainer );
-
- EmitPinchSignal( actor, derivedContainer, pinchEvent, actorCoordinates );
-
- if ( actor.OnStage() )
- {
- processor.mCurrentPinchEmitters = derivedContainer;
- processor.SetActor( actor );
- }
- }
-
- const Integration::PinchGestureEvent& pinchEvent;
- PinchGestureProcessor& processor;
-};
-
PinchGestureProcessor::PinchGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager )
-: mStage(stage),
+: 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
- GestureDetectorContainer gestureDetectors;
- UpCastContainer<PinchGestureDetector>( mGestureDetectors, gestureDetectors );
- ProcessAndEmit( hitTestResults, gestureDetectors, functor );
+ // Set mCurrentPinchEvent to use inside overridden methods called from ProcessAndEmit()
+ mCurrentPinchEvent = &pinchEvent;
+ ProcessAndEmit( hitTestResults );
+ mCurrentPinchEvent = NULL;
}
break;
}
if ( currentGesturedActor->IsHittable() && !mCurrentPinchEmitters.empty() && mCurrentRenderTask )
{
// Ensure actor is still attached to the emitters, if it is not then remove the emitter.
- PinchGestureDetectorContainer::iterator endIter = std::remove_if( mCurrentPinchEmitters.begin(), mCurrentPinchEmitters.end(), IsNotAttachedFunctor(currentGesturedActor) );
+ GestureDetectorContainer::iterator endIter = std::remove_if( mCurrentPinchEmitters.begin(), mCurrentPinchEmitters.end(), IsNotAttachedFunctor(currentGesturedActor) );
mCurrentPinchEmitters.erase( endIter, mCurrentPinchEmitters.end() );
if ( !mCurrentPinchEmitters.empty() )
RenderTask& renderTaskImpl( GetImplementation(mCurrentRenderTask) );
currentGesturedActor->ScreenToLocal( renderTaskImpl, actorCoords.x, actorCoords.y, pinchEvent.centerPoint.x, pinchEvent.centerPoint.y );
- EmitPinchSignal( Dali::Actor(currentGesturedActor), mCurrentPinchEmitters, pinchEvent, actorCoords );
+ EmitPinchSignal( currentGesturedActor, mCurrentPinchEmitters, pinchEvent, actorCoords );
}
else
{
if ( !mCurrentPinchEmitters.empty() )
{
// Check if the removed detector was one that is currently being pinched and remove it from emitters.
- PinchGestureDetectorContainer::iterator endIter = std::remove( mCurrentPinchEmitters.begin(), mCurrentPinchEmitters.end(), gestureDetector );
+ GestureDetectorContainer::iterator endIter = std::remove( mCurrentPinchEmitters.begin(), mCurrentPinchEmitters.end(), gestureDetector );
mCurrentPinchEmitters.erase( endIter, mCurrentPinchEmitters.end() );
// If we no longer have any emitters, then we should clear mCurrentGesturedActor as well
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