Merge "Gesture event refactor" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / events / touch-event-processor.cpp
index b9c305c..b9047bd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/actors/layer-impl.h>
-#include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/scene-impl.h>
 #include <dali/internal/event/events/hit-test-algorithm-impl.h>
 #include <dali/internal/event/events/multi-point-event-util.h>
 #include <dali/internal/event/events/touch-data-impl.h>
@@ -149,8 +149,8 @@ Dali::Actor EmitTouchSignals( Actor* actor, RenderTask& renderTask, const TouchE
 
 } // unnamed namespace
 
-TouchEventProcessor::TouchEventProcessor( Stage& stage )
-: mStage( stage ),
+TouchEventProcessor::TouchEventProcessor( Scene& scene )
+: mScene( scene ),
   mLastPrimaryHitActor( MakeCallback( this, &TouchEventProcessor::OnObservedActorDisconnected ) ),
   mLastConsumedActor(),
   mTouchDownConsumedActor(),
@@ -167,11 +167,8 @@ TouchEventProcessor::~TouchEventProcessor()
 void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& event )
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
-
   DALI_ASSERT_ALWAYS( !event.points.empty() && "Empty TouchEvent sent from Integration\n" );
 
-  Stage& stage = mStage;
-
   PRINT_HIERARCHY(gLogFilter);
 
   // 1) Check if it is an interrupted event - we should inform our last primary hit actor about this
@@ -229,8 +226,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
     touchEvent.points.push_back( currentPoint.GetTouchPoint() );
     touchData->AddPoint( currentPoint );
 
-    mStage.EmitTouchedSignal( touchEvent, touchDataHandle );
-
+    mScene.EmitTouchedSignal( touchEvent, touchDataHandle );
     return; // No need for hit testing
   }
 
@@ -242,12 +238,12 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
   DALI_LOG_INFO( gLogFilter, Debug::Concise, "\n" );
   DALI_LOG_INFO( gLogFilter, Debug::General, "Point(s): %d\n", event.GetPointCount() );
 
