Merge "Ensure animation is not played when an actor is not on scene" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-impl.cpp
old mode 100755 (executable)
new mode 100644 (file)
index ca215aa..6b3386a
@@ -230,7 +230,7 @@ const char* const SIGNAL_WHEEL_EVENT = "wheelEvent";
 const char* const SIGNAL_ON_SCENE = "onScene";
 const char* const SIGNAL_OFF_SCENE = "offScene";
 const char* const SIGNAL_ON_RELAYOUT = "onRelayout";
-const char* const SIGNAL_TOUCH = "touch";
+const char* const SIGNAL_TOUCHED = "touched";
 const char* const SIGNAL_VISIBILITY_CHANGED = "visibilityChanged";
 const char* const SIGNAL_LAYOUT_DIRECTION_CHANGED = "layoutDirectionChanged";
 const char* const SIGNAL_CHILD_ADDED = "childAdded";
@@ -253,7 +253,7 @@ SignalConnectorType signalConnector3( mType, SIGNAL_WHEEL_EVENT, &Actor::DoConne
 SignalConnectorType signalConnector4( mType, SIGNAL_ON_SCENE, &Actor::DoConnectSignal );
 SignalConnectorType signalConnector5( mType, SIGNAL_OFF_SCENE, &Actor::DoConnectSignal );
 SignalConnectorType signalConnector6( mType, SIGNAL_ON_RELAYOUT, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector7( mType, SIGNAL_TOUCH, &Actor::DoConnectSignal );
+SignalConnectorType signalConnector7( mType, SIGNAL_TOUCHED, &Actor::DoConnectSignal );
 SignalConnectorType signalConnector8( mType, SIGNAL_VISIBILITY_CHANGED, &Actor::DoConnectSignal );
 SignalConnectorType signalConnector9( mType, SIGNAL_LAYOUT_DIRECTION_CHANGED, &Actor::DoConnectSignal );
 SignalConnectorType signalConnector10( mType, SIGNAL_CHILD_ADDED, &Actor::DoConnectSignal );
@@ -462,7 +462,7 @@ Dali::Layer Actor::GetLayer()
   }
 
   // Find the immediate Layer parent
-  for( Actor* parent = mParent; !layer && parent != NULL; parent = parent->GetParent() )
+  for( Actor* parent = mParent; !layer && parent != nullptr; parent = parent->GetParent() )
   {
     if( parent->IsLayer() )
     {
@@ -549,7 +549,7 @@ void Actor::Remove( Actor& child )
       mChildren->erase( iter );
 
       DALI_ASSERT_DEBUG( actor->GetParent() == this );
-      actor->SetParent( NULL );
+      actor->SetParent( nullptr );
 
       break;
     }
@@ -582,7 +582,7 @@ void Actor::Unparent()
 
 uint32_t Actor::GetChildCount() const
 {
-  return ( NULL != mChildren ) ? static_cast<uint32_t>( mChildren->size() ) : 0; // only 4,294,967,295 children per actor
+  return ( nullptr != mChildren ) ? static_cast<uint32_t>( mChildren->size() ) : 0; // only 4,294,967,295 children per actor
 }
 
 ActorPtr Actor::GetChildAt( uint32_t index ) const
@@ -594,7 +594,7 @@ ActorPtr Actor::GetChildAt( uint32_t index ) const
 
 ActorPtr Actor::FindChildByName( const std::string& actorName )
 {
-  ActorPtr child = 0;
+  ActorPtr child = nullptr;
   if( actorName == mName )
   {
     child = this;
@@ -617,7 +617,7 @@ ActorPtr Actor::FindChildByName( const std::string& actorName )
 
 ActorPtr Actor::FindChildById( const uint32_t id )
 {
-  ActorPtr child = 0;
+  ActorPtr child = nullptr;
   if( id == GetId() )
   {
     child = this;
@@ -1788,17 +1788,17 @@ bool Actor::IsKeyboardFocusable() const
 
 bool Actor::GetTouchRequired() const
 {
-  return !mTouchSignal.Empty() || mDerivedRequiresTouch;
+  return !mTouchedSignal.Empty();
 }
 
 bool Actor::GetHoverRequired() const
 {
-  return !mHoveredSignal.Empty() || mDerivedRequiresHover;
+  return !mHoveredSignal.Empty();
 }
 
 bool Actor::GetWheelEventRequired() const
 {
-  return !mWheelEventSignal.Empty() || mDerivedRequiresWheelEvent;
+  return !mWheelEventSignal.Empty();
 }
 
 bool Actor::IsHittable() const
@@ -1810,26 +1810,26 @@ ActorGestureData& Actor::GetGestureData()
 {
   // Likely scenario is that once gesture-data is created for this actor, the actor will require
   // that gesture for its entire life-time so no need to destroy it until the actor is destroyed
-  if( NULL == mGestureData )
+  if( nullptr == mGestureData )
   {
     mGestureData = new ActorGestureData;
   }
   return *mGestureData;
 }
 
-bool Actor::IsGestureRequred( DevelGesture::Type type ) const
+bool Actor::IsGestureRequired( GestureType::Value type ) const
 {
-  return mGestureData && mGestureData->IsGestureRequred( type );
+  return mGestureData && mGestureData->IsGestureRequired( type );
 }
 
 bool Actor::EmitTouchEventSignal( const Dali::TouchEvent& touch )
 {
   bool consumed = false;
 
-  if( !mTouchSignal.Empty() )
+  if( !mTouchedSignal.Empty() )
   {
     Dali::Actor handle( this );
-    consumed = mTouchSignal.Emit( handle, touch );
+    consumed = mTouchedSignal.Emit( handle, touch );
   }
 
   return consumed;
@@ -1845,16 +1845,10 @@ bool Actor::EmitHoverEventSignal( const Dali::HoverEvent& event )
     consumed = mHoveredSignal.Emit( handle, event );
   }
 
-  if( !consumed )
-  {
-    // Notification for derived classes
-    consumed = OnHoverEvent( event );
-  }
-
   return consumed;
 }
 
-bool Actor::EmitWheelEventSignal( const WheelEvent& event )
+bool Actor::EmitWheelEventSignal( const Dali::WheelEvent& event )
 {
   bool consumed = false;
 
@@ -1864,12 +1858,6 @@ bool Actor::EmitWheelEventSignal( const WheelEvent& event )
     consumed = mWheelEventSignal.Emit( handle, event );
   }
 
-  if( !consumed )
-  {
-    // Notification for derived classes
-    consumed = OnWheelEvent( event );
-  }
-
   return consumed;
 }
 
@@ -1909,9 +1897,9 @@ void Actor::EmitChildRemovedSignal( Actor& child )
   }
 }
 
-Dali::Actor::TouchEventSignalType& Actor::TouchSignal()
+Dali::Actor::TouchEventSignalType& Actor::TouchedSignal()
 {
-  return mTouchSignal;
+  return mTouchedSignal;
 }
 
 Dali::Actor::HoverSignalType& Actor::HoveredSignal()
@@ -1989,9 +1977,9 @@ bool Actor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra
   {
     actor->OnRelayoutSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_TOUCH ) )
+  else if( 0 == signalName.compare( SIGNAL_TOUCHED ) )
   {
-    actor->TouchSignal().Connect( tracker, functor );
+    actor->TouchedSignal().Connect( tracker, functor );
   }
   else if( 0 == signalName.compare( SIGNAL_VISIBILITY_CHANGED ) )
   {
@@ -2021,14 +2009,14 @@ bool Actor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra
 Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node )
 : Object( &node ),
   mScene( nullptr ),
-  mParent( NULL ),
-  mChildren( NULL ),
-  mRenderers( NULL ),
-  mParentOrigin( NULL ),
-  mAnchorPoint( NULL ),
-  mRelayoutData( NULL ),
-  mGestureData( NULL ),
-  mTouchSignal(),
+  mParent( nullptr ),
+  mChildren( nullptr ),
+  mRenderers( nullptr ),
+  mParentOrigin( nullptr ),
+  mAnchorPoint( nullptr ),
+  mRelayoutData( nullptr ),
+  mGestureData( nullptr ),
+  mTouchedSignal(),
   mHoveredSignal(),
   mWheelEventSignal(),
   mOnSceneSignal(),
@@ -2055,9 +2043,6 @@ Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node )
   mSensitive( true ),
   mLeaveRequired( false ),
   mKeyboardFocusable( false ),
