From 7b4ff0da8b4fa2647c0abc34c03da61154de2038 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Mon, 13 Jun 2016 16:32:11 +0100 Subject: [PATCH] (Touch) Added pressure, radius & angle information Refactored Integration and internal touch processing to use new Point rather than TouchPoint so we can store the new parameters. Change-Id: If35d6c4a156c19391c736b750c7673631a7a4ef0 --- .../dali/dali-test-suite-utils/test-touch-utils.h | 7 +- automated-tests/src/dali/utc-Dali-Actor.cpp | 18 +- automated-tests/src/dali/utc-Dali-BaseHandle.cpp | 4 +- automated-tests/src/dali/utc-Dali-CustomActor.cpp | 8 +- .../src/dali/utc-Dali-HoverProcessing.cpp | 7 +- .../src/dali/utc-Dali-LongPressGestureDetector.cpp | 9 +- .../src/dali/utc-Dali-PanGestureDetector.cpp | 9 +- .../src/dali/utc-Dali-PinchGestureDetector.cpp | 15 +- automated-tests/src/dali/utc-Dali-Stage.cpp | 70 ++--- .../src/dali/utc-Dali-TapGestureDetector.cpp | 9 +- .../src/dali/utc-Dali-TouchDataProcessing.cpp | 348 ++++++++++++++++----- .../src/dali/utc-Dali-TouchEventCombiner.cpp | 292 ++++++++--------- .../src/dali/utc-Dali-TouchProcessing.cpp | 7 +- .../events/multi-point-event-integ.cpp | 6 +- .../events/multi-point-event-integ.h | 30 +- dali/integration-api/events/point.cpp | 147 +++++++++ dali/integration-api/events/point.h | 203 ++++++++++++ .../events/touch-event-combiner.cpp | 58 ++-- dali/integration-api/events/touch-event-combiner.h | 12 +- dali/integration-api/file.list | 2 + dali/internal/event/actors/actor-impl.cpp | 2 +- .../event/events/hover-event-processor.cpp | 13 +- dali/internal/event/events/touch-data-impl.cpp | 77 ++++- dali/internal/event/events/touch-data-impl.h | 73 +++-- .../event/events/touch-event-processor.cpp | 136 ++++---- dali/public-api/events/touch-data.cpp | 32 +- dali/public-api/events/touch-data.h | 72 ++++- dali/public-api/events/touch-event.h | 2 +- 28 files changed, 1213 insertions(+), 455 deletions(-) create mode 100644 dali/integration-api/events/point.cpp create mode 100644 dali/integration-api/events/point.h diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-touch-utils.h b/automated-tests/src/dali/dali-test-suite-utils/test-touch-utils.h index ebae313..28caca9 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-touch-utils.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-touch-utils.h @@ -62,10 +62,13 @@ struct TouchEventDataFunctor } // Generate a touch-event - Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, Vector2 screenPosition ) const + Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition ) const { Integration::TouchEvent touchEvent; - touchEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) ); + Integration::Point point; + point.SetState( state ); + point.SetScreenPosition( screenPosition ); + touchEvent.points.push_back( point ); return touchEvent; } diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 6dcde41..a913208 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -58,7 +58,9 @@ int SimulateTouchForSetOverlayHitTest(TestApplication& app) gTouchCallBackCalled = false; // simulate a touch event - Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f ); + Dali::Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 25.0f, 25.0f ) ); Dali::Integration::TouchEvent event; event.AddPoint( point ); app.ProcessEvent( event ); @@ -1968,7 +1970,10 @@ int UtcDaliActorTouchedSignal(void) // simulate a touch event in the middle of the screen Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 ); - Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y ); + Dali::Integration::Point point; + point.SetDeviceId( 1 ); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) ); Dali::Integration::TouchEvent event; event.AddPoint( point ); application.ProcessEvent( event ); @@ -1995,7 +2000,10 @@ int UtcDaliActorHoveredSignal(void) // simulate a hover event in the middle of the screen Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 ); - Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y ); + Dali::Integration::Point point; + point.SetDeviceId( 1 ); + point.SetState( PointState::MOTION ); + point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) ); Dali::Integration::HoverEvent event; event.AddPoint( point ); application.ProcessEvent( event ); @@ -2201,7 +2209,9 @@ int UtcDaliActorHitTest(void) // connect to its touch signal actor.TouchedSignal().Connect(TestCallback); - Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ); + Dali::Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) ); Dali::Integration::TouchEvent event; event.AddPoint( point ); diff --git a/automated-tests/src/dali/utc-Dali-BaseHandle.cpp b/automated-tests/src/dali/utc-Dali-BaseHandle.cpp index 9e3da41..bb64130 100644 --- a/automated-tests/src/dali/utc-Dali-BaseHandle.cpp +++ b/automated-tests/src/dali/utc-Dali-BaseHandle.cpp @@ -410,7 +410,9 @@ int UtcDaliBaseHandleConnectSignal(void) application.Render(1000); // simulate a touch event - Dali::TouchPoint point( 0, TouchPoint::Down, 240, 400 ); + Dali::Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 240, 400 ) ); Dali::Integration::TouchEvent event; event.AddPoint( point ); application.ProcessEvent( event ); diff --git a/automated-tests/src/dali/utc-Dali-CustomActor.cpp b/automated-tests/src/dali/utc-Dali-CustomActor.cpp index 928500d..347ef03 100644 --- a/automated-tests/src/dali/utc-Dali-CustomActor.cpp +++ b/automated-tests/src/dali/utc-Dali-CustomActor.cpp @@ -1668,7 +1668,9 @@ int UtcDaliCustomActorOnTouchEvent(void) application.Render(); // simulate a touch event - Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 ); + Dali::Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 1, 1 ) ); Dali::Integration::TouchEvent event; event.AddPoint( point ); application.ProcessEvent( event ); @@ -1699,7 +1701,9 @@ int UtcDaliCustomActorOnHoverEvent(void) application.Render(); // simulate a hover event - Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 ); + Dali::Integration::Point point; + point.SetState( PointState::MOTION ); + point.SetScreenPosition( Vector2( 1, 1 ) ); Dali::Integration::HoverEvent event; event.AddPoint( point ); application.ProcessEvent( event ); diff --git a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp index 5325c43..7dd76a6 100644 --- a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp @@ -117,10 +117,13 @@ struct RemoveActorFunctor : public HoverEventFunctor } }; -Integration::HoverEvent GenerateSingleHover( TouchPoint::State state, Vector2 screenPosition ) +Integration::HoverEvent GenerateSingleHover( TouchPoint::State state, const Vector2& screenPosition ) { Integration::HoverEvent hoverEvent; - hoverEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) ); + Integration::Point point; + point.SetState( static_cast< PointState::Type >( state ) ); + point.SetScreenPosition( screenPosition ); + hoverEvent.points.push_back( point ); return hoverEvent; } diff --git a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp index 6c7ba81..66d85c7 100644 --- a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp @@ -223,7 +223,10 @@ int UtcDaliLongPressGestureDetectorNew(void) actor.TouchedSignal().Connect(&application, touchFunctor); Integration::TouchEvent touchEvent(1); - TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f); + Integration::Point point; + point.SetDeviceId( 1 ); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); touchEvent.AddPoint(point); application.ProcessEvent(touchEvent); @@ -1339,7 +1342,7 @@ int UtcDaliLongPressGestureBehindTouchableSystemOverlay(void) touchData.Reset(); // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) ); + application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); @@ -1393,7 +1396,7 @@ int UtcDaliLongPressGestureTouchBehindGesturedSystemOverlay(void) touchData.Reset(); // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) ); + application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); diff --git a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp index 4943ce6..43f5d95 100644 --- a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp @@ -336,7 +336,10 @@ int UtcDaliPanGestureDetectorNew(void) application.Render(); Integration::TouchEvent touchEvent(1); - TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f); + Integration::Point point; + point.SetDeviceId( 1 ); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); touchEvent.AddPoint(point); application.ProcessEvent(touchEvent); END_TEST; @@ -1671,7 +1674,7 @@ int UtcDaliPanGestureBehindTouchableSystemOverlay(void) touchData.Reset(); // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) ); + application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoordsStart ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); @@ -1728,7 +1731,7 @@ int UtcDaliPanGestureTouchBehindGesturedSystemOverlay(void) touchData.Reset(); // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) ); + application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoordsStart ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); diff --git a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp index 5fb8b27..9ec76db 100644 --- a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp @@ -196,11 +196,18 @@ int UtcDaliPinchGestureDetectorNew(void) detector.Attach(actor); Integration::TouchEvent touchEvent(1); - TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f); + Integration::Point point; + point.SetDeviceId( 1 ); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); touchEvent.AddPoint(point); application.ProcessEvent(touchEvent); - TouchPoint point2(1, TouchPoint::Down, 20.0f, 20.0f, 20.0f, 20.0f); + Integration::Point point2; + point.SetDeviceId( 1 ); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); + point.SetLocalPosition( Vector2( 20.0f, 20.0f ) ); touchEvent.AddPoint(point2); application.ProcessEvent(touchEvent); END_TEST; @@ -1261,7 +1268,7 @@ int UtcDaliPinchGestureBehindTouchableSystemOverlay(void) touchData.Reset(); // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) ); + application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); @@ -1318,7 +1325,7 @@ int UtcDaliPinchGestureTouchBehindGesturedSystemOverlay(void) touchData.Reset(); // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) ); + application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); diff --git a/automated-tests/src/dali/utc-Dali-Stage.cpp b/automated-tests/src/dali/utc-Dali-Stage.cpp index 3c5ef7b..7611ad2 100644 --- a/automated-tests/src/dali/utc-Dali-Stage.cpp +++ b/automated-tests/src/dali/utc-Dali-Stage.cpp @@ -224,6 +224,16 @@ struct ActorCreatedFunctor bool& mSignalVerified; }; +void GenerateTouch( TestApplication& application, PointState::Type state, const Vector2& screenPosition ) +{ + Integration::TouchEvent touchEvent; + Integration::Point point; + point.SetState( state ); + point.SetScreenPosition( screenPosition ); + touchEvent.points.push_back( point ); + application.ProcessEvent( touchEvent ); +} + } // unnamed namespace @@ -872,17 +882,14 @@ int UtcDaliStageTouchedSignalP(void) // Basic test: No actors, single touch (down then up). { - Integration::TouchEvent touchEvent; - touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) ); - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u ); DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor ); data.Reset(); - touchEvent.points[0].state = TouchPoint::Up; - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u ); @@ -904,24 +911,19 @@ int UtcDaliStageTouchedSignalP(void) // Actor on scene, single touch, down in actor, motion, then up outside actor. { - Integration::TouchEvent touchEvent; - touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) ); - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u ); DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor ); data.Reset(); - touchEvent.points[0].state = TouchPoint::Motion; - touchEvent.points[0].screen.x = 150.0f; // Some motion - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); - touchEvent.points[0].state = TouchPoint::Up; - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u ); @@ -932,25 +934,30 @@ int UtcDaliStageTouchedSignalP(void) // Multiple touch. Should only receive a touch on first down and last up. { Integration::TouchEvent touchEvent; + Integration::Point point; // 1st point - touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) ); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); + touchEvent.points.push_back( point ); application.ProcessEvent( touchEvent ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION ); data.Reset(); // 2nd point - touchEvent.points[0].state = TouchPoint::Stationary; - touchEvent.points.push_back( TouchPoint( 1, TouchPoint::Down, 50.0f, 50.0f ) ); + touchEvent.points[0].SetState( PointState::STATIONARY ); + point.SetDeviceId( 1 ); + point.SetScreenPosition( Vector2( 50.0f, 50.0f ) ); + touchEvent.points.push_back( point ); application.ProcessEvent( touchEvent ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION ); data.Reset(); // Primary point is up - touchEvent.points[0].state = TouchPoint::Up; - touchEvent.points[1].state = TouchPoint::Stationary; + touchEvent.points[0].SetState( PointState::UP ); + touchEvent.points[1].SetState( PointState::STATIONARY ); application.ProcessEvent( touchEvent ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION ); @@ -958,15 +965,15 @@ int UtcDaliStageTouchedSignalP(void) // Remove 1st point now, 2nd point is now in motion touchEvent.points.erase( touchEvent.points.begin() ); - touchEvent.points[0].state = TouchPoint::Motion; - touchEvent.points[0].screen.x = 150.0f; + touchEvent.points[0].SetState( PointState::MOTION ); + touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) ); application.ProcessEvent( touchEvent ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION ); data.Reset(); // Final point Up - touchEvent.points[0].state = TouchPoint::Up; + touchEvent.points[0].SetState( PointState::UP ); application.ProcessEvent( touchEvent ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION ); @@ -993,9 +1000,7 @@ int UtcDaliStageTouchedSignalN(void) // No actors, single touch, down, motion then up. { - Integration::TouchEvent touchEvent; - touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) ); - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u ); @@ -1003,16 +1008,13 @@ int UtcDaliStageTouchedSignalN(void) data.Reset(); // Confirm there is no signal when the touchpoint is only moved. - touchEvent.points[0].state = TouchPoint::Motion; - touchEvent.points[0].screen.x = 1200.0f; // Some motion - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); // Confirm a following up event generates a signal. - touchEvent.points[0].state = TouchPoint::Up; - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u ); @@ -1034,9 +1036,7 @@ int UtcDaliStageTouchedSignalN(void) // Actor on scene. Interrupted before down and interrupted after down. { - Integration::TouchEvent touchEvent; - touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Interrupted, 10.0f, 10.0f ) ); - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u ); @@ -1044,8 +1044,7 @@ int UtcDaliStageTouchedSignalN(void) DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted ); data.Reset(); - touchEvent.points[0].state = TouchPoint::Down; - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u ); @@ -1053,8 +1052,7 @@ int UtcDaliStageTouchedSignalN(void) DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Down ); data.Reset(); - touchEvent.points[0].state = TouchPoint::Interrupted; - application.ProcessEvent( touchEvent ); + GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u ); diff --git a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp index eed11ca..d6300de 100644 --- a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp @@ -208,7 +208,10 @@ int UtcDaliTapGestureDetectorNew(void) actor.TouchedSignal().Connect( &application, touchFunctor ); Integration::TouchEvent touchEvent(1); - TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f); + Integration::Point point; + point.SetDeviceId( 1 ); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); touchEvent.AddPoint(point); application.ProcessEvent(touchEvent); @@ -1273,7 +1276,7 @@ int UtcDaliTapGestureBehindTouchableSystemOverlay(void) touchData.Reset(); // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) ); + application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); @@ -1328,7 +1331,7 @@ int UtcDaliTapGestureTouchBehindGesturedSystemOverlay(void) touchData.Reset(); // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) ); + application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); diff --git a/automated-tests/src/dali/utc-Dali-TouchDataProcessing.cpp b/automated-tests/src/dali/utc-Dali-TouchDataProcessing.cpp index d92bf87..48b6625 100644 --- a/automated-tests/src/dali/utc-Dali-TouchDataProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchDataProcessing.cpp @@ -46,9 +46,13 @@ struct TestPoint Actor hitActor; Vector2 local; Vector2 screen; + float radius; + Vector2 ellipseRadius; + float pressure; + Degree angle; TestPoint() - : deviceId(-1), state(PointState::FINISHED) + : deviceId(-1), state(PointState::FINISHED), radius(0), pressure(0) { } static const TestPoint ZERO; @@ -131,6 +135,10 @@ struct TouchDataFunctor p.hitActor = touchData.GetHitActor(i); p.local = touchData.GetLocalPosition(i); p.screen = touchData.GetScreenPosition(i); + p.radius = touchData.GetRadius(i); + p.ellipseRadius = touchData.GetEllipseRadius(i); + p.pressure = touchData.GetPressure(i); + p.angle = touchData.GetAngle(i); signalData.touchData.points.push_back(p); } @@ -210,10 +218,33 @@ struct OutOfBoundsFunctor bool returnValue; }; -Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, Vector2 screenPosition ) +struct TouchEventFunctor +{ + /** + * Constructor. + * @param[in] functorCalled Reference to a boolean which is set to true if the touch event functor is called. + */ + TouchEventFunctor( bool& functorCalled ) + : functorCalled( functorCalled ) + { + } + + bool operator()( Actor actor, const TouchEvent& touch ) + { + functorCalled = true; + return true; + } + + bool& functorCalled; +}; + +Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition ) { Integration::TouchEvent touchEvent; - touchEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) ); + Integration::Point point; + point.SetState( state ); + point.SetScreenPosition( screenPosition ); + touchEvent.points.push_back( point ); return touchEvent; } @@ -244,7 +275,7 @@ int UtcDaliTouchDataNormalProcessing(void) actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); const TestPoint *point1 = &data.touchData.GetPoint(0); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION ); @@ -256,7 +287,7 @@ int UtcDaliTouchDataNormalProcessing(void) // Emit a motion signal screenCoordinates.x = screenCoordinates.y = 11.0f; actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) ); const TestPoint *point2 = &data.touchData.GetPoint(0); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION ); @@ -268,7 +299,7 @@ int UtcDaliTouchDataNormalProcessing(void) // Emit an up signal screenCoordinates.x = screenCoordinates.y = 12.0f; actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) ); const TestPoint *point3 = &data.touchData.GetPoint(0); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION ); @@ -279,7 +310,7 @@ int UtcDaliTouchDataNormalProcessing(void) // Emit a down signal where the actor is not present screenCoordinates.x = screenCoordinates.y = 200.0f; - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); END_TEST; } @@ -308,7 +339,7 @@ int UtcDaliTouchDataAPINegative(void) actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( -1, data.point.deviceId, TEST_LOCATION ); @@ -357,7 +388,7 @@ int UtcDaliTouchDataOutsideCameraNearFarPlanes(void) Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -368,7 +399,7 @@ int UtcDaliTouchDataOutsideCameraNearFarPlanes(void) application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -379,7 +410,7 @@ int UtcDaliTouchDataOutsideCameraNearFarPlanes(void) application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -390,7 +421,7 @@ int UtcDaliTouchDataOutsideCameraNearFarPlanes(void) application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -401,7 +432,7 @@ int UtcDaliTouchDataOutsideCameraNearFarPlanes(void) application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -444,19 +475,19 @@ int UtcDaliTouchDataInterrupted(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); data.Reset(); // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION ); data.Reset(); // Emit another interrupted signal, our signal handler should not be called. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); END_TEST; } @@ -491,7 +522,7 @@ int UtcDaliTouchDataParentConsumer(void) rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION ); @@ -511,7 +542,7 @@ int UtcDaliTouchDataParentConsumer(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( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION ); @@ -531,7 +562,7 @@ int UtcDaliTouchDataParentConsumer(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( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION ); @@ -550,7 +581,7 @@ int UtcDaliTouchDataParentConsumer(void) // Emit a down 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( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION ); @@ -586,7 +617,7 @@ int UtcDaliTouchDataInterruptedParentConsumer(void) rootActor.TouchSignal().Connect( &application, rootFunctor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); @@ -597,7 +628,7 @@ int UtcDaliTouchDataInterruptedParentConsumer(void) rootData.Reset(); // Emit an interrupted signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( 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( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION ); @@ -608,7 +639,7 @@ int UtcDaliTouchDataInterruptedParentConsumer(void) rootData.Reset(); // Emit another down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); @@ -626,7 +657,7 @@ int UtcDaliTouchDataInterruptedParentConsumer(void) application.Render(); // Emit an interrupted signal, only root actor's signal should be called. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); + application.ProcessEvent( GenerateSingleTouch( 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( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION ); @@ -635,7 +666,7 @@ int UtcDaliTouchDataInterruptedParentConsumer(void) rootData.Reset(); // Emit another interrupted state, none of the signal's should be called. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( 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; @@ -663,24 +694,24 @@ int UtcDaliTouchDataLeave(void) actor.SetLeaveRequired( true ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); data.Reset(); // Emit a motion signal outside of actor, should be signalled with a Leave - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION ); data.Reset(); // Another motion outside of actor, no signalling - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) ); + application.ProcessEvent( GenerateSingleTouch( 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( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION ); data.Reset(); @@ -689,7 +720,7 @@ int UtcDaliTouchDataLeave(void) actor.SetLeaveRequired( false ); // Another motion event outside of actor, no signalling - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -724,7 +755,7 @@ int UtcDaliTouchDataLeaveParentConsumer(void) rootActor.SetLeaveRequired( true ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); @@ -735,7 +766,7 @@ int UtcDaliTouchDataLeaveParentConsumer(void) rootData.Reset(); // Emit a motion signal outside of actor, should be signalled with a Leave - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleTouch( 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( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION ); @@ -746,7 +777,7 @@ int UtcDaliTouchDataLeaveParentConsumer(void) rootData.Reset(); // Another motion outside of actor, only rootActor signalled - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) ); + application.ProcessEvent( GenerateSingleTouch( 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( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION ); @@ -755,7 +786,7 @@ int UtcDaliTouchDataLeaveParentConsumer(void) rootData.Reset(); // Another motion event inside actor, signalled with motion - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) ); + application.ProcessEvent( GenerateSingleTouch( 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( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION ); @@ -770,7 +801,7 @@ int UtcDaliTouchDataLeaveParentConsumer(void) // Another motion event outside of root actor, only root signalled Vector2 stageSize( Stage::GetCurrent().GetSize() ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) ); + application.ProcessEvent( GenerateSingleTouch( 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( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION ); @@ -796,7 +827,7 @@ int UtcDaliTouchDataActorBecomesInsensitive(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); data.Reset(); @@ -805,7 +836,7 @@ int UtcDaliTouchDataActorBecomesInsensitive(void) actor.SetSensitive( false ); // Emit a motion signal, signalled with an interrupted - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION ); data.Reset(); @@ -837,7 +868,7 @@ int UtcDaliTouchDataActorBecomesInsensitiveParentConsumer(void) rootActor.TouchSignal().Connect( &application, rootFunctor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); @@ -855,7 +886,7 @@ int UtcDaliTouchDataActorBecomesInsensitiveParentConsumer(void) rootActor.SetSensitive( false ); // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor) - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION ); DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); @@ -892,27 +923,27 @@ int UtcDaliTouchDataMultipleLayers(void) actor1.TouchSignal().Connect( &application, functor ); // Hit in hittable area, actor1 should be hit - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.touchedActor == actor1 ); data.Reset(); // Make layer1 insensitive, nothing should be hit layer1.SetSensitive( false ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, 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.SetSensitive( true ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.touchedActor == actor1 ); data.Reset(); // Make rootActor insensitive, nothing should be hit rootActor.SetSensitive( false ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -940,21 +971,21 @@ int UtcDaliTouchDataMultipleLayers(void) actor2.TouchSignal().Connect( &application, functor ); // Emit an event, should hit layer2 - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack! data.Reset(); // Make layer2 insensitive, should hit actor1 layer2.SetSensitive( false ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.touchedActor == actor1 ); data.Reset(); // Make layer2 sensitive again, should hit layer2 layer2.SetSensitive( true ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack! data.Reset(); @@ -965,7 +996,7 @@ int UtcDaliTouchDataMultipleLayers(void) application.Render(); // Should hit actor1 - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( data.touchedActor == actor1 ); data.Reset(); @@ -976,7 +1007,7 @@ int UtcDaliTouchDataMultipleLayers(void) application.Render(); // Should not hit anything - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -1009,18 +1040,18 @@ int UtcDaliTouchDataMultipleRenderTasks(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Ensure renderTask actor can be hit too. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, 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( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -1060,18 +1091,18 @@ int UtcDaliTouchDataMultipleRenderTasksWithChildLayer(void) layer.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Ensure renderTask actor can be hit too. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, 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( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -1121,7 +1152,7 @@ int UtcDaliTouchDataOffscreenRenderTasks(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -1154,7 +1185,7 @@ int UtcDaliTouchDataMultipleRenderableActors(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( actor == data.touchedActor ); END_TEST; @@ -1182,7 +1213,7 @@ int UtcDaliTouchDataActorRemovedInSignal(void) actor.SetLeaveRequired( true ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1192,12 +1223,12 @@ int UtcDaliTouchDataActorRemovedInSignal(void) application.Render(); // Emit another signal outside of actor's area, should not get anything as the scene has changed. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1206,7 +1237,7 @@ int UtcDaliTouchDataActorRemovedInSignal(void) application.Render(); // Emit another signal outside of actor's area, should not get anything as the scene has changed. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1216,7 +1247,7 @@ int UtcDaliTouchDataActorRemovedInSignal(void) application.Render(); // Emit another down event - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1224,7 +1255,7 @@ int UtcDaliTouchDataActorRemovedInSignal(void) actor.Reset(); // Emit event, should not crash and should not receive an event. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); END_TEST; } @@ -1248,7 +1279,7 @@ int UtcDaliTouchDataActorSignalNotConsumed(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); END_TEST; } @@ -1272,7 +1303,7 @@ int UtcDaliTouchDataActorUnStaged(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1285,7 +1316,7 @@ int UtcDaliTouchDataActorUnStaged(void) application.Render(); // Emit a move at the same point, we should not be signalled. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; @@ -1321,7 +1352,7 @@ int UtcDaliTouchDataSystemOverlayActor(void) application.Render(); // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor. - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( systemActor == data.touchedActor ); END_TEST; @@ -1357,8 +1388,8 @@ int UtcDaliTouchDataLayerConsumesTouch(void) application.Render(); // Emit a few touch signals - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1370,8 +1401,8 @@ int UtcDaliTouchDataLayerConsumesTouch(void) application.Render(); // Emit the same signals again, should not receive - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1401,8 +1432,8 @@ int UtcDaliTouchDataLeaveActorReadded(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down and motion - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 11.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 11.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1411,12 +1442,12 @@ int UtcDaliTouchDataLeaveActorReadded(void) stage.Add( actor ); // Emit a motion within the actor's bounds - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 12.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( 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( GenerateSingleTouch( TouchPoint::Motion, Vector2( 200.0f, 200.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 200.0f, 200.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION ); data.Reset(); @@ -1450,12 +1481,12 @@ int UtcDaliTouchDataStencilNonRenderableActor(void) actor.TouchSignal().Connect( &application, functor ); // Emit an event within stencil area - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Emit an event outside the stencil area but within the actor area, we should have a hit! - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 60.0f, 60.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 60.0f, 60.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1481,7 +1512,7 @@ int UtcDaliTouchDataActorUnstaged(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor ); @@ -1524,7 +1555,7 @@ int UtcDaliTouchDataParentUnstaged(void) actor.TouchSignal().Connect( &application, functor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor ); @@ -1572,7 +1603,7 @@ int UtcDaliTouchDataActorUnstagedDifferentConsumer(void) parent.TouchSignal().Connect( &application, parentFunctor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor ); @@ -1607,7 +1638,7 @@ int UtcDaliTouchDataActorUnstagedDifferentConsumer(void) application.Render(); // Emit a motion signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION ); data.Reset(); @@ -1670,7 +1701,7 @@ int UtcDaliTouchDataInterruptedDifferentConsumer(void) rootActor.TouchSignal().Connect( &application, rootFunctor ); // Emit a down signal - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor ); @@ -1693,7 +1724,7 @@ int UtcDaliTouchDataInterruptedDifferentConsumer(void) parent.TouchSignal().Connect( &application, secondFunctor ); // Emit an interrupted signal, all three should STILL be called - application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 10.0f, 10.0f ) ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION ); DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION ); @@ -1706,3 +1737,156 @@ int UtcDaliTouchDataInterruptedDifferentConsumer(void) END_TEST; } + +int UtcDaliTouchDataGetRadius(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchDataFunctor functor( data ); + actor.TouchSignal().Connect( &application, functor ); + + // Emit a down signal with an angle + Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ); + touchEvent.points[ 0 ].SetRadius( 100.0f ); + application.ProcessEvent( touchEvent ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION ); + DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION ); + DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTouchDataGetEllipseRadius(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchDataFunctor functor( data ); + actor.TouchSignal().Connect( &application, functor ); + + // Emit a down signal with an angle + Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ); + touchEvent.points[ 0 ].SetRadius( 100.0f, Vector2( 20.0f, 10.0f ) ); + application.ProcessEvent( touchEvent ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION ); + DALI_TEST_EQUALS( 20.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION ); + DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTouchDataGetAngle(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchDataFunctor functor( data ); + actor.TouchSignal().Connect( &application, functor ); + + // Emit a down signal with an angle + Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ); + touchEvent.points[ 0 ].SetAngle( Degree( 90.0f ) ); + application.ProcessEvent( touchEvent ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( Degree( 90.0f ), data.touchData.points[0].angle, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTouchDataGetPressure(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchDataFunctor functor( data ); + actor.TouchSignal().Connect( &application, functor ); + + // Emit a down signal with an angle + Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ); + touchEvent.points[ 0 ].SetPressure( 10.0f ); + application.ProcessEvent( touchEvent ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].pressure, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTouchDataAndEventUsage(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchDataFunctor functor( data ); + actor.TouchSignal().Connect( &application, functor ); + + // Connect to actor's touched signal (OLD) + bool touchEventFunctorCalled = false; + TouchEventFunctor eventFunctor( touchEventFunctorCalled ); + actor.TouchedSignal().Connect( &application, eventFunctor ); + + // Emit a down signal with an angle + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, touchEventFunctorCalled, TEST_LOCATION ); + + END_TEST; + + +} diff --git a/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp index fb1eafa..81475c7 100644 --- a/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp @@ -27,6 +27,18 @@ using namespace Dali; using namespace Dali::Integration; +namespace +{ +Point GeneratePoint( int deviceId, PointState::Type state, float x, float y ) +{ + Point point; + point.SetDeviceId( deviceId ); + point.SetState( state ); + point.SetScreenPosition( Vector2( x, y ) ); + return point; +} +} + void utc_dali_touch_event_combiner_startup(void) { test_return_value = TET_UNDEF; @@ -218,13 +230,13 @@ int UtcDaliTouchEventCombinerSingleTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -233,13 +245,13 @@ int UtcDaliTouchEventCombinerSingleTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 101.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 101.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -248,20 +260,20 @@ int UtcDaliTouchEventCombinerSingleTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 101.0f, 101.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 101.0f, 101.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } // Motion event, but same time { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -272,13 +284,13 @@ int UtcDaliTouchEventCombinerSingleTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -287,7 +299,7 @@ int UtcDaliTouchEventCombinerSingleTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -296,13 +308,13 @@ int UtcDaliTouchEventCombinerSingleTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 102.0f, 102.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 102.0f, 102.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } END_TEST; } @@ -316,13 +328,13 @@ int UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].state, TouchPoint::Started, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), PointState::STARTED, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -331,13 +343,13 @@ int UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } END_TEST; } @@ -351,13 +363,13 @@ int UtcDaliTouchEventCombinerSingleTouchMotionFollowedByDown(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].state, TouchPoint::Started, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), PointState::STARTED, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -366,13 +378,13 @@ int UtcDaliTouchEventCombinerSingleTouchMotionFollowedByDown(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -381,13 +393,13 @@ int UtcDaliTouchEventCombinerSingleTouchMotionFollowedByDown(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 103.0f, 103.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 103.0f, 103.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -396,17 +408,17 @@ int UtcDaliTouchEventCombinerSingleTouchMotionFollowedByDown(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 103.0f, 103.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 103.0f, 103.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchBoth, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].state, TouchPoint::Finished, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), PointState::FINISHED, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } END_TEST; } @@ -420,13 +432,13 @@ int UtcDaliTouchEventCombinerSingleTouchTwoDowns(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -435,7 +447,7 @@ int UtcDaliTouchEventCombinerSingleTouchTwoDowns(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -451,7 +463,7 @@ int UtcDaliTouchEventCombinerSingleTouchUpWithoutDown(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -462,7 +474,7 @@ int UtcDaliTouchEventCombinerSingleTouchUpWithoutDown(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 102.0f, 102.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 102.0f, 102.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -478,13 +490,13 @@ int UtcDaliTouchEventCombinerSingleTouchTwoUps(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -493,13 +505,13 @@ int UtcDaliTouchEventCombinerSingleTouchTwoUps(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -508,7 +520,7 @@ int UtcDaliTouchEventCombinerSingleTouchTwoUps(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -524,13 +536,13 @@ int UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -539,7 +551,7 @@ int UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 2, TouchPoint::Up, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 2, PointState::UP, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -550,13 +562,13 @@ int UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } END_TEST; } @@ -570,13 +582,13 @@ int UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -585,13 +597,13 @@ int UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 2, TouchPoint::Motion, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 2, PointState::MOTION, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].state, TouchPoint::Started, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), PointState::STARTED, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -600,13 +612,13 @@ int UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } END_TEST; } @@ -620,13 +632,13 @@ int UtcDaliTouchEventCombinerMultiTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -635,14 +647,14 @@ int UtcDaliTouchEventCombinerMultiTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 2, TouchPoint::Down, 200.0f, 200.0f ); + Integration::Point point = GeneratePoint( 2, PointState::DOWN, 200.0f, 200.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[1].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, TouchPoint::Stationary, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[1].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[1].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), PointState::STATIONARY, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -651,21 +663,21 @@ int UtcDaliTouchEventCombinerMultiTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Motion, 101.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::MOTION, 101.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[1].state, TouchPoint::Stationary, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].GetState(), PointState::STATIONARY, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } // 2nd point motion, no time diff { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 2, TouchPoint::Motion, 200.0f, 200.0f ); + Integration::Point point = GeneratePoint( 2, PointState::MOTION, 200.0f, 200.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -676,14 +688,14 @@ int UtcDaliTouchEventCombinerMultiTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 2, TouchPoint::Motion, 201.0f, 201.0f ); + Integration::Point point = GeneratePoint( 2, PointState::MOTION, 201.0f, 201.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[1].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, TouchPoint::Stationary, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[1].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[1].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), PointState::STATIONARY, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -692,14 +704,14 @@ int UtcDaliTouchEventCombinerMultiTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 101.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 101.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[1].state, TouchPoint::Stationary, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].GetState(), PointState::STATIONARY, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -708,13 +720,13 @@ int UtcDaliTouchEventCombinerMultiTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 2, TouchPoint::Motion, 202.0f, 202.0f ); + Integration::Point point = GeneratePoint( 2, PointState::MOTION, 202.0f, 202.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -723,13 +735,13 @@ int UtcDaliTouchEventCombinerMultiTouchNormal(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 2, TouchPoint::Up, 202.0f, 202.0f ); + Integration::Point point = GeneratePoint( 2, PointState::UP, 202.0f, 202.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } END_TEST; } @@ -745,7 +757,7 @@ int UtcDaliTouchEventCombinerSeveralPoints(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( pointCount, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( pointCount, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time++, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION ); @@ -756,7 +768,7 @@ int UtcDaliTouchEventCombinerSeveralPoints(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( pointCount, TouchPoint::Up, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( pointCount, PointState::UP, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time++, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION ); @@ -773,13 +785,13 @@ int UtcDaliTouchEventCombinerReset(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -791,7 +803,7 @@ int UtcDaliTouchEventCombinerReset(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -807,13 +819,13 @@ int UtcDaliTouchEventCombinerSingleTouchInterrupted(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION ); } time++; @@ -822,13 +834,13 @@ int UtcDaliTouchEventCombinerSingleTouchInterrupted(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Interrupted, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::INTERRUPTED, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchBoth, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); } // Send up, should not be able to send as combiner has been reset. @@ -836,7 +848,7 @@ int UtcDaliTouchEventCombinerSingleTouchInterrupted(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -854,7 +866,7 @@ int UtcDaliTouchEventCombinerMultiTouchInterrupted(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( pointCount, TouchPoint::Down, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( pointCount, PointState::DOWN, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION ); @@ -864,13 +876,13 @@ int UtcDaliTouchEventCombinerMultiTouchInterrupted(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Interrupted, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::INTERRUPTED, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchBoth, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION ); } // Send up, should not be able to send as combiner has been reset. @@ -878,7 +890,7 @@ int UtcDaliTouchEventCombinerMultiTouchInterrupted(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } @@ -894,7 +906,7 @@ int UtcDaliTouchEventCombinerInvalidState(void) { Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; - TouchPoint point( 1, TouchPoint::Stationary, 100.0f, 100.0f ); + Integration::Point point = GeneratePoint( 1, PointState::STATIONARY, 100.0f, 100.0f ); DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION ); } diff --git a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp index cf90160..62052ed 100644 --- a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp @@ -117,10 +117,13 @@ struct RemoveActorFunctor : public TouchEventFunctor } }; -Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, Vector2 screenPosition ) +Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, const Vector2& screenPosition ) { Integration::TouchEvent touchEvent; - touchEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) ); + Integration::Point point; + point.SetState( static_cast< PointState::Type >( state ) ); + point.SetScreenPosition( screenPosition ); + touchEvent.points.push_back( point ); return touchEvent; } diff --git a/dali/integration-api/events/multi-point-event-integ.cpp b/dali/integration-api/events/multi-point-event-integ.cpp index 9320a45..780a04f 100644 --- a/dali/integration-api/events/multi-point-event-integ.cpp +++ b/dali/integration-api/events/multi-point-event-integ.cpp @@ -43,18 +43,18 @@ MultiPointEvent::~MultiPointEvent() { } -void MultiPointEvent::AddPoint(const TouchPoint& point) +void MultiPointEvent::AddPoint( const Point& point ) { points.push_back(point); } -TouchPoint& MultiPointEvent::GetPoint(unsigned int point) +Point& MultiPointEvent::GetPoint( unsigned int point ) { DALI_ASSERT_ALWAYS(point < points.size() && "MultiPointEvent: Point index out of bounds"); return points[point]; } -const TouchPoint& MultiPointEvent::GetPoint(unsigned int point) const +const Point& MultiPointEvent::GetPoint( unsigned int point ) const { DALI_ASSERT_ALWAYS(point < points.size() && "MultiPointEvent: Point index out of bounds"); return points[point]; diff --git a/dali/integration-api/events/multi-point-event-integ.h b/dali/integration-api/events/multi-point-event-integ.h index b5dd601..8fd7c2d 100644 --- a/dali/integration-api/events/multi-point-event-integ.h +++ b/dali/integration-api/events/multi-point-event-integ.h @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include namespace Dali DALI_IMPORT_API { @@ -29,6 +29,10 @@ namespace Dali DALI_IMPORT_API namespace Integration { +typedef std::vector< Point > PointContainer; ///< Container of points +typedef PointContainer::iterator PointContainerIterator; ///< Iterator for Dali::Integration::PointContainer +typedef PointContainer::const_iterator PointContainerConstIterator; ///< Const iterator for Dali::Integration::PointContainer + /** * An instance of this structure should be used by the adaptor to send a multi-point event to Dali core. * @@ -58,38 +62,42 @@ protected: MultiPointEvent(Type eventType, unsigned long time); public: + // Data /** - * @copydoc Dali::MultiPointEvent::points + * @brief A series of points */ - std::vector points; + PointContainer points; /** - * @copydoc Dali::MultiPointEvent::time + * @brief The time */ unsigned long time; // Convenience Methods /** - * Adds a point to the MultiPointEvent. + * @brief Adds a point to the MultiPointEvent. * @param[in] point The point to add. */ - void AddPoint(const TouchPoint& point); + void AddPoint( const Point& point ); /** - * @copydoc Dali::MultiPointEvent::GetPoint() + * @brief Retrieves the Point at position point. + * @return The Point at position point. */ - TouchPoint& GetPoint(unsigned int point); + Point& GetPoint( unsigned int point ); /** - * @copydoc Dali::MultiPointEvent::GetPoint() + * @brief Retrieves a const ref of the Point at position point. + * @return The const ref of the Point at position point. */ - const TouchPoint& GetPoint(unsigned int point) const; + const Point& GetPoint( unsigned int point ) const; /** - * @copydoc Dali::MultiPointEvent::GetPointCount() const + * @brief The total number of Points in this TouchEvent. + * @return The point count. */ unsigned int GetPointCount() const; }; diff --git a/dali/integration-api/events/point.cpp b/dali/integration-api/events/point.cpp new file mode 100644 index 0000000..485c4ed --- /dev/null +++ b/dali/integration-api/events/point.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2016 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 Integration +{ + +Point::Point() +: mTouchPoint( 0, TouchPoint::Started, 0.0f, 0.0f ), + mEllipseRadius(), + mAngle( 0.0f ), + mPressure( 1.0f ), + mRadius( 0.0f ) +{ +} + +Point::Point( const TouchPoint& touchPoint ) +: mTouchPoint( touchPoint ), + mEllipseRadius(), + mAngle( 0.0f ), + mPressure( 1.0f ), + mRadius( 0.0f ) +{ +} + +Point::~Point() +{ +} + +void Point::SetDeviceId( int deviceId ) +{ + mTouchPoint.deviceId = deviceId; +} + +void Point::SetState( PointState::Type state ) +{ + mTouchPoint.state = static_cast< TouchPoint::State >( state ); +} + +void Point::SetScreenPosition( const Vector2& screenPosition ) +{ + mTouchPoint.screen = screenPosition; +} + +void Point::SetRadius( float radius ) +{ + mRadius = mEllipseRadius.x = mEllipseRadius.y = radius; +} + +void Point::SetRadius( float radius, Vector2 ellipseRadius ) +{ + mRadius = radius; + mEllipseRadius = ellipseRadius; +} + +void Point::SetPressure( float pressure ) +{ + mPressure = pressure; +} + +void Point::SetAngle( Degree angle ) +{ + mAngle = angle; +} + +int Point::GetDeviceId() const +{ + return mTouchPoint.deviceId; +} + +PointState::Type Point::GetState() const +{ + return static_cast< PointState::Type >( mTouchPoint.state ); +} + +const Vector2& Point::GetScreenPosition() const +{ + return mTouchPoint.screen; +} + +float Point::GetRadius() const +{ + return mRadius; +} + +const Vector2& Point::GetEllipseRadius() const +{ + return mEllipseRadius; +} + +float Point::GetPressure() const +{ + return mPressure; +} + +Degree Point::GetAngle() const +{ + return mAngle; +} + +void Point::SetHitActor( Actor hitActor ) +{ + mTouchPoint.hitActor = hitActor; +} + +void Point::SetLocalPosition( const Vector2& localPosition ) +{ + mTouchPoint.local = localPosition; +} + +Actor Point::GetHitActor() const +{ + return mTouchPoint.hitActor; +} + +const Vector2& Point::GetLocalPosition() const +{ + return mTouchPoint.local; +} + +const TouchPoint& Point::GetTouchPoint() const +{ + return mTouchPoint; +} + +} // namespace Integration + +} // namespace Dali diff --git a/dali/integration-api/events/point.h b/dali/integration-api/events/point.h new file mode 100644 index 0000000..3b05f5c --- /dev/null +++ b/dali/integration-api/events/point.h @@ -0,0 +1,203 @@ +#ifndef __DALI_INTEGRATION_POINT_H__ +#define __DALI_INTEGRATION_POINT_H__ + +/* + * Copyright (c) 2016 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 + +namespace Dali +{ + +namespace Integration +{ + +/** + * @brief A Point represents a point on the screen that is currently being touched or where touch has stopped. + */ +struct DALI_IMPORT_API Point +{ + /** + * @brief Default Constructor + */ + Point(); + + /** + * @brief Constructor which creates a Point instance from a TouchPoint. + * @param[in] touchPoint The touch-point to copy from. + */ + explicit Point( const TouchPoint& touchPoint ); + + /** + * @brief Destructor + */ + ~Point(); + + /** + * @brief Set the Unique Device ID. + * + * Each touch point has a unique device ID which specifies the touch device for that point. + * + * @param[in] deviceId The Unique Device ID. + */ + void SetDeviceId( int deviceId ); + + /** + * @brief Set the state of the point. + * @param[in] state The state of the point. + */ + void SetState( PointState::Type state ); + + /** + * @brief Set the screen position of the point from the top-left of the screen. + * @param[in] screenPosition The screen position of the point from the top-left of the screen. + */ + void SetScreenPosition( const Vector2& screenPosition ); + + /** + * @brief Set the radius of the press point. + * + * This is the average of both the horizontal and vertical radii of the press point. + * @param[in] radius The average of both the horizontal and vertical radii. + */ + void SetRadius( float radius ); + + /** + * @brief Set the radius of the press point as an ellipse. + * @param[in] radius The average of both the horizontal and vertical radii. + * @param[in] ellipseRadius The horizontal and vertical radii of the press point (different if an ellipse). + */ + void SetRadius( float radius, Vector2 ellipseRadius ); + + /** + * @brief Sets the touch pressure. + * + * The pressure range starts at 0.0f. + * Normal pressure is defined as 1.0f. + * A value between 0.0f and 1.0f means light pressure has been applied. + * A value greater than 1.0f means more pressure than normal has been applied. + * + * @param[in] pressure The touch pressure. + */ + void SetPressure( float pressure ); + + /** + * @brief Sets the angle of the press point relative to the Y-Axis. + * @param[in] angle The angle of the press point relative to the Y-Axis. + */ + void SetAngle( Degree angle ); + + /** + * @brief Retrieve the Unique Device ID of the point. + * @return The Unique Device ID of the point. + */ + int GetDeviceId() const; + + /** + * @brief Retrieve the state of the point. + * @return The state of the point. + */ + PointState::Type GetState() const; + + /** + * @brief Retrieve the screen position from the top-left of the screen. + * @return The screen position from the top-left of the screen. + */ + const Vector2& GetScreenPosition() const; + + /** + * @brief Retrieve the radius of the press point. + * @return The radius of the press point. + * @see SetRadius(float) + * @see SetRadius(float,Vector2) + */ + float GetRadius() const; + + /** + * @brief Retrieve BOTH the horizontal and the vertical radii of the press point. + * @return The radius of the press point. + * @see SetRadius(float) + * @see SetRadius(float,Vector2) + */ + const Vector2& GetEllipseRadius() const; + + /** + * @brief Retrieves the touch pressure. + * + * @return The touch pressure. + * @see SetPressure() + */ + float GetPressure() const; + + /** + * @brief Retrieve the angle of the press point relative to the Y-Axis. + * @return The angle of the press point. + */ + Degree GetAngle() const; + +public: // Not intended for Integration API developers + + /** + * @brief Sets the hit actor under this point. + * @param[in] hitActor The hit actor. + */ + DALI_INTERNAL void SetHitActor( Actor hitActor ); + + /** + * @brief Set the co-ordinates relative to the top-left of the hit-actor. + * @param[in] localPosition The local position. + * @note The top-left of an actor is (0.0, 0.0, 0.5). + */ + DALI_INTERNAL void SetLocalPosition( const Vector2& localPosition ); + + /** + * @brief Retrieve the Hit Actor. + * @return The hit actor. + */ + DALI_INTERNAL Actor GetHitActor() const; + + /** + * @brief Retrieve the local position relative to the top-left of the hit-actor. + * @return The local position. + * @note The top-left of an actor is (0.0, 0.0, 0.5). + */ + DALI_INTERNAL const Vector2& GetLocalPosition() const; + + /** + * @brief Retrieve the touch point equivalent of this point for old API. + * @return The touch point equivalent. + */ + DALI_INTERNAL const TouchPoint& GetTouchPoint() const; + +private: + + TouchPoint mTouchPoint; ///< Stores screen position, device Id, local & screen positions and the hit-actor. @see TouchPoint + Vector2 mEllipseRadius; ///< Radius of both the horizontal and vertical radius (useful if an ellipse). + Degree mAngle; ///< The angle of the press point, relative to the Y-Axis. + float mPressure; ///< The touch pressure. + float mRadius; ///< Radius of the press point, an average of the ellipse radius. +}; + +} // namespace Integration + +} // namespace Dali + +#endif // __DALI_TOUCH_POINT_H__ diff --git a/dali/integration-api/events/touch-event-combiner.cpp b/dali/integration-api/events/touch-event-combiner.cpp index 4e98ccf..5e7a649 100644 --- a/dali/integration-api/events/touch-event-combiner.cpp +++ b/dali/integration-api/events/touch-event-combiner.cpp @@ -48,7 +48,7 @@ struct TouchEventCombiner::PointInfo * @param[in] touchPoint The point to add. * @param[in] pointTime The time of the point event. */ - PointInfo( const TouchPoint& touchPoint, unsigned long pointTime ) + PointInfo( const Point& touchPoint, unsigned long pointTime ) : point( touchPoint ), time( pointTime ) { @@ -56,7 +56,7 @@ struct TouchEventCombiner::PointInfo // Data - TouchPoint point; ///< The point. + Point point; ///< The point. unsigned long time; ///< The time the point event took place. }; @@ -84,13 +84,15 @@ TouchEventCombiner::~TouchEventCombiner() { } -TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( const TouchPoint& point, unsigned long time, TouchEvent& touchEvent, HoverEvent& hoverEvent ) +TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( const Point& point, unsigned long time, TouchEvent& touchEvent, HoverEvent& hoverEvent ) { TouchEventCombiner::EventDispatchType dispatchEvent( TouchEventCombiner::DispatchNone ); + const PointState::Type state = point.GetState(); + const int deviceId = point.GetDeviceId(); - switch ( point.state ) + switch ( state ) { - case TouchPoint::Started: + case PointState::STARTED: { touchEvent.time = time; bool addToContainer( true ); @@ -98,9 +100,9 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con // Iterate through already stored touch points and add to TouchEvent for ( PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter ) { - if ( iter->point.deviceId != point.deviceId ) + if ( iter->point.GetDeviceId() != deviceId ) { - iter->point.state = TouchPoint::Stationary; + iter->point.SetState( PointState::STATIONARY ); } else { @@ -129,16 +131,16 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con PointInfoContainer::iterator match( mHoveredPoints.end() ); for ( PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter ) { - if ( point.deviceId == iter->point.deviceId ) + if ( deviceId == iter->point.GetDeviceId() ) { match = iter; // Add new point to the HoverEvent - iter->point.state = TouchPoint::Finished; + iter->point.SetState( PointState::FINISHED ); hoverEvent.AddPoint( iter->point ); } else { - iter->point.state = TouchPoint::Stationary; + iter->point.SetState( PointState::STATIONARY ); hoverEvent.AddPoint( iter->point ); } } @@ -154,7 +156,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con break; } - case TouchPoint::Finished: + case PointState::FINISHED: { touchEvent.time = time; @@ -162,7 +164,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con PointInfoContainer::iterator match( mPressedPoints.end() ); for ( PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter ) { - if ( point.deviceId == iter->point.deviceId ) + if ( deviceId == iter->point.GetDeviceId() ) { match = iter; @@ -171,7 +173,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con } else { - iter->point.state = TouchPoint::Stationary; + iter->point.SetState( PointState::STATIONARY ); touchEvent.AddPoint( iter->point ); } } @@ -184,7 +186,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con // Iterate through already stored touch points for HoverEvent and delete them for ( PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter ) { - if ( iter->point.deviceId == point.deviceId ) + if ( iter->point.GetDeviceId() == deviceId ) { iter = mHoveredPoints.erase( iter ); } @@ -193,7 +195,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con break; } - case TouchPoint::Motion: + case PointState::MOTION: { bool fromNewDeviceId = false; @@ -203,9 +205,10 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con bool ignore = false; PointInfoContainer::iterator match = mPressedPoints.end(); + const Vector2& pointScreenPosition = point.GetScreenPosition(); for ( PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter ) { - if ( point.deviceId == iter->point.deviceId ) + if ( deviceId == iter->point.GetDeviceId() ) { unsigned long timeDiff( time - iter->time ); @@ -216,8 +219,9 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con break; } - if ( ( std::abs( point.screen.x - iter->point.screen.x ) < mMinMotionDistance.x ) && - ( std::abs( point.screen.y - iter->point.screen.y ) < mMinMotionDistance.y ) ) + const Vector2& currentScreenPosition = iter->point.GetScreenPosition(); + if ( ( std::abs( pointScreenPosition.x - currentScreenPosition.x ) < mMinMotionDistance.x ) && + ( std::abs( pointScreenPosition.y - currentScreenPosition.y ) < mMinMotionDistance.y ) ) { // Not enough positional change from last event so ignore ignore = true; @@ -231,7 +235,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con } else { - iter->point.state = TouchPoint::Stationary; + iter->point.SetState( PointState::STATIONARY ); touchEvent.AddPoint( iter->point ); } } @@ -257,9 +261,10 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con // Iterate through already stored touch points and add to HoverEvent bool ignore = false; PointInfoContainer::iterator match = mHoveredPoints.end(); + const Vector2& pointScreenPosition = point.GetScreenPosition(); for ( PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter ) { - if ( iter->point.deviceId == point.deviceId ) + if ( iter->point.GetDeviceId() == deviceId ) { unsigned long timeDiff( time - iter->time ); @@ -270,8 +275,9 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con break; } - if ( ( std::abs( point.screen.x - iter->point.screen.x ) < mMinMotionDistance.x ) && - ( std::abs( point.screen.y - iter->point.screen.y ) < mMinMotionDistance.y ) ) + const Vector2& currentScreenPosition = iter->point.GetScreenPosition(); + if ( ( std::abs( pointScreenPosition.x - currentScreenPosition.x ) < mMinMotionDistance.x ) && + ( std::abs( pointScreenPosition.y - currentScreenPosition.y ) < mMinMotionDistance.y ) ) { // Not enough positional change from last event so ignore ignore = true; @@ -285,7 +291,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con } else { - iter->point.state = TouchPoint::Stationary; + iter->point.SetState( PointState::STATIONARY ); hoverEvent.AddPoint( iter->point ); } } @@ -295,8 +301,8 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con { if( match == mHoveredPoints.end() ) { - TouchPoint hoverPoint(point); - hoverPoint.state = TouchPoint::Started; // The first hover event received + Point hoverPoint(point); + hoverPoint.SetState( PointState::STARTED ); // The first hover event received mHoveredPoints.push_back( PointInfo( hoverPoint, time ) ); hoverEvent.AddPoint( hoverPoint ); } @@ -319,7 +325,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con break; } - case TouchPoint::Interrupted: + case PointState::INTERRUPTED: { Reset(); diff --git a/dali/integration-api/events/touch-event-combiner.h b/dali/integration-api/events/touch-event-combiner.h index 1c3b351..fd2f25a 100644 --- a/dali/integration-api/events/touch-event-combiner.h +++ b/dali/integration-api/events/touch-event-combiner.h @@ -20,10 +20,10 @@ // INTERNAL INCLUDES #include -#include #include +#include -namespace Dali DALI_IMPORT_API +namespace Dali { namespace Integration @@ -35,7 +35,7 @@ struct HoverEvent; /** * Dali::Integration::TouchEventCombiner is a utility class, an instance of which, should be created * upon initialisation. It accepts single Point(s) containing information about a touch area and - * creates a TouchEvent and/or HoverEvent combining the latest event's information with previous TouchPoint(s). + * creates a TouchEvent and/or HoverEvent combining the latest event's information with previous Point(s). * * The created TouchEvent and/or HoverEvent can then be sent to the Dali Core as indicated by the GetNextTouchEvent() * method. @@ -46,7 +46,7 @@ struct HoverEvent; * - Motion event throttling is carried out to satisfy the minimum distance and time delta required. * - If an interrupted event is received, then any stored Point history is cleared. */ -class TouchEventCombiner +class DALI_IMPORT_API TouchEventCombiner { public: @@ -105,7 +105,7 @@ public: * * @return true if the point is beyond the different thresholds set thus, should be sent to core, false otherwise. */ - EventDispatchType GetNextTouchEvent( const TouchPoint& point, unsigned long time, TouchEvent& touchEvent, HoverEvent& hoverEvent ); + EventDispatchType GetNextTouchEvent( const Point& point, unsigned long time, TouchEvent& touchEvent, HoverEvent& hoverEvent ); /** * Sets the minimum time (in ms) that should occur between motion events. @@ -152,7 +152,7 @@ public: /** * This resets any information contained by the TouchEventCombiner. * This may be required if some platform event has occurred which makes it necessary to reset any - * TouchPoint information that the combiner may store. + * Point information that the combiner may store. */ void Reset(); diff --git a/dali/integration-api/file.list b/dali/integration-api/file.list index 45a2be6..79d4f95 100644 --- a/dali/integration-api/file.list +++ b/dali/integration-api/file.list @@ -18,6 +18,7 @@ platform_abstraction_src_files = \ $(platform_abstraction_src_dir)/events/multi-point-event-integ.cpp \ $(platform_abstraction_src_dir)/events/pan-gesture-event.cpp \ $(platform_abstraction_src_dir)/events/pinch-gesture-event.cpp \ + $(platform_abstraction_src_dir)/events/point.cpp \ $(platform_abstraction_src_dir)/events/tap-gesture-event.cpp \ $(platform_abstraction_src_dir)/events/touch-event-combiner.cpp \ $(platform_abstraction_src_dir)/events/touch-event-integ.cpp @@ -55,6 +56,7 @@ platform_abstraction_events_header_files = \ $(platform_abstraction_src_dir)/events/multi-point-event-integ.h \ $(platform_abstraction_src_dir)/events/pan-gesture-event.h \ $(platform_abstraction_src_dir)/events/pinch-gesture-event.h \ + $(platform_abstraction_src_dir)/events/point.h \ $(platform_abstraction_src_dir)/events/tap-gesture-event.h \ $(platform_abstraction_src_dir)/events/touch-event-combiner.h \ $(platform_abstraction_src_dir)/events/touch-event-integ.h diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 7f7ae96..acc916c 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -1823,7 +1823,7 @@ bool Actor::EmitTouchEventSignal( const TouchEvent& event, const Dali::TouchData consumed = mTouchSignal.Emit( handle, touch ); } - if( !mTouchedSignal.Empty() || !mTouchSignal.Empty() ) + if( !mTouchedSignal.Empty() ) { Dali::Actor handle( this ); consumed |= mTouchedSignal.Emit( handle, event ); diff --git a/dali/internal/event/events/hover-event-processor.cpp b/dali/internal/event/events/hover-event-processor.cpp index c4d5440..964ad87 100644 --- a/dali/internal/event/events/hover-event-processor.cpp +++ b/dali/internal/event/events/hover-event-processor.cpp @@ -168,6 +168,7 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even DALI_ASSERT_ALWAYS( !event.points.empty() && "Empty HoverEvent sent from Integration\n" ); Stage& stage = mStage; + TouchPoint::State state = static_cast< TouchPoint::State >( event.points[0].GetState() ); PRINT_HIERARCHY(gLogFilter); @@ -177,10 +178,10 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even // 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. - if ( event.points[0].state == TouchPoint::Interrupted ) + if ( state == TouchPoint::Interrupted ) { Dali::Actor consumingActor; - hoverEvent.points.push_back(event.points[0]); + hoverEvent.points.push_back( event.points[0].GetTouchPoint() ); Actor* lastPrimaryHitActor( mLastPrimaryHitActor.GetActor() ); if ( lastPrimaryHitActor ) @@ -230,20 +231,20 @@ void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& even Dali::RenderTask currentRenderTask; - for ( TouchPointContainerConstIterator iter = event.points.begin(), beginIter = event.points.begin(), endIter = event.points.end(); iter != endIter; ++iter ) + for ( Integration::PointContainerConstIterator iter = event.points.begin(), beginIter = event.points.begin(), endIter = event.points.end(); iter != endIter; ++iter ) { HitTestAlgorithm::Results hitTestResults; ActorHoverableCheck actorHoverableCheck; - HitTestAlgorithm::HitTest( stage, iter->screen, hitTestResults, actorHoverableCheck ); + HitTestAlgorithm::HitTest( stage, iter->GetScreenPosition(), hitTestResults, actorHoverableCheck ); - TouchPoint newPoint( iter->deviceId, iter->state, iter->screen.x, iter->screen.y ); + TouchPoint newPoint( iter->GetTouchPoint() ); newPoint.hitActor = hitTestResults.actor; newPoint.local = hitTestResults.actorCoordinates; hoverEvent.points.push_back( newPoint ); DALI_LOG_INFO( gLogFilter, Debug::General, " State(%s), Screen(%.0f, %.0f), HitActor(%p, %s), Local(%.2f, %.2f)\n", - TOUCH_POINT_STATE[iter->state], iter->screen.x, iter->screen.y, + TOUCH_POINT_STATE[iter->GetState()], iter->GetScreenPosition().x, iter->GetScreenPosition().y, ( hitTestResults.actor ? (void*)&hitTestResults.actor.GetBaseObject() : NULL ), ( hitTestResults.actor ? hitTestResults.actor.GetName().c_str() : "" ), hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y ); diff --git a/dali/internal/event/events/touch-data-impl.cpp b/dali/internal/event/events/touch-data-impl.cpp index f076099..a041c82 100644 --- a/dali/internal/event/events/touch-data-impl.cpp +++ b/dali/internal/event/events/touch-data-impl.cpp @@ -39,6 +39,14 @@ TouchData::TouchData( unsigned long time ) { } +TouchDataPtr TouchData::Clone( const TouchData& other ) +{ + TouchDataPtr touchData( new TouchData ); + touchData->mPoints = other.mPoints; + touchData->mTime = other.mTime; + return touchData; +} + TouchData::~TouchData() { } @@ -48,70 +56,107 @@ unsigned long TouchData::GetTime() const return mTime; } -size_t TouchData::GetPointCount() const +std::size_t TouchData::GetPointCount() const { return mPoints.size(); } -int32_t TouchData::GetDeviceId( size_t point ) const +int32_t TouchData::GetDeviceId( std::size_t point ) const { if( point < mPoints.size() ) { - return mPoints[ point ].deviceId; + return mPoints[ point ].GetDeviceId(); } return -1; } -PointState::Type TouchData::GetState( size_t point ) const +PointState::Type TouchData::GetState( std::size_t point ) const { if( point < mPoints.size() ) { - return static_cast< PointState::Type >( mPoints[ point ].state ); + return mPoints[ point ].GetState(); } return PointState::FINISHED; } -Dali::Actor TouchData::GetHitActor( size_t point ) const +Dali::Actor TouchData::GetHitActor( std::size_t point ) const { if( point < mPoints.size() ) { - return mPoints[ point ].hitActor; + return mPoints[ point ].GetHitActor(); } return Dali::Actor(); } -const Vector2& TouchData::GetLocalPosition( size_t point ) const +const Vector2& TouchData::GetLocalPosition( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetLocalPosition(); + } + return Vector2::ZERO; +} + +const Vector2& TouchData::GetScreenPosition( std::size_t point ) const { if( point < mPoints.size() ) { - return mPoints[ point ].local; + return mPoints[ point ].GetScreenPosition(); } return Vector2::ZERO; } -const Vector2& TouchData::GetScreenPosition( size_t point ) const +float TouchData::GetRadius( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetRadius(); + } + return 0.0f; +} + +const Vector2& TouchData::GetEllipseRadius( std::size_t point ) const { if( point < mPoints.size() ) { - return mPoints[ point ].screen; + return mPoints[ point ].GetEllipseRadius(); } return Vector2::ZERO; } -const TouchPoint& TouchData::GetPoint( size_t point ) const +float TouchData::GetPressure( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetPressure(); + } + return 1.0f; +} + +Degree TouchData::GetAngle( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetAngle(); + } + return Degree(); +} + +const Integration::Point& TouchData::GetPoint( std::size_t point ) const { DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" ); return mPoints[ point ]; } -void TouchData::AddPoint( const TouchPoint& point ) +Integration::Point& TouchData::GetPoint( std::size_t point ) { - mPoints.push_back( point ); + DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" ); + return mPoints[ point ]; } -void TouchData::SetPoints( const TouchPointContainer& points ) +void TouchData::AddPoint( const Integration::Point& point ) { - mPoints = points; + mPoints.push_back( point ); } } // namsespace Internal diff --git a/dali/internal/event/events/touch-data-impl.h b/dali/internal/event/events/touch-data-impl.h index fb7589f..5221db0 100644 --- a/dali/internal/event/events/touch-data-impl.h +++ b/dali/internal/event/events/touch-data-impl.h @@ -22,8 +22,8 @@ #include #include #include -#include #include +#include namespace Dali { @@ -34,6 +34,9 @@ struct Vector2; namespace Internal { +class TouchData; +typedef IntrusivePtr< TouchData > TouchDataPtr; + /** * @copydoc Dali::TouchData */ @@ -55,6 +58,15 @@ public: TouchData( unsigned long time ); /** + * @brief Clones the TouchData object. + * + * Required because base class copy constructor is not implemented. + * @param[in] other The TouchData to clone from. + * @return A new TouchData object which is has the same touch point data. + */ + static TouchDataPtr Clone( const TouchData& other ); + + /** * @brief Destructor */ ~TouchData(); @@ -69,44 +81,74 @@ public: /** * @copydoc Dali::TouchData::GetPointCount() */ - size_t GetPointCount() const; + std::size_t GetPointCount() const; /** * @copydoc Dali::TouchData::GetDeviceId() */ - int32_t GetDeviceId( size_t point ) const; + int32_t GetDeviceId( std::size_t point ) const; /** * @copydoc Dali::TouchData::GetGetState() */ - PointState::Type GetState( size_t point ) const; + PointState::Type GetState( std::size_t point ) const; /** * @copydoc Dali::TouchData::GetHitActor() */ - Dali::Actor GetHitActor( size_t point ) const; + Dali::Actor GetHitActor( std::size_t point ) const; /** * @copydoc Dali::TouchData::GetLocalPosition() */ - const Vector2& GetLocalPosition( size_t point ) const; + const Vector2& GetLocalPosition( std::size_t point ) const; /** * @copydoc Dali::TouchData::GetScreenPosition() */ - const Vector2& GetScreenPosition( size_t point ) const; + const Vector2& GetScreenPosition( std::size_t point ) const; + + /** + * @copydoc Dali::TouchData::GetRadius() + */ + float GetRadius( std::size_t point ) const; + + /** + * @copydoc Dali::TouchData::GetEllipseRadius() + */ + const Vector2& GetEllipseRadius( std::size_t point ) const; + + /** + * @copydoc Dali::TouchData::GetPressure() + */ + float GetPressure( std::size_t point ) const; + + /** + * @copydoc Dali::TouchData::GetAngle() + */ + Degree GetAngle( 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). * - * @SINCE_1_1.36 * @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. */ - const TouchPoint& GetPoint( size_t point ) const; + Integration::Point& GetPoint( std::size_t point ); // Setters @@ -114,14 +156,7 @@ public: * @brief Adds a point to this touch event handler. * @param[in] point The point to add to the touch event handler. */ - void AddPoint( const TouchPoint& point ); - - /** - * @brief Overwrites the internal container with the point container specified. - * - * @param[in] points The point container. - */ - void SetPoints( const TouchPointContainer& points ); + void AddPoint( const Integration::Point& point ); private: @@ -131,8 +166,8 @@ private: /// Undefined TouchData& operator=( const TouchData& other ); - TouchPointContainer mPoints; ///< Container of the points for this touch event. - unsigned long mTime; ///< The time (in ms) that the touch event occurred. + std::vector< Integration::Point > mPoints; ///< Container of the points for this touch event. + unsigned long mTime; ///< The time (in ms) that the touch event occurred. }; } // namespace Internal diff --git a/dali/internal/event/events/touch-event-processor.cpp b/dali/internal/event/events/touch-event-processor.cpp index 0551ccd..b9c305c 100644 --- a/dali/internal/event/events/touch-event-processor.cpp +++ b/dali/internal/event/events/touch-event-processor.cpp @@ -48,14 +48,14 @@ namespace #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TOUCH_PROCESSOR" ); -const char * TOUCH_POINT_STATE[TouchPoint::Last] = +const char * TOUCH_POINT_STATE[ 6 ] = { - "Down", - "Up", - "Motion", - "Leave", - "Stationary", - "Interrupted", + "DOWN", + "UP", + "MOTION", + "LEAVE", + "STATIONARY", + "INTERRUPTED", }; #endif // defined(DEBUG_ENABLED) @@ -104,13 +104,13 @@ Dali::Actor EmitTouchSignals( Dali::Actor actor, const TouchEvent& event, const return consumedActor; } -Dali::Actor AllocAndEmitTouchSignals( unsigned long time, Dali::Actor actor, const TouchPoint& point ) +Dali::Actor AllocAndEmitTouchSignals( unsigned long time, Dali::Actor actor, const Integration::Point& point ) { TouchEvent touchEvent( time ); - IntrusivePtr< TouchData > touchData( new TouchData( time ) ); + TouchDataPtr touchData( new TouchData( time ) ); Dali::TouchData touchDataHandle( touchData.Get() ); - touchEvent.points.push_back( point ); + touchEvent.points.push_back( point.GetTouchPoint() ); touchData->AddPoint( point ); return EmitTouchSignals( actor, touchEvent, touchDataHandle ); @@ -120,25 +120,31 @@ Dali::Actor AllocAndEmitTouchSignals( unsigned long time, Dali::Actor actor, co /** * Changes the state of the primary point to leave and emits the touch signals */ -Dali::Actor EmitTouchSignals( Actor* actor, RenderTask& renderTask, const TouchEvent& originalEvent, TouchPoint::State state ) +Dali::Actor EmitTouchSignals( Actor* actor, RenderTask& renderTask, const TouchEvent& originalEvent, const TouchDataPtr& originalTouchData, PointState::Type state ) { - TouchEvent touchEvent( originalEvent ); + Dali::Actor consumingActor; - DALI_ASSERT_DEBUG( NULL != actor && "NULL actor pointer" ); if( actor ) { - TouchPoint& primaryPoint = touchEvent.points[0]; + TouchDataPtr touchData = TouchData::Clone( *originalTouchData.Get() ); - actor->ScreenToLocal( renderTask, primaryPoint.local.x, primaryPoint.local.y, primaryPoint.screen.x, primaryPoint.screen.y ); + Integration::Point& primaryPoint = touchData->GetPoint( 0 ); - primaryPoint.hitActor = Dali::Actor(actor); - primaryPoint.state = state; - } + const Vector2& screenPosition = primaryPoint.GetScreenPosition(); + Vector2 localPosition; + actor->ScreenToLocal( renderTask, localPosition.x, localPosition.y, screenPosition.x, screenPosition.y ); + + primaryPoint.SetLocalPosition( localPosition ); + primaryPoint.SetHitActor( Dali::Actor( actor ) ); + primaryPoint.SetState( state ); - IntrusivePtr< TouchData > touchData( new TouchData( touchEvent.time ) ); - touchData->SetPoints( touchEvent.points ); + TouchEvent touchEvent( originalEvent ); + touchEvent.points[0] = primaryPoint.GetTouchPoint(); + + consumingActor = EmitTouchSignals( Dali::Actor(actor), touchEvent, Dali::TouchData( touchData.Get() ) ); + } - return EmitTouchSignals( Dali::Actor(actor), touchEvent, Dali::TouchData( touchData.Get() ) ); + return consumingActor; } } // unnamed namespace @@ -171,16 +177,16 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even // 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. - if ( event.points[0].state == TouchPoint::Interrupted ) + if ( event.points[0].GetState() == PointState::INTERRUPTED ) { Dali::Actor consumingActor; - TouchPoint currentPoint( event.points[0] ); + Integration::Point currentPoint( event.points[0] ); Actor* lastPrimaryHitActor( mLastPrimaryHitActor.GetActor() ); if ( lastPrimaryHitActor ) { Dali::Actor lastPrimaryHitActorHandle( lastPrimaryHitActor ); - currentPoint.hitActor = lastPrimaryHitActorHandle; + currentPoint.SetHitActor( lastPrimaryHitActorHandle ); consumingActor = AllocAndEmitTouchSignals( event.time, lastPrimaryHitActorHandle, currentPoint ); } @@ -192,7 +198,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even lastConsumedActor != consumingActor ) { Dali::Actor lastConsumedActorHandle( lastConsumedActor ); - currentPoint.hitActor = lastConsumedActorHandle; + currentPoint.SetHitActor( lastConsumedActorHandle ); AllocAndEmitTouchSignals( event.time, lastConsumedActorHandle, currentPoint ); } @@ -205,7 +211,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even { Dali::Actor touchDownConsumedActorHandle( touchDownConsumedActor ); - currentPoint.hitActor = touchDownConsumedActorHandle; + currentPoint.SetHitActor( touchDownConsumedActorHandle ); AllocAndEmitTouchSignals( event.time, touchDownConsumedActorHandle, currentPoint ); } @@ -214,13 +220,13 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even mTouchDownConsumedActor.SetActor( NULL ); mLastRenderTask.Reset(); - currentPoint.hitActor.Reset(); + currentPoint.SetHitActor( Dali::Actor() ); TouchEvent touchEvent( event.time ); - IntrusivePtr< TouchData > touchData( new TouchData( event.time ) ); + TouchDataPtr touchData( new TouchData( event.time ) ); Dali::TouchData touchDataHandle( touchData.Get() ); - touchEvent.points.push_back( currentPoint ); + touchEvent.points.push_back( currentPoint.GetTouchPoint() ); touchData->AddPoint( currentPoint ); mStage.EmitTouchedSignal( touchEvent, touchDataHandle ); @@ -230,7 +236,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even // 2) Hit Testing. TouchEvent touchEvent( event.time ); - IntrusivePtr< TouchData > touchData( new TouchData( event.time ) ); + TouchDataPtr touchData( new TouchData( event.time ) ); Dali::TouchData touchDataHandle( touchData.Get() ); DALI_LOG_INFO( gLogFilter, Debug::Concise, "\n" ); @@ -238,19 +244,20 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even Dali::RenderTask currentRenderTask; - for ( TouchPointContainerConstIterator iter = event.points.begin(), beginIter = event.points.begin(), endIter = event.points.end(); iter != endIter; ++iter ) + for ( Integration::PointContainerConstIterator iter = event.points.begin(), beginIter = event.points.begin(), endIter = event.points.end(); iter != endIter; ++iter ) { HitTestAlgorithm::Results hitTestResults; - HitTestAlgorithm::HitTest( stage, iter->screen, hitTestResults ); + HitTestAlgorithm::HitTest( stage, iter->GetScreenPosition(), hitTestResults ); - TouchPoint newPoint( iter->deviceId, iter->state, iter->screen.x, iter->screen.y, hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y ); - newPoint.hitActor = hitTestResults.actor; + Integration::Point newPoint( *iter ); + newPoint.SetHitActor( hitTestResults.actor ); + newPoint.SetLocalPosition( hitTestResults.actorCoordinates ); - touchEvent.points.push_back( newPoint ); + touchEvent.points.push_back( newPoint.GetTouchPoint() ); touchData->AddPoint( newPoint ); DALI_LOG_INFO( gLogFilter, Debug::General, " State(%s), Screen(%.0f, %.0f), HitActor(%p, %s), Local(%.2f, %.2f)\n", - TOUCH_POINT_STATE[iter->state], iter->screen.x, iter->screen.y, + TOUCH_POINT_STATE[iter->GetState()], iter->GetScreenPosition().x, iter->GetScreenPosition().y, ( hitTestResults.actor ? (void*)&hitTestResults.actor.GetBaseObject() : NULL ), ( hitTestResults.actor ? hitTestResults.actor.GetName().c_str() : "" ), hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y ); @@ -268,17 +275,17 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even Dali::Actor consumedActor; if ( currentRenderTask ) { - consumedActor = EmitTouchSignals( touchEvent.points[0].hitActor, touchEvent, touchDataHandle ); + consumedActor = EmitTouchSignals( touchData->GetPoint( 0 ).GetHitActor(), touchEvent, touchDataHandle ); } - TouchPoint& primaryPoint = touchEvent.points[0]; - Dali::Actor primaryHitActor = primaryPoint.hitActor; - TouchPoint::State primaryPointState = primaryPoint.state; + Integration::Point& primaryPoint = touchData->GetPoint( 0 ); + Dali::Actor primaryHitActor = primaryPoint.GetHitActor(); + PointState::Type primaryPointState = primaryPoint.GetState(); - DALI_LOG_INFO( gLogFilter, Debug::Concise, "PrimaryHitActor: (%p) %s\n", primaryPoint.hitActor ? (void*)&primaryPoint.hitActor.GetBaseObject() : NULL, primaryPoint.hitActor ? primaryPoint.hitActor.GetName().c_str() : "" ); + DALI_LOG_INFO( gLogFilter, Debug::Concise, "PrimaryHitActor: (%p) %s\n", primaryHitActor ? (void*)&primaryHitActor.GetBaseObject() : NULL, primaryHitActor ? primaryHitActor.GetName().c_str() : "" ); DALI_LOG_INFO( gLogFilter, Debug::Concise, "ConsumedActor: (%p) %s\n", consumedActor ? (void*)&consumedActor.GetBaseObject() : NULL, consumedActor ? consumedActor.GetName().c_str() : "" ); - if ( ( primaryPointState == TouchPoint::Down ) && + if ( ( primaryPointState == PointState::DOWN ) && ( touchEvent.GetPointCount() == 1 ) && ( consumedActor && consumedActor.OnStage() ) ) { @@ -290,7 +297,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even Actor* lastPrimaryHitActor( mLastPrimaryHitActor.GetActor() ); Actor* lastConsumedActor( mLastConsumedActor.GetActor() ); - if( (primaryPointState == TouchPoint::Motion) || (primaryPointState == TouchPoint::Up) || (primaryPointState == TouchPoint::Stationary) ) + if( ( primaryPointState == PointState::MOTION ) || ( primaryPointState == PointState::UP ) || ( primaryPointState == PointState::STATIONARY ) ) { if ( mLastRenderTask ) { @@ -306,7 +313,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even if ( lastPrimaryHitActor->GetLeaveRequired() ) { DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Hit): (%p) %s\n", (void*)lastPrimaryHitActor, lastPrimaryHitActor->GetName().c_str() ); - leaveEventConsumer = EmitTouchSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEvent, TouchPoint::Leave ); + leaveEventConsumer = EmitTouchSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEvent, touchData, PointState::LEAVE ); } } else @@ -314,7 +321,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even // At this point mLastPrimaryHitActor was touchable and sensitive in the previous touch event process but is not in the current one. // An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls) DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Hit): (%p) %s\n", (void*)lastPrimaryHitActor, lastPrimaryHitActor->GetName().c_str() ); - leaveEventConsumer = EmitTouchSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEvent, TouchPoint::Interrupted ); + leaveEventConsumer = EmitTouchSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEvent, touchData, PointState::INTERRUPTED ); } } @@ -332,7 +339,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even if( lastConsumedActor->GetLeaveRequired() ) { DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Consume): (%p) %s\n", (void*)lastConsumedActor, lastConsumedActor->GetName().c_str() ); - EmitTouchSignals( lastConsumedActor, lastRenderTaskImpl, touchEvent, TouchPoint::Leave ); + EmitTouchSignals( lastConsumedActor, lastRenderTaskImpl, touchEvent, touchData, PointState::LEAVE ); } } else @@ -340,7 +347,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even // At this point mLastConsumedActor was touchable and sensitive in the previous touch event process but is not in the current one. // An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls) DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Consume): (%p) %s\n", (void*)lastConsumedActor, lastConsumedActor->GetName().c_str() ); - EmitTouchSignals( mLastConsumedActor.GetActor(), lastRenderTaskImpl, touchEvent, TouchPoint::Interrupted ); + EmitTouchSignals( mLastConsumedActor.GetActor(), lastRenderTaskImpl, touchEvent, touchData, PointState::INTERRUPTED ); } } } @@ -349,7 +356,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even // 5) If our primary point is an Up 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::Up ) + if ( primaryPointState == PointState::UP ) { mLastPrimaryHitActor.SetActor( NULL ); mLastConsumedActor.SetActor( NULL ); @@ -389,7 +396,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even { switch ( primaryPointState ) { - case TouchPoint::Up: + case PointState::UP: { Actor* touchDownConsumedActor( mTouchDownConsumedActor.GetActor() ); if ( touchDownConsumedActor && @@ -399,9 +406,9 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even { Dali::Actor touchDownConsumedActorHandle( touchDownConsumedActor ); - TouchPoint currentPoint = touchData->GetPoint( 0 ); - currentPoint.hitActor = touchDownConsumedActorHandle; - currentPoint.state = TouchPoint::Interrupted; + Integration::Point currentPoint = touchData->GetPoint( 0 ); + currentPoint.SetHitActor( touchDownConsumedActorHandle ); + currentPoint.SetState( PointState::INTERRUPTED ); AllocAndEmitTouchSignals( event.time, touchDownConsumedActorHandle, currentPoint ); } @@ -410,17 +417,16 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even } // No break, Fallthrough - case TouchPoint::Down: + case PointState::DOWN: { mStage.EmitTouchedSignal( touchEvent, touchDataHandle ); break; } - case TouchPoint::Motion: - case TouchPoint::Leave: - case TouchPoint::Stationary: - case TouchPoint::Interrupted: - case TouchPoint::Last: + case PointState::MOTION: + case PointState::LEAVE: + case PointState::STATIONARY: + case PointState::INTERRUPTED: { // Ignore break; @@ -434,14 +440,18 @@ void TouchEventProcessor::OnObservedActorDisconnected( Actor* actor ) if ( actor == mLastPrimaryHitActor.GetActor() ) { Dali::Actor handle( actor ); - TouchEvent touchEvent( 0 ); - touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Interrupted, 0.0f, 0.0f ) ); - touchEvent.points[0].hitActor = handle; - IntrusivePtr< TouchData > touchData( new TouchData ); - touchData->SetPoints( touchEvent.points ); + Integration::Point point; + point.SetState( PointState::INTERRUPTED ); + point.SetHitActor( handle ); + TouchDataPtr touchData( new TouchData ); + touchData->AddPoint( point ); Dali::TouchData touchDataHandle( touchData.Get() ); + + TouchEvent touchEvent( 0 ); + touchEvent.points.push_back( point.GetTouchPoint() ); + Dali::Actor eventConsumer = EmitTouchSignals( handle, touchEvent, touchDataHandle ); if ( mLastConsumedActor.GetActor() != eventConsumer ) diff --git a/dali/public-api/events/touch-data.cpp b/dali/public-api/events/touch-data.cpp index 7f15af4..215ae67 100644 --- a/dali/public-api/events/touch-data.cpp +++ b/dali/public-api/events/touch-data.cpp @@ -52,36 +52,56 @@ unsigned long TouchData::GetTime() const return GetImplementation( *this ).GetTime(); } -size_t TouchData::GetPointCount() const +std::size_t TouchData::GetPointCount() const { return GetImplementation( *this ).GetPointCount(); } -int32_t TouchData::GetDeviceId( size_t point ) const +int32_t TouchData::GetDeviceId( std::size_t point ) const { return GetImplementation( *this ).GetDeviceId( point ); } -PointState::Type TouchData::GetState( size_t point ) const +PointState::Type TouchData::GetState( std::size_t point ) const { return GetImplementation( *this ).GetState( point ); } -Actor TouchData::GetHitActor( size_t point ) const +Actor TouchData::GetHitActor( std::size_t point ) const { return GetImplementation( *this ).GetHitActor( point ); } -const Vector2& TouchData::GetLocalPosition( size_t point ) const +const Vector2& TouchData::GetLocalPosition( std::size_t point ) const { return GetImplementation( *this ).GetLocalPosition( point ); } -const Vector2& TouchData::GetScreenPosition( size_t point ) const +const Vector2& TouchData::GetScreenPosition( std::size_t point ) const { return GetImplementation( *this ).GetScreenPosition( point ); } +float TouchData::GetRadius( std::size_t point ) const +{ + return GetImplementation( *this ).GetRadius( point ); +} + +const Vector2& TouchData::GetEllipseRadius( std::size_t point ) const +{ + return GetImplementation( *this ).GetEllipseRadius( point ); +} + +float TouchData::GetPressure( std::size_t point ) const +{ + return GetImplementation( *this ).GetPressure( point ); +} + +Degree TouchData::GetAngle( std::size_t point ) const +{ + return GetImplementation( *this ).GetAngle( point ); +} + TouchData::TouchData( Internal::TouchData* internal ) : BaseHandle( internal ) { diff --git a/dali/public-api/events/touch-data.h b/dali/public-api/events/touch-data.h index 7b1cfd2..be302a2 100644 --- a/dali/public-api/events/touch-data.h +++ b/dali/public-api/events/touch-data.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace Dali { @@ -70,7 +71,7 @@ public: * @brief Copy constructor * * @SINCE_1_1.37 - * @param[in] other The TouchEventHandle to copy from. + * @param[in] other The TouchData to copy from. */ TouchData( const TouchData& other ); @@ -87,7 +88,7 @@ public: * @brief Assignment Operator * * @SINCE_1_1.37 - * @param[in] other The TouchEventHandle to copy from. + * @param[in] other The TouchData to copy from. */ TouchData& operator=( const TouchData& other ); @@ -102,12 +103,12 @@ public: unsigned long GetTime() const; /** - * @brief Returns the total number of points in this TouchEventHandle. + * @brief Returns the total number of points in this TouchData. * * @SINCE_1_1.37 * @return Total number of Points. */ - size_t GetPointCount() const; + std::size_t GetPointCount() const; /** * @brief Returns the ID of the device used for the Point specified. @@ -120,7 +121,7 @@ public: * @return The Device ID of this point. * @note If point is greater than GetPointCount() then this method will return -1. */ - int32_t GetDeviceId( size_t point ) const; + int32_t GetDeviceId( std::size_t point ) const; /** * @brief Retrieves the State of the point specified. @@ -128,11 +129,10 @@ public: * @SINCE_1_1.37 * @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. + * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED. * @see State */ - PointState::Type GetState( size_t point ) const; + PointState::Type GetState( std::size_t point ) const; /** * @brief Retrieve the actor that was underneath the point specified. @@ -140,10 +140,9 @@ public: * @SINCE_1_1.37 * @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. + * @note If point is greater than GetPointCount() then this method will return an empty handle. */ - Actor GetHitActor( size_t point ) const; + Actor GetHitActor( std::size_t point ) const; /** * @brief Retrieve the co-ordinates relative to the top-left of the hit-actor at the point specified. @@ -157,7 +156,7 @@ public: * then you should use Actor::ScreenToLocal(). * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO. */ - const Vector2& GetLocalPosition( size_t point ) const; + 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. @@ -167,7 +166,54 @@ public: * @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( size_t point ) const; + const Vector2& GetScreenPosition( std::size_t point ) const; + + /** + * @brief Retrieve the radius of the press point. + * + * This is the average of both the horizontal and vertical radii of the press point. + * + * @SINCE_1_1.39 + * @param[in] point The point required. + * @return The radius of the press point. + * @note If point is greater than GetPointCount() then this method will return 0.0f. + */ + float GetRadius( std::size_t point ) const; + + /** + * @brief Retrieve BOTH the horizontal and the vertical radii of the press point. + * + * @SINCE_1_1.39 + * @param[in] point The point required. + * @return The horizontal and vertical radii of the press point. + * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO. + */ + const Vector2& GetEllipseRadius( std::size_t point ) const; + + /** + * @brief Retrieve the touch pressure. + * + * The pressure range starts at 0.0f. + * Normal pressure is defined as 1.0f. + * A value between 0.0f and 1.0f means light pressure has been applied. + * A value greater than 1.0f means more pressure than normal has been applied. + * + * @SINCE_1_1.39 + * @param[in] point The point required. + * @return The touch pressure. + * @note If point is greater than GetPointCount() then this method will return 1.0f. + */ + float GetPressure( std::size_t point ) const; + + /** + * @brief Retrieve the angle of the press point relative to the Y-Axis. + * + * @SINCE_1_1.39 + * @param[in] point The point required. + * @return The angle of the press point. + * @note If point is greater than GetPointCount() then this method will return Degree(). + */ + Degree GetAngle( std::size_t point ) const; public: // Not intended for application developers diff --git a/dali/public-api/events/touch-event.h b/dali/public-api/events/touch-event.h index e7d9926..92b6988 100644 --- a/dali/public-api/events/touch-event.h +++ b/dali/public-api/events/touch-event.h @@ -30,7 +30,7 @@ namespace Dali */ /** - * @DEPRECATED_1_1.37 Use TouchEventHandle instead + * @DEPRECATED_1_1.37 Use TouchData instead * * @brief Touch events are a collection of touch points at a specific moment in time. * -- 2.7.4