From fe6b78b7c6ff8a3c14c058dc6804f8d73a80d9c8 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Tue, 1 Sep 2020 16:19:26 +0900 Subject: [PATCH] Revert "Revert "HoverEvent class pimpling"" This reverts commit 07f5249f8ef980d7bd70ca13d2d7faa279c06aad. --- .../src/dali/utc-Dali-HoverProcessing.cpp | 333 +++++++++++---------- dali/internal/event/actors/actor-impl.cpp | 2 +- dali/internal/event/actors/actor-impl.h | 2 +- dali/internal/event/events/hover-event-impl.cpp | 125 ++++++++ dali/internal/event/events/hover-event-impl.h | 177 +++++++++++ .../event/events/hover-event-processor.cpp | 120 ++++---- dali/internal/file.list | 1 + dali/public-api/events/hover-event.cpp | 55 +++- dali/public-api/events/hover-event.h | 150 ++++++++-- 9 files changed, 714 insertions(+), 251 deletions(-) create mode 100755 dali/internal/event/events/hover-event-impl.cpp create mode 100755 dali/internal/event/events/hover-event-impl.h diff --git a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp index f1f6200..c0dc5b6 100644 --- a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -53,10 +53,7 @@ struct SignalData void Reset() { functorCalled = false; - - hoverEvent.time = 0u; - hoverEvent.points.clear(); - + hoverEvent.Reset(); hoveredActor.Reset(); } @@ -117,11 +114,11 @@ struct RemoveActorFunctor : public HoverEventFunctor } }; -Integration::HoverEvent GenerateSingleHover( TouchPoint::State state, const Vector2& screenPosition ) +Integration::HoverEvent GenerateSingleHover( PointState::Type state, const Vector2& screenPosition ) { Integration::HoverEvent hoverEvent; Integration::Point point; - point.SetState( static_cast< PointState::Type >( state ) ); + point.SetState( state ); point.SetScreenPosition( screenPosition ); hoverEvent.points.push_back( point ); return hoverEvent; @@ -154,46 +151,66 @@ int UtcDaliHoverNormalProcessing(void) actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( localCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - - TouchPoint point = data.hoverEvent.GetPoint(0); - DALI_TEST_EQUALS( TouchPoint::Started, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, point.screen, TEST_LOCATION ); - DALI_TEST_EQUALS( localCoordinates, point.local, 0.1f, TEST_LOCATION ); - + DALI_TEST_EQUALS( PointState::STARTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( localCoordinates, data.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( 0, data.hoverEvent.GetDeviceId( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( 0u, data.hoverEvent.GetTime(), TEST_LOCATION ); + DALI_TEST_EQUALS( actor, data.hoverEvent.GetHitActor( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( -1, data.hoverEvent.GetDeviceId( 1 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::FINISHED, data.hoverEvent.GetState( 1 ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2::ZERO, data.hoverEvent.GetScreenPosition( 1 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2::ZERO, data.hoverEvent.GetLocalPosition( 1 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::Actor(), data.hoverEvent.GetHitActor( 1 ), TEST_LOCATION ); data.Reset(); // Emit a motion signal screenCoordinates.x = screenCoordinates.y = 11.0f; actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( localCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::MOTION, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( localCoordinates, data.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( 0, data.hoverEvent.GetDeviceId( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( 0u, data.hoverEvent.GetTime(), TEST_LOCATION ); + DALI_TEST_EQUALS( actor, data.hoverEvent.GetHitActor( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( -1, data.hoverEvent.GetDeviceId( 1 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::FINISHED, data.hoverEvent.GetState( 1 ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2::ZERO, data.hoverEvent.GetScreenPosition( 1 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2::ZERO, data.hoverEvent.GetLocalPosition( 1 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::Actor(), data.hoverEvent.GetHitActor( 1 ), TEST_LOCATION ); data.Reset(); // Emit a finished signal screenCoordinates.x = screenCoordinates.y = 12.0f; actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Finished, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::FINISHED, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Finished, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( localCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::FINISHED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( localCoordinates, data.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( 0, data.hoverEvent.GetDeviceId( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( 0u, data.hoverEvent.GetTime(), TEST_LOCATION ); + DALI_TEST_EQUALS( actor, data.hoverEvent.GetHitActor( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( -1, data.hoverEvent.GetDeviceId( 1 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::FINISHED, data.hoverEvent.GetState( 1 ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2::ZERO, data.hoverEvent.GetScreenPosition( 1 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2::ZERO, data.hoverEvent.GetLocalPosition( 1 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::Actor(), data.hoverEvent.GetHitActor( 1 ), TEST_LOCATION ); data.Reset(); // Emit a started signal where the actor is not present screenCoordinates.x = screenCoordinates.y = 200.0f; - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, screenCoordinates ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( !data.hoverEvent ); + END_TEST; } @@ -233,7 +250,7 @@ int UtcDaliHoverOutsideCameraNearFarPlanes(void) Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -244,7 +261,7 @@ int UtcDaliHoverOutsideCameraNearFarPlanes(void) application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -255,7 +272,7 @@ int UtcDaliHoverOutsideCameraNearFarPlanes(void) application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, screenCoordinates ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -266,7 +283,7 @@ int UtcDaliHoverOutsideCameraNearFarPlanes(void) application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -277,7 +294,7 @@ int UtcDaliHoverOutsideCameraNearFarPlanes(void) application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, screenCoordinates ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -320,19 +337,19 @@ int UtcDaliHoverInterrupted(void) actor.HoveredSignal().Connect( &application, functor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::STARTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); data.Reset(); // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, data.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::INTERRUPTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); data.Reset(); // Emit another interrupted signal, our signal handler should not be called. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); END_TEST; } @@ -367,19 +384,19 @@ int UtcDaliHoverParentConsumer(void) rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); DALI_TEST_EQUALS( 1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( actorCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::STARTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::STARTED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( actorCoordinates, data.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.hoverEvent.GetHitActor( 0 ) ); + DALI_TEST_CHECK( actor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); @@ -387,19 +404,19 @@ int UtcDaliHoverParentConsumer(void) screenCoordinates.x = screenCoordinates.y = 11.0f; actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y ); rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); DALI_TEST_EQUALS( 1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( actorCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::MOTION, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::MOTION, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( actorCoordinates, data.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.hoverEvent.GetHitActor( 0 ) ); + DALI_TEST_CHECK( actor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); @@ -407,33 +424,33 @@ int UtcDaliHoverParentConsumer(void) screenCoordinates.x = screenCoordinates.y = 12.0f; actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y ); rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Finished, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::FINISHED, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); DALI_TEST_EQUALS( 1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Finished, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Finished, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( actorCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::FINISHED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::FINISHED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( actorCoordinates, data.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.hoverEvent.GetHitActor( 0 ) ); + DALI_TEST_CHECK( actor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); // Emit a started signal where the actor is not present, will hit the root actor though screenCoordinates.x = screenCoordinates.y = 200.0f; rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, screenCoordinates ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_CHECK( rootActor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::STARTED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.GetScreenPosition( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.GetLocalPosition( 0 ), 0.1f, TEST_LOCATION ); + DALI_TEST_CHECK( rootActor == rootData.hoverEvent.GetHitActor( 0 ) ); END_TEST; } @@ -462,33 +479,33 @@ int UtcDaliHoverInterruptedParentConsumer(void) rootActor.HoveredSignal().Connect( &application, rootFunctor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::STARTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::STARTED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.hoverEvent.GetHitActor( 0 ) ); + DALI_TEST_CHECK( actor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); // Emit an interrupted signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::INTERRUPTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.hoverEvent.GetHitActor( 0 ) ); + DALI_TEST_CHECK( actor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); // Emit another started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::STARTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::STARTED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); data.Reset(); rootData.Reset(); @@ -500,16 +517,16 @@ int UtcDaliHoverInterruptedParentConsumer(void) application.Render(); // Emit an interrupted signal, only root actor's signal should be called. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( rootActor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_CHECK( rootActor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); // Emit another interrupted state, none of the signal's should be called. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION ); END_TEST; @@ -537,33 +554,33 @@ int UtcDaliHoverLeave(void) actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::STARTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); data.Reset(); // Emit a motion signal outside of actor, should be signalled with a Leave - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, data.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::LEAVE, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); data.Reset(); // Another motion outside of actor, no signalling - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); // Another motion event inside actor, signalled with motion - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, data.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::MOTION, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); data.Reset(); // We do not want to listen to leave events anymore actor.SetProperty( Actor::Property::LEAVE_REQUIRED, false ); // Another motion event outside of actor, no signalling - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -598,44 +615,44 @@ int UtcDaliHoverLeaveParentConsumer(void) rootActor.SetProperty( Actor::Property::LEAVE_REQUIRED, true ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::STARTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::STARTED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.hoverEvent.GetHitActor( 0 ) ); + DALI_TEST_CHECK( actor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); // Emit a motion signal outside of actor, should be signalled with a Leave - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::LEAVE, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::LEAVE, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.hoverEvent.GetHitActor( 0 ) ); + DALI_TEST_CHECK( actor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); // Another motion outside of actor, only rootActor signalled - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( rootActor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::MOTION, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_CHECK( rootActor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); // Another motion event inside actor, signalled with motion - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::MOTION, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::MOTION, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.hoverEvent.GetHitActor( 0 ) ); + DALI_TEST_CHECK( actor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); @@ -644,10 +661,10 @@ int UtcDaliHoverLeaveParentConsumer(void) // Another motion event outside of root actor, only root signalled Vector2 stageSize( application.GetScene().GetSize() ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, rootData.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::LEAVE, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); END_TEST; } @@ -670,18 +687,18 @@ int UtcDaliHoverActorBecomesInsensitive(void) actor.HoveredSignal().Connect( &application, functor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::STARTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); data.Reset(); // Change actor to insensitive actor.SetProperty( Actor::Property::SENSITIVE, false ); // Emit a motion signal, signalled with an interrupted - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, data.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::INTERRUPTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); data.Reset(); END_TEST; } @@ -711,13 +728,13 @@ int UtcDaliHoverActorBecomesInsensitiveParentConsumer(void) rootActor.HoveredSignal().Connect( &application, rootFunctor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + DALI_TEST_EQUALS( PointState::STARTED, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::STARTED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.hoverEvent.GetHitActor( 0 ) ); + DALI_TEST_CHECK( actor == rootData.hoverEvent.GetHitActor( 0 ) ); data.Reset(); rootData.Reset(); @@ -732,10 +749,10 @@ int UtcDaliHoverActorBecomesInsensitiveParentConsumer(void) rootActor.SetProperty( Actor::Property::SENSITIVE, false ); // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor) - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.hoverEvent.GetState( 0 ), TEST_LOCATION ); END_TEST; } @@ -768,27 +785,27 @@ int UtcDaliHoverMultipleLayers(void) actor1.HoveredSignal().Connect( &application, functor ); // Hit in hittable area, actor1 should be hit - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.hoveredActor == actor1 ); data.Reset(); // Make layer1 insensitive, nothing should be hit layer1.SetProperty( Actor::Property::SENSITIVE, false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); // Make layer1 sensitive again, again actor1 will be hit layer1.SetProperty( Actor::Property::SENSITIVE, true ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.hoveredActor == actor1 ); data.Reset(); // Make rootActor insensitive, nothing should be hit rootActor.SetProperty( Actor::Property::SENSITIVE, false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -816,21 +833,21 @@ int UtcDaliHoverMultipleLayers(void) actor2.HoveredSignal().Connect( &application, functor ); // Emit an event, should hit layer2 - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); //DALI_TEST_CHECK( data.hoveredActor == layer2 ); // TODO: Uncomment this after removing renderable hack! data.Reset(); // Make layer2 insensitive, should hit actor1 layer2.SetProperty( Actor::Property::SENSITIVE, false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.hoveredActor == actor1 ); data.Reset(); // Make layer2 sensitive again, should hit layer2 layer2.SetProperty( Actor::Property::SENSITIVE, true ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); //DALI_TEST_CHECK( data.hoveredActor == layer2 ); // TODO: Uncomment this after removing renderable hack! data.Reset(); @@ -841,7 +858,7 @@ int UtcDaliHoverMultipleLayers(void) application.Render(); // Should hit actor1 - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.hoveredActor == actor1 ); data.Reset(); @@ -852,7 +869,7 @@ int UtcDaliHoverMultipleLayers(void) application.Render(); // Should not hit anything - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -885,18 +902,18 @@ int UtcDaliHoverMultipleRenderTasks(void) actor.HoveredSignal().Connect( &application, functor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Ensure renderTask actor can be hit too. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Disable input on renderTask, should not be hittable renderTask.SetInputEnabled( false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -936,18 +953,18 @@ int UtcDaliHoverMultipleRenderTasksWithChildLayer(void) layer.HoveredSignal().Connect( &application, functor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Ensure renderTask actor can be hit too. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Disable input on renderTask, should not be hittable renderTask.SetInputEnabled( false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -997,7 +1014,7 @@ int UtcDaliHoverOffscreenRenderTasks(void) actor.HoveredSignal().Connect( &application, functor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -1030,7 +1047,7 @@ int UtcDaliHoverMultipleRenderableActors(void) actor.HoveredSignal().Connect( &application, functor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( actor == data.hoveredActor ); END_TEST; @@ -1058,7 +1075,7 @@ int UtcDaliHoverActorRemovedInSignal(void) actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1068,12 +1085,12 @@ int UtcDaliHoverActorRemovedInSignal(void) application.Render(); // Emit another signal outside of actor's area, should not get anything as the scene has changed. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1082,7 +1099,7 @@ int UtcDaliHoverActorRemovedInSignal(void) application.Render(); // Emit another signal outside of actor's area, should not get anything as the scene has changed. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1092,7 +1109,7 @@ int UtcDaliHoverActorRemovedInSignal(void) application.Render(); // Emit another started event - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1100,7 +1117,7 @@ int UtcDaliHoverActorRemovedInSignal(void) actor.Reset(); // Emit event, should not crash and should not receive an event. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); END_TEST; } @@ -1124,7 +1141,7 @@ int UtcDaliHoverActorSignalNotConsumed(void) actor.HoveredSignal().Connect( &application, functor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); END_TEST; } @@ -1148,7 +1165,7 @@ int UtcDaliHoverActorUnStaged(void) actor.HoveredSignal().Connect( &application, functor ); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1160,7 +1177,7 @@ int UtcDaliHoverActorUnStaged(void) application.Render(); // Emit a move at the same point, we should not be signalled. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -1189,8 +1206,8 @@ int UtcDaliHoverLeaveActorReadded(void) actor.HoveredSignal().Connect( &application, functor ); // Emit a started and motion - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 11.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2( 11.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1199,14 +1216,14 @@ int UtcDaliHoverLeaveActorReadded(void) stage.Add( actor ); // Emit a motion within the actor's bounds - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 12.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2( 12.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Emit a motion outside the actor's bounds - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 200.0f, 200.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::MOTION, Vector2( 200.0f, 200.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, data.hoverEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::LEAVE, data.hoverEvent.GetState( 0 ), TEST_LOCATION ); data.Reset(); END_TEST; @@ -1245,19 +1262,19 @@ int UtcDaliHoverClippingActor(void) actor.HoveredSignal().Connect( &application, functor ); // Emit an event within clipped area - no hit. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); // Emit an event outside the clipped area but within the actor area, we should have a hit. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 60.0f, 60.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 60.0f, 60.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); clippingChild.HoveredSignal().Connect( &application, functor ); // Emit an event inside part of the child which is within the clipped area, we should have a hit. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 30.0f, 30.0f ) ) ); + application.ProcessEvent( GenerateSingleHover( PointState::STARTED, Vector2( 30.0f, 30.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index ed2d690..ca215aa 100755 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -1835,7 +1835,7 @@ bool Actor::EmitTouchEventSignal( const Dali::TouchEvent& touch ) return consumed; } -bool Actor::EmitHoverEventSignal( const HoverEvent& event ) +bool Actor::EmitHoverEventSignal( const Dali::HoverEvent& event ) { bool consumed = false; diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index feb5444..9fd62b3 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -1416,7 +1416,7 @@ public: * @param[in] event The hover event. * @return True if the event was consumed. */ - bool EmitHoverEventSignal( const HoverEvent& event ); + bool EmitHoverEventSignal( const Dali::HoverEvent& event ); /** * Used by the EventProcessor to emit wheel event signals. diff --git a/dali/internal/event/events/hover-event-impl.cpp b/dali/internal/event/events/hover-event-impl.cpp new file mode 100755 index 0000000..5f6f191 --- /dev/null +++ b/dali/internal/event/events/hover-event-impl.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2020 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +namespace Dali +{ + +namespace Internal +{ + +HoverEvent::HoverEvent() +: mPoints(), + mTime( 0 ) +{ +} + +HoverEvent::HoverEvent( unsigned long time ) +: mPoints(), + mTime( time ) +{ +} + +HoverEventPtr HoverEvent::Clone( const HoverEvent& rhs ) +{ + HoverEventPtr hoverEvent( new HoverEvent ); + hoverEvent->mPoints = rhs.mPoints; + hoverEvent->mTime = rhs.mTime; + return hoverEvent; +} + +HoverEvent::~HoverEvent() +{ +} + +unsigned long HoverEvent::GetTime() const +{ + return mTime; +} + +std::size_t HoverEvent::GetPointCount() const +{ + return mPoints.size(); +} + +int32_t HoverEvent::GetDeviceId( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetDeviceId(); + } + return -1; +} + +PointState::Type HoverEvent::GetState( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetState(); + } + return PointState::FINISHED; +} + +Dali::Actor HoverEvent::GetHitActor( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetHitActor(); + } + return Dali::Actor(); +} + +const Vector2& HoverEvent::GetLocalPosition( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetLocalPosition(); + } + return Vector2::ZERO; +} + +const Vector2& HoverEvent::GetScreenPosition( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetScreenPosition(); + } + return Vector2::ZERO; +} + +const Integration::Point& HoverEvent::GetPoint( std::size_t point ) const +{ + DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" ); + return mPoints[ point ]; +} + +Integration::Point& HoverEvent::GetPoint( std::size_t point ) +{ + DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" ); + return mPoints[ point ]; +} + +void HoverEvent::AddPoint( const Integration::Point& point ) +{ + mPoints.push_back( point ); +} + +} // namsespace Internal + +} // namespace Dali diff --git a/dali/internal/event/events/hover-event-impl.h b/dali/internal/event/events/hover-event-impl.h new file mode 100755 index 0000000..36c9725 --- /dev/null +++ b/dali/internal/event/events/hover-event-impl.h @@ -0,0 +1,177 @@ +#ifndef DALI_INTERNAL_HOVER_EVENT_H +#define DALI_INTERNAL_HOVER_EVENT_H + +/* + * Copyright (c) 2020 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +class HoverEvent; +typedef IntrusivePtr< HoverEvent > HoverEventPtr; + +/** + * @copydoc Dali::HoverEvent + */ +class HoverEvent : public BaseObject +{ +public: + + // Construction & Destruction + + /** + * @brief Default constructor + */ + HoverEvent(); + + /** + * @brief Constructor + * @param[in] time The time the event occurred + */ + HoverEvent( unsigned long time ); + + /** + * @brief Clones the HoverEvent object. + * + * Required because base class copy constructor is not implemented. + * @param[in] rhs The HoverEvent to clone from. + * @return A new HoverEvent object which is has the same hover event data. + */ + static HoverEventPtr Clone( const HoverEvent& rhs ); + + /** + * @brief Destructor + */ + ~HoverEvent(); + + // Getters + + /** + * @copydoc Dali::HoverEvent::GetTime() + */ + unsigned long GetTime() const; + + /** + * @copydoc Dali::HoverEvent::GetPointCount() + */ + std::size_t GetPointCount() const; + + /** + * @copydoc Dali::HoverEvent::GetDeviceId() + */ + int32_t GetDeviceId( std::size_t point ) const; + + /** + * @copydoc Dali::HoverEvent::GetGetState() + */ + PointState::Type GetState( std::size_t point ) const; + + /** + * @copydoc Dali::HoverEvent::GetHitActor() + */ + Dali::Actor GetHitActor( std::size_t point ) const; + + /** + * @copydoc Dali::HoverEvent::GetLocalPosition() + */ + const Vector2& GetLocalPosition( std::size_t point ) const; + + /** + * @copydoc Dali::HoverEvent::GetScreenPosition() + */ + const Vector2& GetScreenPosition( std::size_t point ) const; + + /** + * @brief Returns a const reference to a point at the index requested. + * + * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event). + * + * @param[in] point The index of the required Point. + * @return A const reference to the Point at the position requested + * @note point should be less than the value returned by GetPointCount(). Will assert if out of range. + */ + const Integration::Point& GetPoint( std::size_t point ) const; + + /** + * @brief Returns a reference to a point at the index requested. + * + * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event). + * + * @param[in] point The index of the required Point. + * @return A reference to the Point at the position requested + * @note point should be less than the value returned by GetPointCount(). Will assert if out of range. + */ + Integration::Point& GetPoint( std::size_t point ); + + // Setters + + /** + * @brief Adds a point to this hover event. + * @param[in] point The point to add to the hover event. + */ + void AddPoint( const Integration::Point& point ); + +private: + + // Not copyable or movable + + HoverEvent( const HoverEvent& rhs ) = delete; ///< Deleted copy constructor + HoverEvent( HoverEvent&& rhs ) = delete; ///< Deleted move constructor + HoverEvent& operator=( const HoverEvent& rhs ) = delete; ///< Deleted copy assignment operator + HoverEvent& operator=( HoverEvent&& rhs ) = delete; ///< Deleted move assignment operator + +private: + + std::vector< Integration::Point > mPoints; ///< Container of the points for this hover event + unsigned long mTime; ///< The time (in ms) that the hover event occurred +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods + +inline Internal::HoverEvent& GetImplementation( Dali::HoverEvent& hoverEvent ) +{ + DALI_ASSERT_ALWAYS( hoverEvent && "Hover Event handle is empty" ); + + BaseObject& object = hoverEvent.GetBaseObject(); + + return static_cast< Internal::HoverEvent& >( object ); +} + +inline const Internal::HoverEvent& GetImplementation( const Dali::HoverEvent& hoverEvent ) +{ + DALI_ASSERT_ALWAYS( hoverEvent && "Hover Event handle is empty" ); + + const BaseObject& object = hoverEvent.GetBaseObject(); + + return static_cast< const Internal::HoverEvent& >( object ); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_HOVER_EVENT_H diff --git a/dali/internal/event/events/hover-event-processor.cpp b/dali/internal/event/events/hover-event-processor.cpp index e32d587..84b6ffb 100644 --- a/dali/internal/event/events/hover-event-processor.cpp +++ b/dali/internal/event/events/hover-event-processor.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace Dali @@ -60,7 +61,7 @@ const char * TOUCH_POINT_STATE[TouchPoint::Last] = /** * Recursively deliver events to the actor and its parents, until the event is consumed or the stage is reached. */ -Dali::Actor EmitHoverSignals( Dali::Actor actor, const HoverEvent& event ) +Dali::Actor EmitHoverSignals( Dali::Actor actor, const Dali::HoverEvent& event ) { Dali::Actor consumedActor; @@ -100,25 +101,38 @@ Dali::Actor EmitHoverSignals( Dali::Actor actor, const HoverEvent& event ) return consumedActor; } +Dali::Actor AllocAndEmitHoverSignals( unsigned long time, Dali::Actor actor, const Integration::Point& point ) +{ + HoverEventPtr hoverEvent( new HoverEvent( time ) ); + Dali::HoverEvent hoverEventHandle( hoverEvent.Get() ); + + hoverEvent->AddPoint( point ); + + return EmitHoverSignals( actor, hoverEventHandle ); +} + /** * Changes the state of the primary point to leave and emits the hover signals */ -Dali::Actor EmitHoverSignals( Actor* actor, RenderTask& renderTask, const HoverEvent& originalEvent, TouchPoint::State state ) +Dali::Actor EmitHoverSignals( Actor* actor, RenderTask& renderTask, const HoverEventPtr& originalEvent, PointState::Type state ) { - HoverEvent hoverEvent( originalEvent ); + HoverEventPtr hoverEvent = HoverEvent::Clone( *originalEvent.Get() ); DALI_ASSERT_DEBUG( NULL != actor && "NULL actor pointer" ); if( actor ) { - TouchPoint& primaryPoint = hoverEvent.points[0]; + Integration::Point& primaryPoint = hoverEvent->GetPoint( 0 ); - actor->ScreenToLocal( renderTask, primaryPoint.local.x, primaryPoint.local.y, primaryPoint.screen.x, primaryPoint.screen.y ); + const Vector2& screenPosition = primaryPoint.GetScreenPosition(); + Vector2 localPosition; + actor->ScreenToLocal( renderTask, localPosition.x, localPosition.y, screenPosition.x, screenPosition.y ); - primaryPoint.hitActor = Dali::Actor(actor); - primaryPoint.state = state; + primaryPoint.SetLocalPosition( localPosition ); + primaryPoint.SetHitActor( Dali::Actor( actor ) ); + primaryPoint.SetState( state ); } - return EmitHoverSignals( Dali::Actor(actor), hoverEvent ); + return EmitHoverSignals( Dali::Actor(actor), Dali::HoverEvent( hoverEvent.Get() ) ); } /** @@ -167,7 +181,7 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even PRINT_HIERARCHY(gLogFilter); // Copy so we can add the results of a hit-test. - HoverEvent hoverEvent( event.time ); + HoverEventPtr hoverEvent( new HoverEvent( event.time ) ); // 1) Check if it is an interrupted event - we should inform our last primary hit actor about this // and emit the stage signal as well. @@ -175,14 +189,14 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even if ( state == TouchPoint::Interrupted ) { Dali::Actor consumingActor; - hoverEvent.points.push_back( event.points[0].GetTouchPoint() ); + Integration::Point currentPoint( event.points[0] ); Actor* lastPrimaryHitActor( mLastPrimaryHitActor.GetActor() ); if ( lastPrimaryHitActor ) { Dali::Actor lastPrimaryHitActorHandle( lastPrimaryHitActor ); - hoverEvent.points[0].hitActor = lastPrimaryHitActorHandle; - consumingActor = EmitHoverSignals( lastPrimaryHitActorHandle, hoverEvent ); + currentPoint.SetHitActor( lastPrimaryHitActorHandle ); + consumingActor = AllocAndEmitHoverSignals( event.time, lastPrimaryHitActorHandle, currentPoint ); } // If the last consumed actor was different to the primary hit actor then inform it as well (if it has not already been informed). @@ -192,8 +206,8 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even lastConsumedActor != consumingActor ) { Dali::Actor lastConsumedActorHandle( lastConsumedActor ); - hoverEvent.points[0].hitActor = lastConsumedActorHandle; - EmitHoverSignals( lastConsumedActorHandle, hoverEvent ); + currentPoint.SetHitActor( lastConsumedActorHandle ); + AllocAndEmitHoverSignals( event.time, lastConsumedActorHandle, currentPoint ); } // Tell the hover-start consuming actor as well, if required @@ -204,8 +218,8 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even hoverStartConsumedActor != consumingActor ) { Dali::Actor hoverStartConsumedActorHandle( hoverStartConsumedActor ); - hoverEvent.points[0].hitActor = hoverStartConsumedActorHandle; - EmitHoverSignals( hoverStartConsumedActorHandle, hoverEvent ); + currentPoint.SetHitActor( hoverStartConsumedActorHandle ); + AllocAndEmitHoverSignals( event.time, hoverStartConsumedActorHandle, currentPoint ); } mLastPrimaryHitActor.SetActor( NULL ); @@ -213,39 +227,41 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even mHoverStartConsumedActor.SetActor( NULL ); mLastRenderTask.Reset(); - hoverEvent.points[0].hitActor.Reset(); - return; // No need for hit testing } // 2) Hit Testing. + Dali::HoverEvent hoverEventHandle( hoverEvent.Get() ); + DALI_LOG_INFO( gLogFilter, Debug::Concise, "\n" ); DALI_LOG_INFO( gLogFilter, Debug::General, "Point(s): %d\n", event.GetPointCount() ); RenderTaskPtr currentRenderTask; + bool firstPointParsed = false; - for ( Integration::PointContainerConstIterator iter = event.points.begin(), beginIter = event.points.begin(), endIter = event.points.end(); iter != endIter; ++iter ) + for ( auto&& currentPoint : event.points ) { HitTestAlgorithm::Results hitTestResults; ActorHoverableCheck actorHoverableCheck; - HitTestAlgorithm::HitTest( mScene.GetSize(), mScene.GetRenderTaskList(), mScene.GetLayerList(), iter->GetScreenPosition(), hitTestResults, actorHoverableCheck ); + HitTestAlgorithm::HitTest( mScene.GetSize(), mScene.GetRenderTaskList(), mScene.GetLayerList(), currentPoint.GetScreenPosition(), hitTestResults, actorHoverableCheck ); - TouchPoint newPoint( iter->GetTouchPoint() ); - newPoint.hitActor = hitTestResults.actor; - newPoint.local = hitTestResults.actorCoordinates; + Integration::Point newPoint( currentPoint ); + newPoint.SetHitActor( hitTestResults.actor ); + newPoint.SetLocalPosition( hitTestResults.actorCoordinates ); - hoverEvent.points.push_back( newPoint ); + hoverEvent->AddPoint( newPoint ); 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, + TOUCH_POINT_STATE[currentPoint.GetState()], currentPoint.GetScreenPosition().x, currentPoint.GetScreenPosition().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 ); // Only set the currentRenderTask for the primary hit actor. - if ( iter == beginIter && hitTestResults.renderTask ) + if( !firstPointParsed ) { + firstPointParsed = true; currentRenderTask = hitTestResults.renderTask; } } @@ -256,18 +272,18 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even Dali::Actor consumedActor; if ( currentRenderTask ) { - consumedActor = EmitHoverSignals( hoverEvent.points[0].hitActor, hoverEvent ); + consumedActor = EmitHoverSignals( hoverEvent->GetHitActor( 0 ), hoverEventHandle ); } - TouchPoint& primaryPoint = hoverEvent.points[0]; - Dali::Actor primaryHitActor = primaryPoint.hitActor; - TouchPoint::State primaryPointState = primaryPoint.state; + Integration::Point primaryPoint = hoverEvent->GetPoint( 0 ); + Dali::Actor primaryHitActor = primaryPoint.GetHitActor(); + PointState::Type primaryPointState = primaryPoint.GetState(); - DALI_LOG_INFO( gLogFilter, Debug::Concise, "PrimaryHitActor: (%p) %s\n", primaryPoint.hitActor ? reinterpret_cast< void* >( &primaryPoint.hitActor.GetBaseObject() ) : NULL, primaryPoint.hitActor ? primaryPoint.hitActor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" ); + DALI_LOG_INFO( gLogFilter, Debug::Concise, "PrimaryHitActor: (%p) %s\n", primaryHitActor ? reinterpret_cast< void* >( &primaryHitActor.GetBaseObject() ) : NULL, primaryHitActor ? primaryHitActor.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() : "" ); - if ( ( primaryPointState == TouchPoint::Started ) && - ( hoverEvent.GetPointCount() == 1 ) && + if ( ( primaryPointState == PointState::STARTED ) && + ( hoverEvent->GetPointCount() == 1 ) && ( consumedActor && GetImplementation( consumedActor ).OnScene() ) ) { mHoverStartConsumedActor.SetActor( &GetImplementation( consumedActor ) ); @@ -278,7 +294,7 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even Actor* lastPrimaryHitActor( mLastPrimaryHitActor.GetActor() ); Actor* lastConsumedActor( mLastConsumedActor.GetActor() ); - if( (primaryPointState == TouchPoint::Motion) || (primaryPointState == TouchPoint::Finished) || (primaryPointState == TouchPoint::Stationary) ) + if( (primaryPointState == PointState::MOTION) || (primaryPointState == PointState::FINISHED) || (primaryPointState == PointState::STATIONARY) ) { if ( mLastRenderTask ) { @@ -294,7 +310,7 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even if ( lastPrimaryHitActor->GetLeaveRequired() ) { DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Hit): (%p) %s\n", reinterpret_cast< void* >( lastPrimaryHitActor ), lastPrimaryHitActor->GetName().c_str() ); - leaveEventConsumer = EmitHoverSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, hoverEvent, TouchPoint::Leave ); + leaveEventConsumer = EmitHoverSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::LEAVE ); } } else @@ -302,7 +318,7 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& 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", reinterpret_cast< void* >( lastPrimaryHitActor ), lastPrimaryHitActor->GetName().c_str() ); - leaveEventConsumer = EmitHoverSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, hoverEvent, TouchPoint::Interrupted ); + leaveEventConsumer = EmitHoverSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::INTERRUPTED ); } } @@ -320,7 +336,7 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even if( lastConsumedActor->GetLeaveRequired() ) { DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Consume): (%p) %s\n", reinterpret_cast< void* >( lastConsumedActor ), lastConsumedActor->GetName().c_str() ); - EmitHoverSignals( lastConsumedActor, lastRenderTaskImpl, hoverEvent, TouchPoint::Leave ); + EmitHoverSignals( lastConsumedActor, lastRenderTaskImpl, hoverEvent, PointState::LEAVE ); } } else @@ -328,7 +344,7 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& 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", reinterpret_cast< void* >( lastConsumedActor ), lastConsumedActor->GetName().c_str() ); - EmitHoverSignals( mLastConsumedActor.GetActor(), lastRenderTaskImpl, hoverEvent, TouchPoint::Interrupted ); + EmitHoverSignals( mLastConsumedActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::INTERRUPTED ); } } } @@ -337,7 +353,7 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even // 5) If our primary point is an Finished event, then the primary point (in multi-touch) will change next // time so set our last primary actor to NULL. Do the same to the last consumed actor as well. - if ( primaryPointState == TouchPoint::Finished ) + if ( primaryPointState == PointState::FINISHED ) { mLastPrimaryHitActor.SetActor( NULL ); mLastConsumedActor.SetActor( NULL ); @@ -372,11 +388,11 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even // 6) Emit an interrupted event to the hover-started actor if it hasn't consumed the Finished. - if ( hoverEvent.GetPointCount() == 1 ) // Only want the first hover started + if ( hoverEvent->GetPointCount() == 1 ) // Only want the first hover started { switch ( primaryPointState ) { - case TouchPoint::Finished: + case PointState::FINISHED: { Actor* hoverStartConsumedActor( mHoverStartConsumedActor.GetActor() ); if ( hoverStartConsumedActor && @@ -385,25 +401,25 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even hoverStartConsumedActor != lastConsumedActor ) { Dali::Actor hoverStartConsumedActorHandle( hoverStartConsumedActor ); - hoverEvent.points[0].hitActor = hoverStartConsumedActorHandle; - hoverEvent.points[0].state = TouchPoint::Interrupted; - EmitHoverSignals( hoverStartConsumedActorHandle, hoverEvent ); + Integration::Point primaryPoint = hoverEvent->GetPoint( 0 ); + primaryPoint.SetHitActor( hoverStartConsumedActorHandle ); + primaryPoint.SetState( PointState::INTERRUPTED ); + AllocAndEmitHoverSignals( event.time, hoverStartConsumedActorHandle, primaryPoint ); // Restore hover-event to original state - hoverEvent.points[0].hitActor = primaryHitActor; - hoverEvent.points[0].state = primaryPointState; + primaryPoint.SetHitActor( primaryHitActor ); + primaryPoint.SetState( primaryPointState ); } mHoverStartConsumedActor.SetActor( NULL ); } // No break, Fallthrough - case TouchPoint::Started: - case TouchPoint::Motion: - case TouchPoint::Leave: - case TouchPoint::Stationary: - case TouchPoint::Interrupted: - case TouchPoint::Last: + case PointState::STARTED: + case PointState::MOTION: + case PointState::LEAVE: + case PointState::STATIONARY: + case PointState::INTERRUPTED: { // Ignore break; diff --git a/dali/internal/file.list b/dali/internal/file.list index 6312383..b4642ee 100644 --- a/dali/internal/file.list +++ b/dali/internal/file.list @@ -54,6 +54,7 @@ SET( internal_src_files ${internal_src_dir}/event/events/gesture-event-processor.cpp ${internal_src_dir}/event/events/gesture-processor.cpp ${internal_src_dir}/event/events/hit-test-algorithm-impl.cpp + ${internal_src_dir}/event/events/hover-event-impl.cpp ${internal_src_dir}/event/events/hover-event-processor.cpp ${internal_src_dir}/event/events/wheel-event-processor.cpp ${internal_src_dir}/event/events/multi-point-event-util.cpp diff --git a/dali/public-api/events/hover-event.cpp b/dali/public-api/events/hover-event.cpp index 69f02e1..d8a241e 100644 --- a/dali/public-api/events/hover-event.cpp +++ b/dali/public-api/events/hover-event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,34 +19,67 @@ #include // INTERNAL INCLUDES -#include +#include +#include namespace Dali { HoverEvent::HoverEvent() -: time(0) +: BaseHandle() { } -HoverEvent::HoverEvent(unsigned long time) -: time(time) +HoverEvent::HoverEvent( const HoverEvent& rhs ) = default; + +HoverEvent::HoverEvent( HoverEvent&& rhs ) = default; + +HoverEvent::~HoverEvent() { } -HoverEvent::~HoverEvent() +HoverEvent& HoverEvent::operator=( const HoverEvent& rhs ) = default; + +HoverEvent& HoverEvent::operator=( HoverEvent&& rhs ) = default; + +unsigned long HoverEvent::GetTime() const +{ + return GetImplementation( *this ).GetTime(); +} + +std::size_t HoverEvent::GetPointCount() const +{ + return GetImplementation( *this ).GetPointCount(); +} + +int32_t HoverEvent::GetDeviceId( std::size_t point ) const +{ + return GetImplementation( *this ).GetDeviceId( point ); +} + +PointState::Type HoverEvent::GetState( std::size_t point ) const +{ + return GetImplementation( *this ).GetState( point ); +} + +Actor HoverEvent::GetHitActor( std::size_t point ) const +{ + return GetImplementation( *this ).GetHitActor( point ); +} + +const Vector2& HoverEvent::GetLocalPosition( std::size_t point ) const { + return GetImplementation( *this ).GetLocalPosition( point ); } -uint32_t HoverEvent::GetPointCount() const +const Vector2& HoverEvent::GetScreenPosition( std::size_t point ) const { - return static_cast( points.size() ); + return GetImplementation( *this ).GetScreenPosition( point ); } -const TouchPoint& HoverEvent::GetPoint( uint32_t point ) const +HoverEvent::HoverEvent( Internal::HoverEvent* internal ) +: BaseHandle( internal ) { - DALI_ASSERT_ALWAYS( point < points.size() && "No point at index" ); - return points[point]; } } // namespace Dali diff --git a/dali/public-api/events/hover-event.h b/dali/public-api/events/hover-event.h index de77507..9e5a8f1 100644 --- a/dali/public-api/events/hover-event.h +++ b/dali/public-api/events/hover-event.h @@ -2,7 +2,7 @@ #define DALI_HOVER_EVENT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,15 +23,25 @@ // INTERNAL INCLUDES #include -#include +#include +#include namespace Dali { + +namespace Internal DALI_INTERNAL +{ +class HoverEvent; +} + /** * @addtogroup dali_core_events * @{ */ +class Actor; +struct Vector2; + /** * @brief Hover events are a collection of touch points at a specific moment in time. * @@ -39,22 +49,36 @@ namespace Dali * hovered or the points where a hover has stopped. * @SINCE_1_0.0 */ -struct DALI_CORE_API HoverEvent +class DALI_CORE_API HoverEvent : public BaseHandle { + +public: + // Construction & Destruction /** - * @brief Default constructor. + * @brief An uninitialized HoverEvent instance. + * + * Calling member functions with an uninitialized HoverEvent handle is not allowed. * @SINCE_1_0.0 */ HoverEvent(); /** - * @brief Constructor. - * @SINCE_1_0.0 - * @param[in] time The time the event occurred + * @brief Copy constructor. + * + * @SINCE_1_9.25 + * @param[in] rhs The HoverEvent to copy from + */ + HoverEvent( const HoverEvent& rhs ); + + /** + * @brief Move constructor. + * + * @SINCE_1_9.25 + * @param[in] rhs A reference to the moved HoverEvent */ - HoverEvent(unsigned long time); + HoverEvent( HoverEvent&& rhs ); /** * @brief Destructor. @@ -62,43 +86,113 @@ struct DALI_CORE_API HoverEvent */ ~HoverEvent(); - // Data + // Operators /** - * @brief This is a container of points for this hover event. + * @brief Copy assignment operator. * - * The first point in the set is always the - * primary touch point (i.e. the first point touched in a multi-touch event). + * @SINCE_1_1.37 + * @param[in] rhs The HoverEvent to copy from + * @return A reference to this */ - TouchPointContainer points; + HoverEvent& operator=( const HoverEvent& rhs ); /** - * @brief The time (in ms) that the hover event occurred. + * @brief Move assignment operator. + * + * @SINCE_1_9.25 + * @param[in] rhs A reference to the moved HoverEvent + * @return A reference to this */ - unsigned long time; + HoverEvent& operator=( HoverEvent&& rhs ); - // Convenience Methods + // Getters /** - * @brief Returns the total number of points in this HoverEvent. + * @brief Returns the time (in ms) that the hover event occurred. * - * @SINCE_1_0.0 + * @SINCE_1_9.25 + * @return The time (in ms) that the hover event occurred + */ + unsigned long GetTime() const; + + /** + * @brief Returns the total number of points in this hover event. + * + * @SINCE_1_9.25 * @return Total number of Points */ - uint32_t GetPointCount() const; + std::size_t GetPointCount() const; /** - * @brief Returns a touch point at the index requested. + * @brief Returns the ID of the device used for the Point specified. * - * The first point in the set is always the primary - * touch point (i.e. the first point touched in a multi-touch event). - * @SINCE_1_0.0 - * @param[in] point The index of the required Point - * @return Point requested - * @note "point" should be less than the value returned by GetPointCount(). - * If out of range, then program asserts. + * Each point has a unique device ID which specifies the device used for that + * point. This is returned by this method. + * + * @SINCE_1_9.25 + * @param[in] point The point required + * @return The Device ID of this point + * @note If point is greater than GetPointCount() then this method will return -1. + */ + int32_t GetDeviceId( std::size_t point ) const; + + /** + * @brief Retrieves the State of the point specified. + * + * @SINCE_1_9.25 + * @param[in] point The point required + * @return The state of the point specified + * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED. + * @see State + */ + PointState::Type GetState( std::size_t point ) const; + + /** + * @brief Retrieves the actor that was underneath the point specified. + * + * @SINCE_1_9.25 + * @param[in] point The point required + * @return The actor that was underneath the point specified + * @note If point is greater than GetPointCount() then this method will return an empty handle. + */ + Actor GetHitActor( std::size_t point ) const; + + /** + * @brief Retrieves the co-ordinates relative to the top-left of the hit-actor at the point specified. + * + * @SINCE_1_9.25 + * @param[in] point The point required + * @return The co-ordinates relative to the top-left of the hit-actor of the point specified + * + * @note The top-left of an actor is (0.0, 0.0, 0.5). + * @note If you require the local coordinates of another actor (e.g the parent of the hit actor), + * then you should use Actor::ScreenToLocal(). + * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO. + */ + const Vector2& GetLocalPosition( std::size_t point ) const; + + /** + * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified. + * + * @SINCE_1_9.25 + * @param[in] point The point required + * @return The co-ordinates relative to the top-left of the screen of the point specified + * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO. + */ + const Vector2& GetScreenPosition( std::size_t point ) const; + +public: // Not intended for application developers + + /// @cond internal + /** + * @brief This constructor is used internally to Create an initialized HoverEvent handle. + * + * @SINCE_1_9.25 + * @param[in] hoverEvent A pointer to a newly allocated Dali resource */ - const TouchPoint& GetPoint( uint32_t point) const; + explicit DALI_INTERNAL HoverEvent( Internal::HoverEvent* hoverEvent ); + /// @endcond }; /** -- 2.7.4