TouchEventFunctor functor(data);
actor.TouchedSignal().Connect(&application, functor);
- // Emit an event within clipped area - no hit.
+ // Emit an event within clipped area - we should have a hit.
application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ // Emit an event within clipped child area - we should still have a hit.
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(40.0f, 40.0f)));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ // Now connect to the clippingChild's touch signal
+ SignalData clippingChildData;
+ TouchEventFunctor clippingChildFunctor(clippingChildData);
+ clippingChild.TouchedSignal().Connect(&application, clippingChildFunctor);
+
+ // Emit an event within clipped child area - no hit on actor, but hit on clipped child.
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(40.0f, 40.0f)));
+ DALI_TEST_EQUALS(true, clippingChildData.functorCalled, TEST_LOCATION);
DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
data.Reset();
+ clippingChildData.Reset();
// Emit an event outside the clipped area but within the actor area, we should have a hit.
application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(60.0f, 60.0f)));
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
data.Reset();
+ clippingChildData.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.
+ // Emit an event inside part of the child which is within the clipped area, we should have a hit on the clipped child but not the actor.
application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(30.0f, 30.0f)));
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(true, clippingChildData.functorCalled, TEST_LOCATION);
data.Reset();
+ clippingChildData.Reset();
END_TEST;
}
SignalData parentData;
TouchEventFunctor parentFunctor(parentData, false /* Do not consume */);
parent.TouchedSignal().Connect(&application, parentFunctor);
+
+ // Emit a down signal
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
+
+ data.Reset();
+ parentData.Reset();
+
// Connect to parent's intercept touched signal
SignalData interceptData;
TouchEventFunctor interceptFunctor(interceptData, true /* Do intercept */);
// Emit a down signal
application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
- // The actor touched signal is not called because the touch is intercepted in the parent.
- DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+
+ // The actor gets interrupted. Because touch is intercepted by parent.
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
DALI_TEST_EQUALS(true, interceptData.functorCalled, TEST_LOCATION);
DALI_TEST_EQUALS(PointState::DOWN, interceptData.receivedTouch.points[0].state, TEST_LOCATION);
DALI_TEST_CHECK(actor == interceptData.receivedTouch.points[0].hitActor);
END_TEST;
}
-int UtcDaliTouchArea(void)
+int UtcDaliTouchAreaOffset(void)
{
TestApplication application;
data.Reset();
// set a bigger touch area
- actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(200.0f, 200.0f));
+ actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(-70, 70, 70, -70)); // left, right, bottom, top
// Render and notify
application.SendNotification();
application.Render();
// Emit a down signal
- application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(110.0f, 110.0f)));
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(150.0f, 150.0f)));
+ // The actor touched signal is called because the touch area is inside touchArea.
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
+ DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
+ data.Reset();
+
+ // set a offset touch area
+ actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(50, 100, -50, 0)); // left, right, bottom, top
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Emit a down signal
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(190.0f, 25.0f)));
// The actor touched signal is called because the touch area is inside touchArea.
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
data.Reset();
// set a smaller touch area
- actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(50.0f, 50.0f));
+ actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(50, 0, 0, 50));
// Render and notify
application.SendNotification();
application.Render();
// Emit a down signal
- application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(80.0f, 80.0f)));
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(40.0f, 40.0f)));
// The actor touched signal is not called because the touch area is outside touchArea.
DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
data.Reset();
// Emit a down signal
- application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(30.0f, 30.0f)));
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(90.0f, 90.0f)));
// The actor touched signal is called because the touch area is inside touchArea.
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);