/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <stdlib.h>
#include <dali/public-api/dali-core.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/system-overlay.h>
+#include <dali/integration-api/render-task-list-integ.h>
#include <dali-test-suite-utils.h>
+#include <dali/devel-api/events/touch-data-devel.h>
using namespace Dali;
}
};
-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;
}
TestApplication application;
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
// Emit a down signal
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
+ const TouchPoint *point1 = &data.touchEvent.GetPoint(0);
DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
- DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
- DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
- DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
+ DALI_TEST_EQUALS( TouchPoint::Down, point1->state, TEST_LOCATION );
+ DALI_TEST_EQUALS( screenCoordinates, point1->screen, TEST_LOCATION );
+ DALI_TEST_EQUALS( localCoordinates, point1->local, 0.1f, TEST_LOCATION );
data.Reset();
// Emit a motion signal
screenCoordinates.x = screenCoordinates.y = 11.0f;
actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) );
+ const TouchPoint *point2 = &data.touchEvent.GetPoint(0);
DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
- DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
- DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
- DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
+ DALI_TEST_EQUALS( TouchPoint::Motion, point2->state, TEST_LOCATION );
+ DALI_TEST_EQUALS( screenCoordinates, point2->screen, TEST_LOCATION );
+ DALI_TEST_EQUALS( localCoordinates, point2->local, 0.1f, TEST_LOCATION );
data.Reset();
// 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 ) );
+
+ const TouchPoint *point3ptr = &data.touchEvent.GetPoint(0);
+ TouchPoint point3( point3ptr->deviceId, point3ptr->state, point3ptr->screen.x, point3ptr->screen.y, point3ptr->local.x, point3ptr->local.y );
+
DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
- DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION );
- DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
- DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
+ DALI_TEST_EQUALS( TouchPoint::Up, point3.state, TEST_LOCATION );
+ DALI_TEST_EQUALS( screenCoordinates, point3.screen, TEST_LOCATION );
+ DALI_TEST_EQUALS( localCoordinates, point3.local, 0.1f, TEST_LOCATION );
data.Reset();
// Emit a down signal where the actor is not present
{
TestApplication application;
- Stage stage = Stage::GetCurrent();
- Vector2 stageSize = stage.GetSize();
+ Integration::Scene scene = application.GetScene();
+ Vector2 sceneSize = scene.GetSize();
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::CENTER);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- stage.Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ scene.Add(actor);
// Render and notify
application.SendNotification();
application.Render();
// Get the camera's near and far planes
- RenderTaskList taskList = stage.GetRenderTaskList();
+ RenderTaskList taskList = scene.GetRenderTaskList();
Dali::RenderTask task = taskList.GetTask(0);
CameraActor camera = task.GetCameraActor();
float nearPlane = camera.GetNearClippingPlane();
// Calculate the current distance of the actor from the camera
float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
- float distance = (stageSize.y * 0.5f) / tanHalfFov;
+ float distance = (sceneSize.y * 0.5f) / tanHalfFov;
// Connect to actor's touched signal
SignalData data;
TouchEventFunctor functor( data );
actor.TouchedSignal().Connect( &application, functor );
- Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
+ Vector2 screenCoordinates( sceneSize.x * 0.5f, sceneSize.y * 0.5f );
// Emit a down signal
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
data.Reset();
// Emit a down signal where actor is just at the camera's near plane
- actor.SetZ(distance - nearPlane);
+ actor.SetProperty( Actor::Property::POSITION_Z, distance - nearPlane);
// Render and notify
application.SendNotification();
data.Reset();
// Emit a down signal where actor is closer than the camera's near plane
- actor.SetZ((distance - nearPlane) + 1.0f);
+ actor.SetProperty( Actor::Property::POSITION_Z, (distance - nearPlane) + 1.0f);
// Render and notify
application.SendNotification();
data.Reset();
// Emit a down signal where actor is just at the camera's far plane
- actor.SetZ(distance - farPlane);
+ actor.SetProperty( Actor::Property::POSITION_Z, distance - farPlane);
// Render and notify
application.SendNotification();
data.Reset();
// Emit a down signal where actor is further than the camera's far plane
- actor.SetZ((distance - farPlane) - 1.0f);
+ actor.SetProperty( Actor::Property::POSITION_Z, (distance - farPlane) - 1.0f);
// Render and notify
application.SendNotification();
TestApplication application;
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
int UtcDaliTouchParentConsumer(void)
{
TestApplication application;
- Actor rootActor( Stage::GetCurrent().GetRootLayer() );
+ Actor rootActor( application.GetScene().GetRootLayer() );
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
int UtcDaliTouchInterruptedParentConsumer(void)
{
TestApplication application;
- Actor rootActor( Stage::GetCurrent().GetRootLayer() );
+ Actor rootActor( application.GetScene().GetRootLayer() );
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
data.Reset();
rootData.Reset();
- // Remove actor from Stage
- Stage::GetCurrent().Remove( actor );
+ // Remove actor from scene
+ application.GetScene().Remove( actor );
data.Reset();
rootData.Reset();
TestApplication application;
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
actor.TouchedSignal().Connect( &application, functor );
// Set actor to require leave events
- actor.SetLeaveRequired( true );
+ actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
// Emit a down signal
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
data.Reset();
// We do not want to listen to leave events anymore
- actor.SetLeaveRequired( false );
+ actor.SetProperty( Actor::Property::LEAVE_REQUIRED, false );
// Another motion event outside of actor, no signalling
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
int UtcDaliTouchLeaveParentConsumer(void)
{
TestApplication application;
- Actor rootActor( Stage::GetCurrent().GetRootLayer() );
+ Actor rootActor( application.GetScene().GetRootLayer() );
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
rootActor.TouchedSignal().Connect( &application, rootFunctor );
// Set actor to require leave events
- actor.SetLeaveRequired( true );
- rootActor.SetLeaveRequired( true );
+ actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
+ rootActor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
// Emit a down signal
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
rootData.Reset();
// We do not want to listen to leave events of actor anymore
- actor.SetLeaveRequired( false );
+ actor.SetProperty( Actor::Property::LEAVE_REQUIRED, false );
// 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 )) );
+ Vector2 sceneSize( application.GetScene().GetSize() );
+ application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( sceneSize.width + 10.0f, sceneSize.height + 10.0f )) );
DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION );
TestApplication application;
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
data.Reset();
// Change actor to insensitive
- actor.SetSensitive( false );
+ actor.SetProperty( Actor::Property::SENSITIVE, false );
// Emit a motion signal, signalled with an interrupted
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
int UtcDaliTouchActorBecomesInsensitiveParentConsumer(void)
{
TestApplication application;
- Actor rootActor( Stage::GetCurrent().GetRootLayer() );
+ Actor rootActor( application.GetScene().GetRootLayer() );
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
application.Render();
// Make root actor insensitive
- rootActor.SetSensitive( false );
+ rootActor.SetProperty( Actor::Property::SENSITIVE, 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 )) );
int UtcDaliTouchMultipleLayers(void)
{
TestApplication application;
- Actor rootActor( Stage::GetCurrent().GetRootLayer() );
+ Actor rootActor( application.GetScene().GetRootLayer() );
// Connect to actor's touched signal
SignalData data;
TouchEventFunctor functor( data );
Layer layer1 ( Layer::New() );
- layer1.SetSize(100.0f, 100.0f);
- layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add( layer1 );
+ layer1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ layer1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add( layer1 );
Actor actor1 ( Actor::New() );
- actor1.SetSize( 100.0f, 100.0f );
- actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
+ actor1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ actor1.SetProperty( Actor::Property::POSITION_Z, 1.0f ); // Should hit actor1 in this layer
layer1.Add( actor1 );
// Render and notify
data.Reset();
// Make layer1 insensitive, nothing should be hit
- layer1.SetSensitive( false );
+ layer1.SetProperty( Actor::Property::SENSITIVE, false );
application.ProcessEvent( GenerateSingleTouch( TouchPoint::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 );
+ layer1.SetProperty( Actor::Property::SENSITIVE, true );
application.ProcessEvent( GenerateSingleTouch( TouchPoint::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 );
+ rootActor.SetProperty( Actor::Property::SENSITIVE, false );
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
data.Reset();
// Make rootActor sensitive
- rootActor.SetSensitive( true );
+ rootActor.SetProperty( Actor::Property::SENSITIVE, true );
// Add another layer
Layer layer2 ( Layer::New() );
- layer2.SetSize(100.0f, 100.0f );
- layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
- Stage::GetCurrent().Add( layer2 );
+ layer2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ layer2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ layer2.SetProperty( Actor::Property::POSITION_Z, 10.0f ); // Should hit layer2 in this layer rather than actor2
+ application.GetScene().Add( layer2 );
Actor actor2 ( Actor::New() );
- actor2.SetSize(100.0f, 100.0f);
- actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
layer2.Add( actor2 );
// Render and notify
data.Reset();
// Make layer2 insensitive, should hit actor1
- layer2.SetSensitive( false );
+ layer2.SetProperty( Actor::Property::SENSITIVE, false );
application.ProcessEvent( GenerateSingleTouch( TouchPoint::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 );
+ layer2.SetProperty( Actor::Property::SENSITIVE, true );
application.ProcessEvent( GenerateSingleTouch( TouchPoint::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 invisible, render and notify
- layer2.SetVisible( false );
+ layer2.SetProperty( Actor::Property::VISIBLE, false );
application.SendNotification();
application.Render();
data.Reset();
// Make rootActor invisible, render and notify
- rootActor.SetVisible( false );
+ rootActor.SetProperty( Actor::Property::VISIBLE, false );
application.SendNotification();
application.Render();
int UtcDaliTouchMultipleRenderTasks(void)
{
TestApplication application;
- Stage stage ( Stage::GetCurrent() );
- Vector2 stageSize ( stage.GetSize() );
+ Integration::Scene scene ( application.GetScene() );
+ Vector2 sceneSize ( scene.GetSize() );
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- stage.Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ scene.Add(actor);
// Create render task
- Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
- RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
+ Viewport viewport( sceneSize.width * 0.5f, sceneSize.height * 0.5f, sceneSize.width * 0.5f, sceneSize.height * 0.5f );
+ RenderTask renderTask ( application.GetScene().GetRenderTaskList().CreateTask() );
renderTask.SetViewport( viewport );
renderTask.SetInputEnabled( true );
int UtcDaliTouchMultipleRenderTasksWithChildLayer(void)
{
TestApplication application;
- Stage stage ( Stage::GetCurrent() );
- Vector2 stageSize ( stage.GetSize() );
+ Integration::Scene scene ( application.GetScene() );
+ Vector2 sceneSize ( scene.GetSize() );
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- stage.Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ scene.Add(actor);
Layer layer = Layer::New();
- layer.SetSize(100.0f, 100.0f);
- layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
actor.Add(layer);
// Create render task
- Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
- RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
+ Viewport viewport( sceneSize.width * 0.5f, sceneSize.height * 0.5f, sceneSize.width * 0.5f, sceneSize.height * 0.5f );
+ RenderTask renderTask ( application.GetScene().GetRenderTaskList().CreateTask() );
renderTask.SetViewport( viewport );
renderTask.SetInputEnabled( true );
renderTask.SetSourceActor( actor );
int UtcDaliTouchOffscreenRenderTasks(void)
{
TestApplication application;
- Stage stage ( Stage::GetCurrent() );
- Vector2 stageSize ( stage.GetSize() );
+ Integration::Scene scene ( application.GetScene() );
+ Vector2 sceneSize ( scene.GetSize() );
- // FrameBufferImage for offscreen RenderTask
- FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
+ // FrameBuffer for offscreen RenderTask
+ FrameBuffer frameBuffer = FrameBuffer::New( sceneSize.width, sceneSize.height );
- // Create an image actor to display the FrameBufferImage
- ImageActor imageActor ( ImageActor::New( frameBufferImage ) );
- imageActor.SetParentOrigin(ParentOrigin::CENTER);
- imageActor.SetSize( stageSize.x, stageSize.y );
- imageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
- stage.Add( imageActor );
+ // Create a renderable actor to display the FrameBufferImage
+ Actor renderableActor = CreateRenderableActor(frameBuffer.GetColorTexture());
+ renderableActor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ renderableActor.SetProperty( Actor::Property::SIZE, Vector2( sceneSize.x, sceneSize.y ) );
+ renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
+ scene.Add( renderableActor );
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- stage.Add( actor );
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ scene.Add( actor );
application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
- stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
+ scene.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
// Create a RenderTask
- RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
+ RenderTask renderTask = scene.GetRenderTaskList().CreateTask();
renderTask.SetSourceActor( actor );
- renderTask.SetTargetFrameBuffer( frameBufferImage );
+ renderTask.SetFrameBuffer( frameBuffer );
renderTask.SetInputEnabled( true );
// Create another RenderTask
- RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
+ RenderTask renderTask2( scene.GetRenderTaskList().CreateTask() );
renderTask2.SetInputEnabled( true );
// Render and notify
END_TEST;
}
+int UtcDaliTouchRenderTaskWithExclusiveActor(void)
+{
+ TestApplication application;
+ auto scene = application.GetScene();
+ auto sceneSize( scene.GetSize() );
+
+ auto actor = CreateRenderableActor();
+ actor.SetProperty( Actor::Property::SIZE, Vector2( sceneSize.x, sceneSize.y ) );
+ scene.Add( actor );
+
+ auto renderTask = scene.GetRenderTaskList().CreateTask();
+ renderTask.SetSourceActor( actor );
+ renderTask.SetExclusive( true );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Connect to actor's touched signal
+ SignalData data;
+ TouchEventFunctor functor( data );
+ actor.TouchedSignal().Connect( &application, functor );
+
+ // Emit a down signal
+ application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ data.Reset();
+
+ END_TEST;
+}
+
int UtcDaliTouchMultipleRenderableActors(void)
{
TestApplication application;
- Stage stage ( Stage::GetCurrent() );
- Vector2 stageSize ( stage.GetSize() );
-
- ImageActor parent = ImageActor::New();
- parent.SetSize(100.0f, 100.0f);
- parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- stage.Add(parent);
-
- ImageActor actor = ImageActor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- actor.SetSortModifier( 1.0f );
+ Integration::Scene scene ( application.GetScene() );
+ Vector2 sceneSize ( scene.GetSize() );
+
+ Actor parent = CreateRenderableActor();
+ parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ scene.Add(parent);
+
+ Actor actor = CreateRenderableActor();
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
parent.Add(actor);
// Render and notify
TestApplication application;
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
actor.TouchedSignal().Connect( &application, functor );
// Register for leave events
- actor.SetLeaveRequired( true );
+ actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
// Emit a down signal
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
data.Reset();
// Re-add, render and notify
- Stage::GetCurrent().Add(actor);
+ application.GetScene().Add(actor);
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
data.Reset();
- // Re-add actor back to stage, render and notify
- Stage::GetCurrent().Add(actor);
+ // Re-add actor back to scene, render and notify
+ application.GetScene().Add(actor);
application.SendNotification();
application.Render();
TestApplication application;
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
END_TEST;
}
-int UtcDaliTouchActorUnStaged(void)
+int UtcDaliTouchActorRemovedFromScene(void)
{
TestApplication application;
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
data.Reset();
- // Remove actor from stage
- Stage::GetCurrent().Remove( actor );
+ // Remove actor from scene
+ application.GetScene().Remove( actor );
data.Reset();
// Render and notify
END_TEST;
}
-int UtcDaliTouchSystemOverlayActor(void)
-{
- TestApplication application;
- Dali::Integration::Core& core( application.GetCore() );
- Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
- systemOverlay.GetOverlayRenderTasks().CreateTask();
-
- // Create an actor and add it to the system overlay.
- Actor systemActor = Actor::New();
- systemActor.SetSize(100.0f, 100.0f);
- systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- systemOverlay.Add( systemActor );
-
- // Create an actor and add it to the stage as per normal, same position and size as systemActor
- Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
-
- // Connect to the touch signals.
- SignalData data;
- TouchEventFunctor functor( data );
- systemActor.TouchedSignal().Connect( &application, functor );
- actor.TouchedSignal().Connect( &application, functor );
-
- // Render and notify
- application.SendNotification();
- 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 ) ) );
- DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
- DALI_TEST_CHECK( systemActor == data.touchedActor );
- END_TEST;
-}
-
int UtcDaliTouchLayerConsumesTouch(void)
{
TestApplication application;
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
// Add a layer to overlap the actor
Layer layer = Layer::New();
- layer.SetSize(100.0f, 100.0f);
- layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add( layer );
+ layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add( layer );
layer.RaiseToTop();
// Render and notify
data.Reset();
// Set layer to consume all touch
- layer.SetTouchConsumed( true );
+ layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
// Render and notify
application.SendNotification();
int UtcDaliTouchLeaveActorReadded(void)
{
TestApplication application;
- Stage stage = Stage::GetCurrent();
+ Integration::Scene scene = application.GetScene();
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- stage.Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ scene.Add(actor);
// Set actor to receive touch-events
- actor.SetLeaveRequired( true );
+ actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
// Render and notify
application.SendNotification();
DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
data.Reset();
- // Remove actor from stage and add again
- stage.Remove( actor );
- stage.Add( actor );
+ // Remove actor from scene and add again
+ scene.Remove( actor );
+ scene.Add( actor );
// Emit a motion within the actor's bounds
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 12.0f, 10.0f ) ) );
END_TEST;
}
-int UtcDaliTouchStencilNonRenderableActor(void)
+int UtcDaliTouchClippingActor(void)
{
TestApplication application;
- Stage stage = Stage::GetCurrent();
+ Integration::Scene scene = application.GetScene();
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- stage.Add(actor);
-
- Actor stencil = Actor::New();
- stencil.SetSize(50.0f, 50.0f);
- stencil.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- stencil.SetDrawMode( DrawMode::STENCIL );
- stage.Add(stencil);
-
- // Render and notify
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ scene.Add( actor );
+
+ Actor clippingActor = Actor::New();
+ clippingActor.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) );
+ clippingActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ clippingActor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+ scene.Add( clippingActor );
+
+ // Add a child to the clipped region.
+ Actor clippingChild = Actor::New();
+ clippingChild.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) );
+ clippingChild.SetProperty( Actor::Property::POSITION, Vector2( 25.0f, 25.0f ));
+ clippingChild.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ clippingActor.Add( clippingChild );
+
+ // Render and notify.
application.SendNotification();
application.Render();
- // Connect to actor's touched signal
+ // Connect to actor's touched signal.
SignalData data;
TouchEventFunctor functor( data );
actor.TouchedSignal().Connect( &application, functor );
- // Emit an event within stencil area
+ // Emit an event within clipped area - no hit.
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
- DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
data.Reset();
- // Emit an event outside the stencil area but within the actor area, we should have a hit!
+ // Emit an event outside the clipped area but within the actor area, we should have a hit.
application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 60.0f, 60.0f ) ) );
DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
data.Reset();
+ clippingChild.TouchedSignal().Connect( &application, functor );
+
+ // Emit an event inside part of the child which is within the clipped area, we should have a hit.
+ application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 30.0f, 30.0f ) ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ data.Reset();
+
END_TEST;
}
-int UtcDaliTouchActorUnstaged(void)
+int UtcDaliTouchActorUnparented(void)
{
TestApplication application;
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
// Render and notify
application.SendNotification();
END_TEST;
}
-int UtcDaliTouchParentUnstaged(void)
+int UtcDaliTouchParentRemovedFromScene(void)
{
TestApplication application;
Actor parent = Actor::New();
- parent.SetSize(100.0f, 100.0f);
- parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(parent);
+ parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(parent);
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
parent.Add(actor);
// Render and notify
END_TEST;
}
-int UtcDaliTouchActorUnstagedDifferentConsumer(void)
+int UtcDaliTouchActorRemovedFromSceneDifferentConsumer(void)
{
TestApplication application;
Actor parent = Actor::New();
- parent.SetSize(100.0f, 100.0f);
- parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(parent);
+ parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(parent);
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
parent.Add(actor);
// Render and notify
int UtcDaliTouchInterruptedDifferentConsumer(void)
{
TestApplication application;
- Actor rootActor( Stage::GetCurrent().GetRootLayer() );
+ Actor rootActor( application.GetScene().GetRootLayer() );
Actor parent = Actor::New();
- parent.SetSize(100.0f, 100.0f);
- parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(parent);
+ parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(parent);
Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
parent.Add(actor);
// Render and notify
END_TEST;
}
+
+int UtcDaliTouchDataConvert(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Connect to actor's touch signal
+ SignalData data;
+ TouchEventFunctor functor(data);
+ actor.TouchedSignal().Connect(&application, functor);
+
+ Vector2 screenCoordiantes(10.0f, 10.0f);
+ Vector2 localCoordinates;
+ actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordiantes.x, screenCoordiantes.y);
+
+ // Emit a down signal
+ application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordiantes));
+ Dali::TouchData touchData = Dali::DevelTouchData::Convert(data.touchEvent);
+
+ DALI_TEST_EQUALS( 1u, touchData.GetPointCount(), TEST_LOCATION );
+ DALI_TEST_EQUALS( screenCoordiantes, touchData.GetScreenPosition(0), TEST_LOCATION );
+ DALI_TEST_EQUALS( localCoordinates, touchData.GetLocalPosition(0), 0.1f, TEST_LOCATION );
+ DALI_TEST_EQUALS( PointState::DOWN, touchData.GetState(0), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor, touchData.GetHitActor(0), TEST_LOCATION );
+
+ data.Reset();
+
+ END_TEST;
+
+}