Revert "[Tizen] Not execute the remove callback"
[platform/core/uifw/dali-core.git] / dali / internal / event / events / wheel-event-processor.cpp
index a5c93e8..c54cd3e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
 // INTERNAL INCLUDES
 #include <dali/public-api/events/wheel-event.h>
 
-#include <dali/public-api/math/vector2.h>
+#include <dali/integration-api/debug.h>
 #include <dali/integration-api/events/wheel-event-integ.h>
+#include <dali/integration-api/trace.h>
 #include <dali/internal/event/actors/actor-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/wheel-event-impl.h>
+#include <dali/public-api/math/vector2.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 namespace
 {
-
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
 #if defined(DEBUG_ENABLED)
 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WHEEL_PROCESSOR");
 #endif
@@ -44,40 +44,40 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WHE
 /**
  *  Recursively deliver events to the actor and its parents, until the event is consumed or the stage is reached.
  */
-Dali::Actor EmitWheelSignals( Dali::Actor actor, const Dali::WheelEvent& event )
+Dali::Actor EmitWheelSignals(Dali::Actor actor, const Dali::WheelEvent& event)
 {
   Dali::Actor consumedActor;
 
-  if ( actor )
+  if(actor)
   {
-    Dali::Actor oldParent( actor.GetParent() );
+    Dali::Actor oldParent(actor.GetParent());
 
-    Actor& actorImpl( GetImplementation(actor) );
+    Actor& actorImpl(GetImplementation(actor));
 
-    bool consumed( false );
+    bool consumed(false);
 
     // Only do the conversion and emit the signal if the actor's wheel signal has connections.
-    if ( actorImpl.GetWheelEventRequired() )
+    if(actorImpl.GetWheelEventRequired())
     {
       // Emit the signal to the parent
-      consumed = actorImpl.EmitWheelEventSignal( event );
+      consumed = actorImpl.EmitWheelEventSignal(event);
     }
 
-    if ( consumed )
+    if(consumed)
     {
       // One of this actor's listeners has consumed the event so set this actor as the consumed actor.
-      consumedActor = Dali::Actor( &actorImpl );
+      consumedActor = Dali::Actor(&actorImpl);
     }
     else
     {
       // The actor may have been removed/reparented during the signal callbacks.
       Dali::Actor parent = actor.GetParent();
 
-      if ( parent &&
-           (parent == oldParent) )
+      if(parent &&
+         (parent == oldParent))
       {
         // One of the actor's parents may consumed the event and they should be set as the consumed actor.
-        consumedActor = EmitWheelSignals( parent, event );
+        consumedActor = EmitWheelSignals(parent, event);
       }
     }
   }
@@ -92,12 +92,12 @@ bool IsActorWheelableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::Travers
 {
   bool hittable = false;
 
-  switch (type)
+  switch(type)
   {
     case Dali::HitTestAlgorithm::CHECK_ACTOR:
     {
-      if( GetImplementation(actor).GetWheelEventRequired() && // Does the Application or derived actor type require a wheel event?
-          GetImplementation(actor).IsHittable() )
+      if(GetImplementation(actor).GetWheelEventRequired() && // Does the Application or derived actor type require a wheel event?
+         GetImplementation(actor).IsHittable())
       {
         hittable = true;
       }
@@ -105,7 +105,7 @@ bool IsActorWheelableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::Travers
     }
     case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
     {
-      if( actor.GetProperty< bool >( Dali::Actor::Property::VISIBLE ) ) // Actor is visible, if not visible then none of its children are visible.
+      if(actor.GetProperty<bool>(Dali::Actor::Property::VISIBLE)) // Actor is visible, if not visible then none of its children are visible.
       {
         hittable = true;
       }
@@ -122,42 +122,41 @@ bool IsActorWheelableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::Travers
 
 } // unnamed namespace
 
-
-WheelEventProcessor::WheelEventProcessor( Scene& scene )
-: mScene( scene )
+WheelEventProcessor::WheelEventProcessor(Scene& scene)
+: mScene(scene)
 {
 }
 
-WheelEventProcessor::~WheelEventProcessor()
-{
-}
+WheelEventProcessor::~WheelEventProcessor() = default;
 
-void WheelEventProcessor::ProcessWheelEvent( const Integration::WheelEvent& event )
+void WheelEventProcessor::ProcessWheelEvent(const Integration::WheelEvent& event)
 {
-  WheelEventPtr wheelEvent = WheelEvent::New( static_cast< Dali::WheelEvent::Type >( event.type ), event.direction, event.modifiers, event.point, event.delta, event.timeStamp );
-  Dali::WheelEvent wheelEventHandle( wheelEvent.Get() );
+  WheelEventPtr    wheelEvent = WheelEvent::New(static_cast<Dali::WheelEvent::Type>(event.type), event.direction, event.modifiers, event.point, event.delta, event.timeStamp);
+  Dali::WheelEvent wheelEventHandle(wheelEvent.Get());
+
+  DALI_TRACE_SCOPE(gTraceFilter, "DALI_PROCESS_WHEEL_EVENT");
 
-  if( wheelEvent->GetType() == Dali::WheelEvent::MOUSE_WHEEL )
+  if(wheelEvent->GetType() == Dali::WheelEvent::MOUSE_WHEEL)
   {
     Dali::HitTestAlgorithm::Results hitTestResults;
-    HitTestAlgorithm::HitTest( mScene.GetSize(), mScene.GetRenderTaskList(), mScene.GetLayerList(), event.point, hitTestResults, IsActorWheelableFunction );
+    HitTestAlgorithm::HitTest(mScene.GetSize(), mScene.GetRenderTaskList(), mScene.GetLayerList(), event.point, hitTestResults, IsActorWheelableFunction);
 
-    DALI_LOG_INFO( gLogFilter, Debug::General, "  Screen(%.0f, %.0f), HitActor(%p, %s), Local(%.2f, %.2f)\n",
-                   event.point.x, event.point.y,
-                   ( hitTestResults.actor ? reinterpret_cast< void* >( &hitTestResults.actor.GetBaseObject() ) : NULL ),
-                   ( hitTestResults.actor ? hitTestResults.actor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" ),
-                   hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y );
+    DALI_LOG_INFO(gLogFilter, Debug::General, "  Screen(%.0f, %.0f), HitActor(%p, %s), Local(%.2f, %.2f)\n", event.point.x, event.point.y, (hitTestResults.actor ? reinterpret_cast<void*>(&hitTestResults.actor.GetBaseObject()) : NULL), (hitTestResults.actor ? hitTestResults.actor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : ""), hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y);
 
     // Recursively deliver events to the actor and its parents, until the event is consumed or the stage is reached.
-    Dali::Actor consumedActor = EmitWheelSignals( hitTestResults.actor, wheelEventHandle );
+    Dali::Actor consumedActor = EmitWheelSignals(hitTestResults.actor, wheelEventHandle);
 
-    DALI_LOG_INFO( gLogFilter, Debug::Concise, "HitActor:      (%p) %s\n", hitTestResults.actor ? reinterpret_cast< void* >( &hitTestResults.actor.GetBaseObject() ) : NULL, hitTestResults.actor ? hitTestResults.actor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" );
-    DALI_LOG_INFO( gLogFilter, Debug::Concise, "ConsumedActor: (%p) %s\n", consumedActor ? reinterpret_cast< void* >( &consumedActor.GetBaseObject() ) : NULL, consumedActor ? consumedActor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" );
+    DALI_LOG_INFO(gLogFilter, Debug::Concise, "HitActor:      (%p) %s\n", hitTestResults.actor ? reinterpret_cast<void*>(&hitTestResults.actor.GetBaseObject()) : NULL, hitTestResults.actor ? hitTestResults.actor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : "");
+    DALI_LOG_INFO(gLogFilter, Debug::Concise, "ConsumedActor: (%p) %s\n", consumedActor ? reinterpret_cast<void*>(&consumedActor.GetBaseObject()) : NULL, consumedActor ? consumedActor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : "");
   }
   else
   {
     // if CUSTOM_WHEEL, emit the wheel event signal from the scene.
-    mScene.EmitWheelEventSignal( wheelEventHandle );
+    bool consumed = mScene.EmitWheelEventGeneratedSignal(wheelEventHandle);
+    if(!consumed)
+    {
+      mScene.EmitWheelEventSignal(wheelEventHandle);
+    }
   }
 }