-  Dali::RenderTask currentRenderTask;
+  RenderTaskPtr currentRenderTask;
 
   for ( Integration::PointContainerConstIterator iter = event.points.begin(), beginIter = event.points.begin(), endIter = event.points.end(); iter != endIter; ++iter )
   {
     HitTestAlgorithm::Results hitTestResults;
-    HitTestAlgorithm::HitTest( stage, iter->GetScreenPosition(), hitTestResults );
+    HitTestAlgorithm::HitTest( mScene.GetSize(), mScene.GetRenderTaskList(), mScene.GetLayerList(), iter->GetScreenPosition(), hitTestResults );
 
     Integration::Point newPoint( *iter );
     newPoint.SetHitActor( hitTestResults.actor );
@@ -258,7 +254,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
 
     DALI_LOG_INFO( gLogFilter, Debug::General, "  State(%s), Screen(%.0f, %.0f), HitActor(%p, %s), Local(%.2f, %.2f)\n",
                    TOUCH_POINT_STATE[iter->GetState()], iter->GetScreenPosition().x, iter->GetScreenPosition().y,
-                   ( hitTestResults.actor ? (void*)&hitTestResults.actor.GetBaseObject() : NULL ),
+                   ( hitTestResults.actor ? reinterpret_cast< void* >( &hitTestResults.actor.GetBaseObject() ) : NULL ),
                    ( hitTestResults.actor ? hitTestResults.actor.GetName().c_str() : "" ),
                    hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y );
 
@@ -282,8 +278,8 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
   Dali::Actor primaryHitActor = primaryPoint.GetHitActor();
   PointState::Type primaryPointState = primaryPoint.GetState();
 
-  DALI_LOG_INFO( gLogFilter, Debug::Concise, "PrimaryHitActor:     (%p) %s\n", primaryHitActor ? (void*)&primaryHitActor.GetBaseObject() : NULL, primaryHitActor ? primaryHitActor.GetName().c_str() : "" );
-  DALI_LOG_INFO( gLogFilter, Debug::Concise, "ConsumedActor:       (%p) %s\n", consumedActor ? (void*)&consumedActor.GetBaseObject() : NULL, consumedActor ? consumedActor.GetName().c_str() : "" );
+  DALI_LOG_INFO( gLogFilter, Debug::Concise, "PrimaryHitActor:     (%p) %s\n", primaryHitActor ? reinterpret_cast< void* >( &primaryHitActor.GetBaseObject() ) : NULL, primaryHitActor ? primaryHitActor.GetName().c_str() : "" );
+  DALI_LOG_INFO( gLogFilter, Debug::Concise, "ConsumedActor:       (%p) %s\n", consumedActor ? reinterpret_cast< void* >( &consumedActor.GetBaseObject() ) : NULL, consumedActor ? consumedActor.GetName().c_str() : "" );
 
   if ( ( primaryPointState == PointState::DOWN ) &&
        ( touchEvent.GetPointCount() == 1 ) &&
@@ -299,10 +295,10 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
   Actor* lastConsumedActor( mLastConsumedActor.GetActor() );
   if( ( primaryPointState == PointState::MOTION ) || ( primaryPointState == PointState::UP ) || ( primaryPointState == PointState::STATIONARY ) )
   {
-    if ( mLastRenderTask )
+    if( mLastRenderTask )
     {
       Dali::Actor leaveEventConsumer;
-      RenderTask& lastRenderTaskImpl( GetImplementation( mLastRenderTask ) );
+      RenderTask& lastRenderTaskImpl = *mLastRenderTask.Get();
 
       if( lastPrimaryHitActor &&
           lastPrimaryHitActor != primaryHitActor &&
@@ -312,7 +308,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
         {
           if ( lastPrimaryHitActor->GetLeaveRequired() )
           {
-            DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Hit):     (%p) %s\n", (void*)lastPrimaryHitActor, lastPrimaryHitActor->GetName().c_str() );
+            DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Hit):     (%p) %s\n", reinterpret_cast< void* >( lastPrimaryHitActor ), lastPrimaryHitActor->GetName().c_str() );
             leaveEventConsumer = EmitTouchSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEvent, touchData, PointState::LEAVE );
           }
         }
@@ -320,7 +316,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
         {
           // At this point mLastPrimaryHitActor was touchable and sensitive in the previous touch event process but is not in the current one.
           // An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls)
-          DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Hit):     (%p) %s\n", (void*)lastPrimaryHitActor, lastPrimaryHitActor->GetName().c_str() );
+          DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Hit):     (%p) %s\n", reinterpret_cast< void* >( lastPrimaryHitActor ), lastPrimaryHitActor->GetName().c_str() );
           leaveEventConsumer = EmitTouchSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEvent, touchData, PointState::INTERRUPTED );
         }
       }
@@ -338,7 +334,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
         {
           if( lastConsumedActor->GetLeaveRequired() )
           {
-            DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Consume): (%p) %s\n", (void*)lastConsumedActor, lastConsumedActor->GetName().c_str() );
+            DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Consume): (%p) %s\n", reinterpret_cast< void* >( lastConsumedActor ), lastConsumedActor->GetName().c_str() );
             EmitTouchSignals( lastConsumedActor, lastRenderTaskImpl, touchEvent, touchData, PointState::LEAVE );
           }
         }
@@ -346,7 +342,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
         {
           // At this point mLastConsumedActor was touchable and sensitive in the previous touch event process but is not in the current one.
           // An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls)
-          DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Consume):     (%p) %s\n", (void*)lastConsumedActor, lastConsumedActor->GetName().c_str() );
+          DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Consume):     (%p) %s\n", reinterpret_cast< void* >( lastConsumedActor ), lastConsumedActor->GetName().c_str() );
           EmitTouchSignals( mLastConsumedActor.GetActor(), lastRenderTaskImpl, touchEvent, touchData, PointState::INTERRUPTED );
         }
       }
@@ -419,7 +415,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
 
       case PointState::DOWN:
       {
-        mStage.EmitTouchedSignal( touchEvent, touchDataHandle );
+        mScene.EmitTouchedSignal( touchEvent, touchDataHandle );
         break;
       }