#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/pan-gesture-event.h>
#include <dali/integration-api/system-overlay.h>
+#include <dali/integration-api/profiling.h>
#include <dali-test-suite-utils.h>
+#include <test-touch-utils.h>
using namespace Dali;
typedef Dali::PanGestureDetector::AngleContainer::size_type AngleSizeType;
-// Stores data that is populated in the callback and will be read by the TET cases
+// Stores data that is populated in the callback and will be read by the test cases
struct SignalData
{
SignalData()
Vector2 screenPosition;
Vector2 screenDisplacement;
+ Vector2 screenVelocity;
Vector2 localPosition;
Vector2 localDisplacement;
+ Vector2 localVelocity;
bool called;
void Reset()
{
- screenPosition = screenDisplacement = localPosition = localDisplacement = Vector2::ZERO;
+ screenPosition = screenDisplacement = screenVelocity = localPosition = localDisplacement = localVelocity = Vector2::ZERO;
called = false;
}
};
Vector3 operator()(const Vector3& current,
const PropertyInput& screenPositionProperty,
const PropertyInput& screenDisplacementProperty,
+ const PropertyInput& screenVelocityProperty,
const PropertyInput& localPositionProperty,
- const PropertyInput& localDisplacementProperty)
+ const PropertyInput& localDisplacementProperty,
+ const PropertyInput& localVelocityProperty)
{
constraintData.screenPosition = screenPositionProperty.GetVector2();
constraintData.screenDisplacement = screenDisplacementProperty.GetVector2();
+ constraintData.screenVelocity = screenVelocityProperty.GetVector2();
constraintData.localPosition = localPositionProperty.GetVector2();
constraintData.localDisplacement = localDisplacementProperty.GetVector2();
+ constraintData.localVelocity = localVelocityProperty.GetVector2();
constraintData.called = true;
return Vector3::ZERO;
}
Vector2 localPosition,
Vector2 screenDisplacement = Vector2::ONE,
Vector2 localDisplacement = Vector2::ONE,
- Vector2 velocity = Vector2::ONE,
+ Vector2 screenVelocity = Vector2::ONE,
+ Vector2 localVelocity = Vector2::ONE,
unsigned int numberOfTouches = 1 )
{
PanGesture pan( state );
pan.screenDisplacement = screenDisplacement;
pan.displacement = localDisplacement;
- pan.screenVelocity = pan.velocity = velocity;
+ pan.screenVelocity = screenVelocity;
+ pan.velocity = localVelocity;
+
pan.numberOfTouches = numberOfTouches;
return pan;
// Start pan within the actor's area
application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliPanGestureBehindTouchableSystemOverlay(void)
+{
+ TestApplication application;
+ Dali::Integration::Core& core = application.GetCore();
+ Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
+ systemOverlay.GetOverlayRenderTasks().CreateTask();
+
+ // SystemOverlay actor
+ Actor systemOverlayActor = Actor::New();
+ systemOverlayActor.SetSize(100.0f, 100.0f);
+ systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ systemOverlay.Add(systemOverlayActor);
+
+ // Stage actor
+ Actor stageActor = Actor::New();
+ stageActor.SetSize(100.0f, 100.0f);
+ stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(stageActor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set system-overlay actor to touchable
+ TouchEventData touchData;
+ TouchEventDataFunctor touchFunctor( touchData );
+ systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
+
+ // Set stage actor to receive the gesture
+ SignalData data;
+ GestureReceivedFunctor functor(data);
+
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach(stageActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ Vector2 screenCoordsStart( 10.0f, 20.0f );
+ Vector2 screenCoordsEnd( 20.0f, 20.0f );
+
+ // Start pan within the two actors' area
+ application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
+ application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
+ application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
+
+ data.Reset();
+ touchData.Reset();
+
+ // Do touch in the same area
+ application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
+ DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPanGestureTouchBehindGesturedSystemOverlay(void)
+{
+ TestApplication application;
+ Dali::Integration::Core& core = application.GetCore();
+ Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
+ systemOverlay.GetOverlayRenderTasks().CreateTask();
+
+ // SystemOverlay actor
+ Actor systemOverlayActor = Actor::New();
+ systemOverlayActor.SetSize(100.0f, 100.0f);
+ systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ systemOverlay.Add(systemOverlayActor);
+
+ // Stage actor
+ Actor stageActor = Actor::New();
+ stageActor.SetSize(100.0f, 100.0f);
+ stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(stageActor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set stage actor to touchable
+ TouchEventData touchData;
+ TouchEventDataFunctor touchFunctor( touchData );
+ stageActor.TouchedSignal().Connect(&application, touchFunctor);
+
+ // Set system-overlay actor to have the gesture
+ SignalData data;
+ GestureReceivedFunctor functor(data);
+
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach(systemOverlayActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ Vector2 screenCoordsStart( 10.0f, 20.0f );
+ Vector2 screenCoordsEnd( 20.0f, 20.0f );
+
+ // Start pan within the two actors' area
+ application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
+ application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
+ application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
+
+ data.Reset();
+ touchData.Reset();
+
+ // Do touch in the same area
+ application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
END_TEST;
}
{
TestApplication application;
TestRenderController& renderController( application.GetRenderController() );
+ Integration::SetPanGesturePredictionMode(0);
Actor actor = Actor::New();
actor.SetSize(100.0f, 100.0f);
ConstraintData constraintData;
actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
+ Source( detector, PanGestureDetector::SCREEN_VELOCITY ),
Source( detector, PanGestureDetector::LOCAL_POSITION ),
Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
+ Source( detector, PanGestureDetector::LOCAL_VELOCITY ),
PanConstraint( constraintData ) ) );
// Render and notify
Vector2 screenPosition( 20.0f, 20.0f );
Vector2 screenDisplacement( 1.0f, 1.0f );
+ Vector2 screenVelocity( 1.3f, 4.0f );
Vector2 localPosition( 21.0f, 21.0f );
Vector2 localDisplacement( 0.5f, 0.5f );
+ Vector2 localVelocity( 1.5f, 2.5f );
- PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition, screenDisplacement, localDisplacement ) );
+ PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition, screenDisplacement, localDisplacement, screenVelocity, localVelocity ) );
DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), true, TEST_LOCATION );
// Render and notify
DALI_TEST_EQUALS( constraintData.localPosition, localPosition, TEST_LOCATION );
DALI_TEST_EQUALS( constraintData.screenDisplacement, screenDisplacement, TEST_LOCATION );
DALI_TEST_EQUALS( constraintData.localDisplacement, localDisplacement, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.screenVelocity, screenVelocity, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.localVelocity, localVelocity, TEST_LOCATION );
constraintData.Reset();
END_TEST;
}
int UtcDaliPanGestureSetPropertiesAlreadyPanning(void)
{
TestApplication application;
+ Integration::SetPanGesturePredictionMode(0);
Actor actor = Actor::New();
actor.SetSize(100.0f, 100.0f);
ConstraintData constraintData;
actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
+ Source( detector, PanGestureDetector::SCREEN_VELOCITY ),
Source( detector, PanGestureDetector::LOCAL_POSITION ),
Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
+ Source( detector, PanGestureDetector::LOCAL_VELOCITY ),
PanConstraint( constraintData ) ) );
// Render and notify
DALI_TEST_EQUALS( indices.size(), detector.GetPropertyCount(), TEST_LOCATION );
END_TEST;
}
+
+int UtcDaliPanGestureLayerConsumesTouch(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(actor);
+
+ // Add a pan detector
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach( actor );
+ SignalData data;
+ GestureReceivedFunctor functor( data );
+ detector.DetectedSignal().Connect( &application, functor );
+
+ // 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.RaiseToTop();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Emit signals, should receive
+ application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ // Set layer to consume all touch
+ layer.SetTouchConsumed( true );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Emit the same signals again, should not receive
+ application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ END_TEST;
+}