Use the containers provided by actor-gesture-data rather than checking if the actor
is available in attached detectors (should be faster).
Using raw Internal::Actor pointers instead of handles.
Removing unnecessary templates.
Next step is to remove gesture-processor functors and use deriving methods instead.
Change-Id: I130cc8cbd0dae293713b74156fcbf3c1c3eaa758
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
namespace Internal
{
-namespace
-{
-
-/**
- * Template to add a detector to the appropriate container. Dynamically allocates the container only if it is used.
- */
-template< typename DetectorType, typename ContainerType >
-inline void AddDetector( ContainerType*& containerPtr, GestureDetector* detector, Gesture::Type& gesturesRequired )
-{
- if ( NULL == containerPtr )
- {
- containerPtr = new ContainerType;
- }
-
- containerPtr->push_back( static_cast< DetectorType* >( detector ) );
- gesturesRequired = Gesture::Type( gesturesRequired | detector->GetType() );
-}
-
-/**
- * Template to remove a detector from the appropriate container. Deletes the container if it is no longer required.
- */
-template< typename ContainerType >
-inline void RemoveDetector( ContainerType*& containerPtr, GestureDetector* detector, Gesture::Type& gesturesRequired )
-{
- if ( NULL != containerPtr )
- {
- ContainerType& container( *containerPtr );
- typename ContainerType::iterator match( std::remove( container.begin(), container.end(), detector ) );
- DALI_ASSERT_DEBUG( match != container.end() && "Actor does not have the detector" );
- container.erase( match, container.end() );
-
- if ( container.empty() )
- {
- gesturesRequired = Gesture::Type( gesturesRequired & ~detector->GetType() );
- delete containerPtr;
- containerPtr = NULL;
- }
- }
-}
-
-} // unnamed namespace
-
ActorGestureData::ActorGestureData()
: gesturesRequired( Gesture::Type( 0 ) ),
panDetectors( NULL ),
void ActorGestureData::AddGestureDetector( GestureDetector& detector )
{
const Gesture::Type type( detector.GetType() );
- switch ( type )
+
+ GestureDetectorContainer*& containerPtr( GetContainerPtr( type ) );
+ if ( NULL == containerPtr )
{
- case Gesture::Pan:
- {
- AddDetector< PanGestureDetector, PanGestureDetectorContainer >( panDetectors, &detector, gesturesRequired );
- break;
- }
+ containerPtr = new GestureDetectorContainer;
+ }
+ containerPtr->push_back( &detector );
- case Gesture::Pinch:
- {
- AddDetector< PinchGestureDetector, PinchGestureDetectorContainer >( pinchDetectors, &detector, gesturesRequired );
- break;
- }
+ gesturesRequired = Gesture::Type( gesturesRequired | type );
+}
- case Gesture::LongPress:
- {
- AddDetector< LongPressGestureDetector, LongPressGestureDetectorContainer >( longPressDetectors, &detector, gesturesRequired );
- break;
- }
+void ActorGestureData::RemoveGestureDetector( GestureDetector& detector )
+{
+ const Gesture::Type type( detector.GetType() );
- case Gesture::Tap:
- {
- AddDetector< TapGestureDetector, TapGestureDetectorContainer >( tapDetectors, &detector, gesturesRequired );
- break;
- }
+ GestureDetectorContainer*& containerPtr( GetContainerPtr( type ) );
+ DALI_ASSERT_DEBUG( containerPtr && "Container had not been created" );
+
+ GestureDetectorContainer& container( *containerPtr );
+ GestureDetectorContainer::iterator match( std::remove( container.begin(), container.end(), &detector ) );
+ DALI_ASSERT_DEBUG( match != container.end() && "Actor does not have the detector" );
+ container.erase( match, container.end() );
+
+ if ( container.empty() )
+ {
+ gesturesRequired = Gesture::Type( gesturesRequired & ~type );
+ delete containerPtr;
+ containerPtr = NULL;
}
}
-void ActorGestureData::RemoveGestureDetector( GestureDetector& detector )
+GestureDetectorContainer& ActorGestureData::GetGestureDetectorContainer( Gesture::Type type )
+{
+ return *GetContainerPtr( type );
+}
+
+GestureDetectorContainer*& ActorGestureData::GetContainerPtr( Gesture::Type type )
{
- switch ( detector.GetType() )
+ switch ( type )
{
case Gesture::Pan:
{
- RemoveDetector< PanGestureDetectorContainer >( panDetectors, &detector, gesturesRequired );
- break;
+ return panDetectors;
}
case Gesture::Pinch:
{
- RemoveDetector< PinchGestureDetectorContainer >( pinchDetectors, &detector, gesturesRequired );
- break;
+ return pinchDetectors;
}
case Gesture::LongPress:
{
- RemoveDetector< LongPressGestureDetectorContainer >( longPressDetectors, &detector, gesturesRequired );
- break;
+ return longPressDetectors;
}
case Gesture::Tap:
{
- RemoveDetector< TapGestureDetectorContainer >( tapDetectors, &detector, gesturesRequired );
- break;
+ return tapDetectors;
}
}
+
+ DALI_ASSERT_DEBUG( ! "Invalid Type" );
+ static GestureDetectorContainer* invalidType( NULL );
+ return invalidType;
}
} // namespace Internal
*/
// INTERNAL INCLUDES
-#include <dali/internal/event/events/pan-gesture-detector-impl.h>
-#include <dali/internal/event/events/pinch-gesture-detector-impl.h>
-#include <dali/internal/event/events/long-press-gesture-detector-impl.h>
-#include <dali/internal/event/events/tap-gesture-detector-impl.h>
+#include <dali/internal/event/events/gesture-detector-impl.h>
namespace Dali
{
return type & gesturesRequired;
}
+ /**
+ * Retrieve a reference to the detectors for the given type.
+ * @param[in] type The container type required
+ * @pre Ensure IsGestureRequired() is used to check if the container is actually available.
+ */
+ GestureDetectorContainer& GetGestureDetectorContainer( Gesture::Type type );
+
+private:
+
+ /**
+ * Helper to retrieve the appropriate container type.
+ * @param[in] type The container type required.
+ */
+ inline GestureDetectorContainer*& GetContainerPtr( Gesture::Type type );
+
private:
Gesture::Type gesturesRequired; ///< Stores which gestures are required
- PanGestureDetectorContainer* panDetectors; ///< Pointer to a container of pan-detectors
- PinchGestureDetectorContainer* pinchDetectors; ///< Pointer to a container of pinch-detectors
- LongPressGestureDetectorContainer* longPressDetectors; ///< Pointer to a container of long-press-detectors
- TapGestureDetectorContainer* tapDetectors; ///< Pointer to a container of tap-detectors
+ GestureDetectorContainer* panDetectors; ///< Pointer to a container of pan-detectors
+ GestureDetectorContainer* pinchDetectors; ///< Pointer to a container of pinch-detectors
+ GestureDetectorContainer* longPressDetectors; ///< Pointer to a container of long-press-detectors
+ GestureDetectorContainer* tapDetectors; ///< Pointer to a container of tap-detectors
};
} // namespace Internal
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
#include <dali/internal/event/actors/actor-impl.h>
-#include <dali/internal/event/render-tasks/render-task-impl.h>
#include <dali/internal/event/events/hit-test-algorithm-impl.h>
+#include <dali/internal/event/events/actor-gesture-data.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
ResetActor();
}
-void GestureProcessor::GetGesturedActor( Dali::Actor& actor, const GestureDetectorContainer& connectedDetectors, std::vector<GestureDetector*>& gestureDetectors, Functor& functor )
+void GestureProcessor::GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors, Functor& functor )
{
while ( actor )
{
- Actor* actorImpl( &GetImplementation(actor) );
-
- // Check if our hit actor or any of its parents are attached to any registered detector.
- // Find all detectors that have the actor attached.
- for ( GestureDetectorContainer::const_iterator iter = connectedDetectors.begin(), endIter = connectedDetectors.end(); iter != endIter; ++iter )
+ // We may be checking a parent so ensure the parent requires this gesture (and do not unintentionally create the gesture data for the parent)
+ if ( actor->IsGestureRequred( mType ) )
{
- GestureDetector* current(*iter);
-
- // Check whether the actor is attached to the gesture detector and then call the functor to
- // check whether the gesture detector satisfies the current gesture's parameters.
- if ( current->IsAttached( *actorImpl ) && functor( current, actorImpl ) )
+ // Retrieve the actor's detectors and check if they satisfy current gesture
+ const GestureDetectorContainer& connectedDetectors( actor->GetGestureData().GetGestureDetectorContainer( mType ) );
+ const GestureDetectorContainer::const_iterator endIter( connectedDetectors.end() );
+ for ( GestureDetectorContainer::const_iterator iter = connectedDetectors.begin(); iter != endIter; ++iter )
{
- gestureDetectors.push_back(current);
+ GestureDetector* current(*iter);
+
+ // Check whether the gesture detector satisfies the current gesture's parameters.
+ if ( functor( current, actor ) )
+ {
+ gestureDetectors.push_back(current);
+ }
}
- }
- // The hit actor or one of the parents is a gestured actor, break out.
- if ( !gestureDetectors.empty() )
- {
- break;
+ // The hit actor or one of the parents is a gestured actor, break out.
+ if ( !gestureDetectors.empty() )
+ {
+ break;
+ }
}
// No match, we should now check the hit actor's parent.
- actor = actor.GetParent();
+ actor = actor->GetParent();
}
}
-void GestureProcessor::ProcessAndEmit( const HitTestAlgorithm::Results& hitTestResults, const GestureDetectorContainer& connectedDetectors, Functor& functor )
+void GestureProcessor::ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults, Functor& functor )
{
- Dali::Actor actor( hitTestResults.actor );
-
- while ( actor )
+ if ( hitTestResults.actor )
{
- std::vector<GestureDetector*> gestureDetectors;
+ Actor* hitTestActor( &GetImplementation( hitTestResults.actor ) );
+ Actor* actor( hitTestActor );
- GetGesturedActor( actor, connectedDetectors, gestureDetectors, functor );
-
- if ( actor && !gestureDetectors.empty() )
+ while ( actor )
{
- // We have a match but check if the hit point is within the gestured actor's bounds.
- // If it is not then continue up the actor hierarchy.
+ GestureDetectorContainer gestureDetectors;
+ GetGesturedActor( actor, gestureDetectors, functor );
- if ( actor == hitTestResults.actor )
- {
- // Our gesture detector's attached actor WAS the hit actor so we can call the emitting functor.
- functor( actor, gestureDetectors, hitTestResults.actorCoordinates );
- break; // We have found AND emitted a signal on the gestured actor, break out.
- }
- else
+ if ( actor && !gestureDetectors.empty() )
{
- if ( GetImplementation(actor).IsHittable() )
- {
- const Vector3 size( actor.GetCurrentSize() );
+ // We have a match but check if the hit point is within the gestured actor's bounds.
+ // If it is not then continue up the actor hierarchy.
- if ( ( size.x > 0.0f ) && ( size.y > 0.0f ) )
+ 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 );
+ break; // We have found AND emitted a signal on the gestured actor, break out.
+ }
+ else
+ {
+ if ( actor->IsHittable() )
{
- // Ensure tap is within the actor's area
- Actor& actorImpl = GetImplementation(actor);
- if ( actorImpl.RaySphereTest( hitTestResults.rayOrigin, hitTestResults.rayDirection ) ) // Quick check
+ const Vector3 size( actor->GetCurrentSize() );
+
+ if ( ( size.x > 0.0f ) && ( size.y > 0.0f ) )
{
- Vector4 hitPointLocal;
- float distance( 0.0f );
- if( actorImpl.RayActorTest( hitTestResults.rayOrigin, hitTestResults.rayDirection, hitPointLocal, distance ) )
+ // Ensure tap is within the actor's area
+ if ( actor->RaySphereTest( hitTestResults.rayOrigin, hitTestResults.rayDirection ) ) // Quick check
{
- // One of the hit actor's parents was the gestured actor so call the emitting functor.
- functor( actor, gestureDetectors, Vector2( hitPointLocal.x, hitPointLocal.y ) );
- break; // We have found AND emitted a signal on the gestured actor, break out.
+ Vector4 hitPointLocal;
+ 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 ) );
+ break; // We have found AND emitted a signal on the gestured actor, break out.
+ }
}
}
}
}
}
- }
- // Continue up hierarchy to see if any of the parents require this gesture.
- if ( actor )
- {
- actor = actor.GetParent();
+ // Continue up hierarchy to see if any of the parents require this gesture.
+ if ( actor )
+ {
+ actor = actor->GetParent();
+ }
}
}
}
return hitTestResults.renderTask && hitTestResults.actor;
}
-void GestureProcessor::SetActor( Dali::Actor actor )
+void GestureProcessor::SetActor( Actor* actor )
{
if ( actor && actor != mCurrentGesturedActor )
{
ResetActor();
- mCurrentGesturedActor = &GetImplementation( actor );
+ mCurrentGesturedActor = actor;
mCurrentGesturedActor->AddObserver( *this );
}
mGesturedActorDisconnected = false;
*/
virtual ~GestureProcessor();
- // Templates and types for deriving classes
-
- /**
- * Given a container of derived pointer types, this populates an equivalent container of base pointer types.
- * @param[in] derivedContainer A const reference to the container with pointers to the derived class.
- * @param[out] baseContainer A reference to the container to populate with equivalent pointers to the base class.
- * @pre Ensure the baseContainer is empty.
- */
- template< typename Detector >
- static void UpCastContainer( const typename DerivedGestureDetectorContainer<Detector>::type& derivedContainer, GestureDetectorContainer& baseContainer )
- {
- baseContainer.assign( derivedContainer.begin(), derivedContainer.end() );
- }
-
- /**
- * Given a container of base pointer types, this populates an equivalent container of derived pointer types.
- * @param[in] baseContainer A const reference to the container with pointers to the base class.
- * @param[out] derivedContainer A reference to the container to populate with equivalent pointers to the derived class.
- * @pre Ensure the derivedContainer is empty.
- */
- template< typename Detector >
- static void DownCastContainer( const GestureDetectorContainer& baseContainer, typename DerivedGestureDetectorContainer<Detector>::type& derivedContainer )
- {
- for ( GestureDetectorContainer::const_iterator iter = baseContainer.begin(), endIter = baseContainer.end(); iter != endIter; ++iter )
- {
- derivedContainer.push_back( static_cast< Detector* >( *iter ) );
- }
- }
+ // Types for deriving classes
/**
* Functor to use in GetGesturedActor() and ProcessAndEmit() methods.
* @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() ( Dali::Actor actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) = 0;
+ virtual void operator() ( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) = 0;
};
// Methods for deriving classes
/**
- * Given the hit actor and attached detectors, this walks up the actor tree to determine the actor that is connected to one (or several) gesture
- * detectors. The functor is used to check whether the gesture falls within the gesture detector's parameters.
- * Derived classes need to provide this functor.
+ * 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 hit actor. When this function returns, this is the actor that has been hit by the gesture.
- * @param[in] connectedDetectors Reference to the detectors connected to the derived processor
+ * @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 A reference to Functor. The operator() (GestureDetector*) should be used to check if the connected gesture detector
- * meets the current gesture's parameters.
+ * @param[in] functor Used to check if a gesture-detector matches the criteria the gesture detector requires.
+ *
+ * @pre gestureDetectors should be empty.
*/
- void GetGesturedActor( Dali::Actor& actor, const GestureDetectorContainer& connectedDetectors, GestureDetectorContainer& gestureDetectors, Functor& functor );
+ void GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors, Functor& functor );
/**
- * This does what GetGesturedActor() does but also starts emission of the gesture (using the functor).
+ * 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] connectedDetectors The detectors attached to the gesture processor.
- * @param[in] functor A reference to the functor which should provide an operator() to check if detector satisfies current gesture and another
- * operator() which will be called when all conditions are met and the gesture should be emitted for the actor and detectors.
+ * @param[in] functor Used to check if a gesture-detector matches the criteria the gesture detector requires and for emitting the signal.
*
* @pre Hit Testing should already be done.
*/
- void ProcessAndEmit( const HitTestAlgorithm::Results& hitTestResults, const GestureDetectorContainer& connectedDetectors, Functor& functor );
+ void ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults, Functor& functor );
/**
* Hit test the screen coordinates, and place the results in hitTestResults.
* Sets the mCurrentGesturedActor and connects to the required signals.
* @actor actor The actor so set.
*/
- void SetActor( Dali::Actor actor );
+ void SetActor( Actor* actor );
/**
* Resets the set actor and disconnects any connected signals.
* @param[in] localPoint Relative to the actor attached to the detector.
*/
void EmitLongPressSignal(
- Dali::Actor actor,
- LongPressGestureDetectorContainer& gestureDetectors,
+ Actor* actor,
+ const GestureDetectorContainer& gestureDetectors,
const Integration::LongPressGestureEvent& longPressEvent,
Vector2 localPoint)
{
longPress.screenPoint = longPressEvent.point;
longPress.localPoint = localPoint;
- for ( LongPressGestureDetectorContainer::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)->EmitLongPressGestureSignal(actor, longPress);
+ static_cast< LongPressGestureDetector* >( *iter )->EmitLongPressGestureSignal( actorHandle, longPress );
}
}
* @param[in] detector The detector to check.
* @return true, if not attached, false otherwise.
*/
- bool operator()( const LongPressGestureDetector* detector ) const
+ bool operator()( const GestureDetector* detector ) const
{
return !detector->IsAttached( *actorToCheck );
}
/**
* 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 )
+ virtual void operator() ( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
{
- LongPressGestureDetectorContainer derivedContainer;
- DownCastContainer<LongPressGestureDetector>( gestureDetectors, derivedContainer );
-
// Clear actor as
processor.mCurrentEmitters.clear();
processor.ResetActor();
- EmitLongPressSignal( actor, derivedContainer, longPressEvent, actorCoordinates );
+ EmitLongPressSignal( actor, gestureDetectors, longPressEvent, actorCoordinates );
- if ( actor.OnStage() )
+ if ( actor->OnStage() )
{
- processor.mCurrentEmitters = derivedContainer;
+ processor.mCurrentEmitters = gestureDetectors;
processor.SetActor( actor );
}
}
HitTestAlgorithm::Results hitTestResults;
if( HitTest( mStage, longPressEvent.point, hitTestResults ) )
{
- SetActor( hitTestResults.actor );
+ SetActor( &GetImplementation( hitTestResults.actor ) );
}
break;
}
mCurrentRenderTask = hitTestResults.renderTask;
LongPressEventFunctor functor( longPressEvent, *this );
- GestureDetectorContainer gestureDetectors;
- UpCastContainer<LongPressGestureDetector>( mGestureDetectors, gestureDetectors );
- ProcessAndEmit( hitTestResults, gestureDetectors, functor );
+ ProcessAndEmit( hitTestResults, functor );
}
else
{
if ( currentGesturedActor->IsHittable() && !mCurrentEmitters.empty() && mCurrentRenderTask )
{
// Ensure actor is still attached to the emitters, if it is not then remove the emitter.
- LongPressGestureDetectorContainer::iterator endIter = std::remove_if( mCurrentEmitters.begin(), mCurrentEmitters.end(), IsNotAttachedFunctor(currentGesturedActor) );
+ GestureDetectorContainer::iterator endIter = std::remove_if( mCurrentEmitters.begin(), mCurrentEmitters.end(), IsNotAttachedFunctor(currentGesturedActor) );
mCurrentEmitters.erase( endIter, mCurrentEmitters.end() );
if ( !mCurrentEmitters.empty() )
RenderTask& renderTaskImpl( GetImplementation( mCurrentRenderTask ) );
currentGesturedActor->ScreenToLocal( renderTaskImpl, actorCoords.x, actorCoords.y, longPressEvent.point.x, longPressEvent.point.y );
- EmitLongPressSignal( Dali::Actor( currentGesturedActor ), mCurrentEmitters, longPressEvent, actorCoords );
+ EmitLongPressSignal( currentGesturedActor, mCurrentEmitters, longPressEvent, actorCoords );
}
}
Integration::GestureManager& mGestureManager;
LongPressGestureDetectorContainer mGestureDetectors;
- LongPressGestureDetectorContainer mCurrentEmitters;
+ GestureDetectorContainer mCurrentEmitters;
Dali::RenderTask mCurrentRenderTask;
unsigned int mMinTouchesRequired;
* @param[in] touches The number of touches in the current pan event.
* @param[in] outsideRangeEmitters Reference to container where emitters outside of the touches range should be added.
*/
- IsNotAttachedAndOutsideTouchesRangeFunctor(Actor* actor, unsigned int touches, PanGestureDetectorContainer& outsideRangeEmitters)
+ IsNotAttachedAndOutsideTouchesRangeFunctor(Actor* actor, unsigned int touches, GestureDetectorContainer& outsideRangeEmitters)
: actorToCheck(actor),
numberOfTouches(touches),
outsideTouchesRangeEmitters(outsideRangeEmitters)
* @param[in] detector The detector to check.
* @return true, if not attached, false otherwise.
*/
- bool operator()(PanGestureDetector* detector) const
+ bool operator()(GestureDetector* detector) const
{
bool remove(!detector->IsAttached(*actorToCheck));
if (!remove)
{
+ PanGestureDetector* panDetector( static_cast< PanGestureDetector* >( detector ) );
+
// Ensure number of touch points is within the range of our emitter. If it isn't then remove
// this emitter and add it to the outsideTouchesRangeEmitters container
- if ( (numberOfTouches < detector->GetMinimumTouchesRequired()) ||
- (numberOfTouches > detector->GetMaximumTouchesRequired()) )
+ if ( (numberOfTouches < panDetector->GetMinimumTouchesRequired()) ||
+ (numberOfTouches > panDetector->GetMaximumTouchesRequired()) )
{
remove = true;
outsideTouchesRangeEmitters.push_back(detector);
Actor* actorToCheck; ///< The actor to check whether it is attached or not.
unsigned int numberOfTouches; ///< The number of touches in the pan event.
- PanGestureDetectorContainer& outsideTouchesRangeEmitters; ///< Emitters that are outside of the range of current pan.
+ GestureDetectorContainer& outsideTouchesRangeEmitters; ///< Emitters that are outside of the range of current pan.
};
} // unnamed namespace
/**
* 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 )
+ virtual void operator() ( 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 );
+ actor->ScreenToLocal( GetImplementation(processor.mCurrentRenderTask), actorCoordinates.x, actorCoordinates.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
- processor.EmitPanSignal( actor, derivedContainer, panEvent, actorCoordinates, panEvent.state, processor.mCurrentRenderTask );
+ processor.EmitPanSignal( actor, gestureDetectors, panEvent, actorCoordinates, panEvent.state, processor.mCurrentRenderTask );
- if ( actorImpl->OnStage() )
+ if ( actor->OnStage() )
{
- processor.mCurrentPanEmitters = derivedContainer;
+ processor.mCurrentPanEmitters = gestureDetectors;
processor.SetActor( actor );
}
}
HitTestAlgorithm::Results hitTestResults;
if( HitTest( mStage, panEvent.currentPosition, hitTestResults ) )
{
- SetActor( hitTestResults.actor );
+ SetActor( &GetImplementation( hitTestResults.actor ) );
mPossiblePanPosition = panEvent.currentPosition;
}
mCurrentRenderTask = hitTestResults.renderTask;
PanEventFunctor functor( panEvent, *this );
- GestureDetectorContainer gestureDetectors;
- UpCastContainer<PanGestureDetector>( mGestureDetectors, gestureDetectors );
- ProcessAndEmit( hitTestResults, gestureDetectors, functor );
+ ProcessAndEmit( hitTestResults, functor );
}
else
{
{
if ( currentGesturedActor->IsHittable() && !mCurrentPanEmitters.empty() && mCurrentRenderTask )
{
- PanGestureDetectorContainer outsideTouchesRangeEmitters;
+ GestureDetectorContainer outsideTouchesRangeEmitters;
// Removes emitters that no longer have the actor attached
// Also remove emitters whose touches are outside the range of the current pan event and add them to outsideTouchesRangeEmitters
- PanGestureDetectorContainer::iterator endIter = std::remove_if( mCurrentPanEmitters.begin(), mCurrentPanEmitters.end(),
- IsNotAttachedAndOutsideTouchesRangeFunctor(currentGesturedActor, panEvent.numberOfTouches, outsideTouchesRangeEmitters) );
+ GestureDetectorContainer::iterator endIter = std::remove_if( mCurrentPanEmitters.begin(), mCurrentPanEmitters.end(),
+ IsNotAttachedAndOutsideTouchesRangeFunctor(currentGesturedActor, panEvent.numberOfTouches, outsideTouchesRangeEmitters) );
mCurrentPanEmitters.erase( endIter, mCurrentPanEmitters.end() );
Vector2 actorCoords;
currentGesturedActor->ScreenToLocal( GetImplementation( mCurrentRenderTask ), actorCoords.x, actorCoords.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
// EmitPanSignal checks whether we have a valid actor and whether the container we are passing in has emitters before it emits the pan.
- EmitPanSignal(Dali::Actor(currentGesturedActor), outsideTouchesRangeEmitters, panEvent, actorCoords, Gesture::Finished, mCurrentRenderTask);
- EmitPanSignal(Dali::Actor(currentGesturedActor), mCurrentPanEmitters, panEvent, actorCoords, panEvent.state, mCurrentRenderTask);
+ EmitPanSignal( currentGesturedActor, outsideTouchesRangeEmitters, panEvent, actorCoords, Gesture::Finished, mCurrentRenderTask);
+ EmitPanSignal( currentGesturedActor, mCurrentPanEmitters, panEvent, actorCoords, panEvent.state, mCurrentRenderTask);
}
if ( mCurrentPanEmitters.empty() )
if (!mCurrentPanEmitters.empty())
{
// Check if the removed detector was one that is currently being panned and remove it from emitters.
- PanGestureDetectorContainer::iterator endIter = std::remove( mCurrentPanEmitters.begin(), mCurrentPanEmitters.end(), gestureDetector );
+ GestureDetectorContainer::iterator endIter = std::remove( mCurrentPanEmitters.begin(), mCurrentPanEmitters.end(), gestureDetector );
mCurrentPanEmitters.erase( endIter, mCurrentPanEmitters.end() );
// If we no longer have any emitters, then we should clear mCurrentGesturedActor as well
}
}
-void PanGestureProcessor::EmitPanSignal( Dali::Actor actorHandle,
- PanGestureDetectorContainer& gestureDetectors,
+void PanGestureProcessor::EmitPanSignal( Actor* actor,
+ const GestureDetectorContainer& gestureDetectors,
const Integration::PanGestureEvent& panEvent,
Vector2 localCurrent,
Gesture::State state,
Dali::RenderTask renderTask )
{
- if ( actorHandle && !gestureDetectors.empty() )
+ if ( actor && !gestureDetectors.empty() )
{
- Actor& actor = GetImplementation(actorHandle);
-
PanGesture pan(state);
pan.time = panEvent.time;
RenderTask& renderTaskImpl( GetImplementation( renderTask ) );
Vector2 localPrevious;
- actor.ScreenToLocal( renderTaskImpl, localPrevious.x, localPrevious.y, panEvent.previousPosition.x, panEvent.previousPosition.y );
+ actor->ScreenToLocal( renderTaskImpl, localPrevious.x, localPrevious.y, panEvent.previousPosition.x, panEvent.previousPosition.y );
pan.displacement = localCurrent - localPrevious;
Vector2 previousPos( panEvent.previousPosition );
mSceneObject->AddGesture( pan );
}
- for ( PanGestureDetectorContainer::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)->EmitPanGestureSignal(actorHandle, pan);
+ static_cast< PanGestureDetector* >( *iter )->EmitPanGestureSignal( actorHandle, pan );
}
}
}
* @param[in] state The state of the gesture.
* @param[in] renderTask The renderTask to use.
*/
- void EmitPanSignal( Dali::Actor actor,
- PanGestureDetectorContainer& gestureDetectors,
+ void EmitPanSignal( Actor* actor,
+ const GestureDetectorContainer& gestureDetectors,
const Integration::PanGestureEvent& panEvent,
Vector2 localCurrent,
Gesture::State state,
Stage& mStage;
Integration::GestureManager& mGestureManager;
PanGestureDetectorContainer mGestureDetectors;
- PanGestureDetectorContainer mCurrentPanEmitters;
+ GestureDetectorContainer mCurrentPanEmitters;
Dali::RenderTask mCurrentRenderTask;
Vector2 mPossiblePanPosition;
* @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);
}
/**
* 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 )
+ virtual void operator() ( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
{
- PinchGestureDetectorContainer derivedContainer;
- DownCastContainer<PinchGestureDetector>( gestureDetectors, derivedContainer );
+ EmitPinchSignal( actor, gestureDetectors, pinchEvent, actorCoordinates );
- EmitPinchSignal( actor, derivedContainer, pinchEvent, actorCoordinates );
-
- if ( actor.OnStage() )
+ if ( actor->OnStage() )
{
- processor.mCurrentPinchEmitters = derivedContainer;
+ processor.mCurrentPinchEmitters = gestureDetectors;
processor.SetActor( actor );
}
}
mCurrentRenderTask = hitTestResults.renderTask;
PinchEventFunctor functor( pinchEvent, *this ); // Sets mCurrentGesturedActor
- GestureDetectorContainer gestureDetectors;
- UpCastContainer<PinchGestureDetector>( mGestureDetectors, gestureDetectors );
- ProcessAndEmit( hitTestResults, gestureDetectors, functor );
+ ProcessAndEmit( hitTestResults, functor );
}
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
Stage& mStage;
Integration::GestureManager& mGestureManager;
PinchGestureDetectorContainer mGestureDetectors;
- PinchGestureDetectorContainer mCurrentPinchEmitters;
+ GestureDetectorContainer mCurrentPinchEmitters;
Dali::RenderTask mCurrentRenderTask;
struct PinchEventFunctor;
* @param[in] localPoint Relative to the actor attached to the detector.
*/
void EmitTapSignal(
- Dali::Actor actor,
- TapGestureDetectorContainer& gestureDetectors,
+ Actor* actor,
+ const GestureDetectorContainer& gestureDetectors,
const Integration::TapGestureEvent& tapEvent,
Vector2 localPoint)
{
tap.screenPoint = tapEvent.point;
tap.localPoint = localPoint;
- for ( TapGestureDetectorContainer::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)->EmitTapGestureSignal( actor, tap );
+ static_cast< TapGestureDetector* >( *iter )->EmitTapGestureSignal( actorHandle, tap );
}
}
/**
* 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 )
+ virtual void operator() ( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
{
- TapGestureDetectorContainer derivedContainer;
- DownCastContainer<TapGestureDetector>( gestureDetectors, derivedContainer );
- EmitTapSignal( actor, derivedContainer, tapEvent, actorCoordinates );
+ EmitTapSignal( actor, gestureDetectors, tapEvent, actorCoordinates );
}
const Integration::TapGestureEvent& tapEvent;
if( HitTest( mStage, tapEvent.point, hitTestResults ) )
{
// Only sets the actor if we have a hit.
- SetActor( hitTestResults.actor );
+ SetActor( &GetImplementation( hitTestResults.actor ) );
}
break;
}
if ( hitTestResults.actor && ( GetCurrentGesturedActor() == &GetImplementation( hitTestResults.actor ) ) )
{
TapEventFunctor functor( tapEvent );
- GestureDetectorContainer gestureDetectors;
- UpCastContainer<TapGestureDetector>( mGestureDetectors, gestureDetectors );
- ProcessAndEmit( hitTestResults, gestureDetectors, functor );
+ ProcessAndEmit( hitTestResults, functor );
}
ResetActor();