-  mDerivedRequiresTouch( false ),
-  mDerivedRequiresHover( false ),
-  mDerivedRequiresWheelEvent( false ),
   mOnSceneSignalled( false ),
   mInsideOnSizeSet( false ),
   mInheritPosition( true ),
@@ -2090,7 +2075,7 @@ Actor::~Actor()
     ActorConstIter endIter = mChildren->end();
     for( ActorIter iter = mChildren->begin(); iter != endIter; ++iter )
     {
-      (*iter)->SetParent( NULL );
+      (*iter)->SetParent( nullptr );
     }
   }
   delete mChildren;
@@ -3315,7 +3300,7 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In
 
 const PropertyBase* Actor::GetSceneObjectAnimatableProperty( Property::Index index ) const
 {
-  const PropertyBase* property( NULL );
+  const PropertyBase* property( nullptr );
 
   switch( index )
   {
@@ -3379,7 +3364,7 @@ const PropertyBase* Actor::GetSceneObjectAnimatableProperty( Property::Index ind
 
 const PropertyInputImpl* Actor::GetSceneObjectInputProperty( Property::Index index ) const
 {
-  const PropertyInputImpl* property( NULL );
+  const PropertyInputImpl* property( nullptr );
 
   switch( index )
   {
@@ -3511,6 +3496,11 @@ int32_t Actor::GetPropertyComponentIndex( Property::Index index ) const
   return componentIndex;
 }
 
+bool Actor::IsAnimationPossible() const
+{
+  return OnScene();
+}
+
 void Actor::SetParent( Actor* parent )
 {
   if( parent )
@@ -3533,9 +3523,9 @@ void Actor::SetParent( Actor* parent )
   }
   else // parent being set to NULL
   {
-    DALI_ASSERT_ALWAYS( mParent != NULL && "Actor should have a parent" );
+    DALI_ASSERT_ALWAYS( mParent != nullptr && "Actor should have a parent" );
 
-    mParent = NULL;
+    mParent = nullptr;
 
     if ( EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
          OnScene() )