X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fevents%2Fpinch-gesture-processor.cpp;h=07051b6a78d3e8ce7eccc6ed96a6fbba1156c742;hb=06a6b57d9bb3a8579f3850704012ab3c66f36833;hp=e266cbf60f60c2d7a895ffb8e270957cf9c6f786;hpb=7dcb0a38005dd8c6d71e466c1ea0ec4d7d57239f;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/events/pinch-gesture-processor.cpp b/dali/internal/event/events/pinch-gesture-processor.cpp index e266cbf..07051b6 100644 --- a/dali/internal/event/events/pinch-gesture-processor.cpp +++ b/dali/internal/event/events/pinch-gesture-processor.cpp @@ -48,8 +48,8 @@ namespace * @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) { @@ -62,9 +62,11 @@ void EmitPinchSignal( 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 ); } } @@ -88,7 +90,7 @@ struct IsNotAttachedFunctor * @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); } @@ -98,53 +100,13 @@ struct IsNotAttachedFunctor } // 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( 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) { } @@ -170,10 +132,10 @@ void PinchGestureProcessor::Process( const Integration::PinchGestureEvent& pinch // Record the current render-task for Screen->Actor coordinate conversions mCurrentRenderTask = hitTestResults.renderTask; - PinchEventFunctor functor( pinchEvent, *this ); // Sets mCurrentGesturedActor - GestureDetectorContainer gestureDetectors; - UpCastContainer( mGestureDetectors, gestureDetectors ); - ProcessAndEmit( hitTestResults, gestureDetectors, functor ); + // Set mCurrentPinchEvent to use inside overridden methods called from ProcessAndEmit() + mCurrentPinchEvent = &pinchEvent; + ProcessAndEmit( hitTestResults ); + mCurrentPinchEvent = NULL; } break; } @@ -191,7 +153,7 @@ void PinchGestureProcessor::Process( const Integration::PinchGestureEvent& pinch 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() ) @@ -200,7 +162,7 @@ void PinchGestureProcessor::Process( const Integration::PinchGestureEvent& pinch 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 { @@ -252,7 +214,7 @@ void PinchGestureProcessor::RemoveGestureDetector( PinchGestureDetector* gesture 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 @@ -286,6 +248,25 @@ void PinchGestureProcessor::OnGesturedActorStageDisconnection() 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