/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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/devel-api/events/hit-test-algorithm.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/internal/event/common/stage-impl.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
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WHEEL_PROCESSOR");
#endif
/**
* 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 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);
}
}
}
{
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;
}
}
case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
{
- if( actor.IsVisible() ) // 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;
}
} // unnamed namespace
-
-WheelEventProcessor::WheelEventProcessor(Stage& stage)
-: mStage(stage)
+WheelEventProcessor::WheelEventProcessor(Scene& scene)
+: mScene(scene)
{
}
-WheelEventProcessor::~WheelEventProcessor()
-{
-}
+WheelEventProcessor::~WheelEventProcessor() = default;
void WheelEventProcessor::ProcessWheelEvent(const Integration::WheelEvent& event)
{
- Stage& stage = mStage;
- WheelEvent wheelEvent( static_cast< WheelEvent::Type >(event.type), event.direction, event.modifiers, event.point, event.z, event.timeStamp );
+ 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());
- if( wheelEvent.type == WheelEvent::MOUSE_WHEEL )
+ if(wheelEvent->GetType() == Dali::WheelEvent::MOUSE_WHEEL)
{
- HitTestAlgorithm::Results hitTestResults;
- HitTestAlgorithm::HitTest( Dali::Stage(&stage), event.point, hitTestResults, IsActorWheelableFunction );
+ Dali::HitTestAlgorithm::Results hitTestResults;
+ 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.GetName().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, wheelEvent );
+ 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.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() : "" );
+ 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 key event signal from stage.
- mStage.EmitWheelEventSignal( wheelEvent );
+ // if CUSTOM_WHEEL, emit the wheel event signal from the scene.
+ bool consumed = mScene.EmitWheelEventGeneratedSignal(wheelEventHandle);
+ if(!consumed)
+ {
+ mScene.EmitWheelEventSignal(wheelEventHandle);
+ }
}
}