[problem] Cannot tap anything behind invisible status bar.
[cause] Status bar consumes all gestures even though it doesn't require them.
[solution] Change the system so that actors are aware of what gestures they have so it is
possible to gesture actors behind the status bar.
Change-Id: I713c907c764445263362803a98af0fa514ffd955
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
utc-Dali-Constraint.cpp
utc-Dali-CustomActor.cpp
utc-Dali-Degree.cpp
- utc-Dali-EventProcessing.cpp
utc-Dali-Font.cpp
utc-Dali-FontParameters.cpp
utc-Dali-FrameBufferImage.cpp
--- /dev/null
+#ifndef _TEST_TOUCH_UTILS_H_
+#define _TEST_TOUCH_UTILS_H_
+
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://floralicense.org/license/
+//
+// 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.
+//
+
+#include <dali/public-api/actors/actor.h>
+
+namespace Dali
+{
+
+// Data for touch events
+struct TouchEventData
+{
+ TouchEventData()
+ : functorCalled(false),
+ receivedTouch(),
+ touchActor()
+ {
+ }
+
+ void Reset()
+ {
+ functorCalled = false;
+
+ receivedTouch.points.clear();
+ receivedTouch.time = 0;
+
+ touchActor = NULL;
+ }
+
+ bool functorCalled;
+ TouchEvent receivedTouch;
+ Actor touchActor;
+};
+
+// Functor that sets the data when called
+struct TouchEventDataFunctor
+{
+ TouchEventDataFunctor(TouchEventData& data) : touchEventData(data) { }
+
+ bool operator()(Actor actor, const TouchEvent& touch)
+ {
+ touchEventData.functorCalled = true;
+ touchEventData.touchActor = actor;
+ touchEventData.receivedTouch = touch;
+ return false;
+ }
+
+ // Generate a touch-event
+ Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, Vector2 screenPosition ) const
+ {
+ Integration::TouchEvent touchEvent;
+ touchEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) );
+ return touchEvent;
+ }
+
+ TouchEventData& touchEventData;
+};
+
+
+} // namespace Dali
+
+#endif // _TEST_TOUCH_UTILS_H_
extern void custom_actor_test_cleanup(void);
extern void utc_dali_degree_startup(void);
extern void utc_dali_degree_cleanup(void);
-extern void utc_dali_event_processing_startup(void);
-extern void utc_dali_event_processing_cleanup(void);
extern void utc_dali_font_startup(void);
extern void utc_dali_font_cleanup(void);
extern void utc_dali_font_parameters_startup(void);
extern int UtcDaliDegreeCastOperatorEquals(void);
extern int UtcDaliDegreeCastOperatorNotEquals(void);
extern int UtcDaliDegreeCastOperatorLessThan(void);
-extern int UtcDaliInvalidEvent(void);
-extern int UtcDaliInvalidGesture(void);
extern int UtcDaliFontNew01(void);
extern int UtcDaliFontNew02(void);
extern int UtcDaliFontNew03(void);
extern int UtcDaliLongPressGestureActorUnstaged(void);
extern int UtcDaliLongPressGestureActorStagedAndDestroyed(void);
extern int UtcDaliLongPressGestureSystemOverlay(void);
+extern int UtcDaliLongPressGestureBehindTouchableSystemOverlay(void);
+extern int UtcDaliLongPressGestureTouchBehindGesturedSystemOverlay(void);
extern int UtcDaliMaterialNew01(void);
extern int UtcDaliMaterialDownCast(void);
extern int UtcDaliMaterialSettersAndGetters(void);
extern int UtcDaliPanGestureActorUnstaged(void);
extern int UtcDaliPanGestureActorStagedAndDestroyed(void);
extern int UtcDaliPanGestureSystemOverlay(void);
+extern int UtcDaliPanGestureBehindTouchableSystemOverlay(void);
+extern int UtcDaliPanGestureTouchBehindGesturedSystemOverlay(void);
extern int UtcDaliPanGestureAngleHandling(void);
extern int UtcDaliPanGestureAngleOutOfRange(void);
extern int UtcDaliPanGestureAngleProcessing(void);
extern int UtcDaliPinchGestureActorUnstaged(void);
extern int UtcDaliPinchGestureActorStagedAndDestroyed(void);
extern int UtcDaliPinchGestureSystemOverlay(void);
+extern int UtcDaliPinchGestureBehindTouchableSystemOverlay(void);
+extern int UtcDaliPinchGestureTouchBehindGesturedSystemOverlay(void);
extern int UtcDaliPixelHasAlpha(void);
extern int UtcDaliPixelGetBytesPerPixel(void);
extern int UtcDaliPixelGetAlphaOffsetAndMask(void);
extern int UtcDaliTapGestureDetectorRemovedWhilePossible(void);
extern int UtcDaliTapGestureActorRemovedWhilePossible(void);
extern int UtcDaliTapGestureSystemOverlay(void);
+extern int UtcDaliTapGestureBehindTouchableSystemOverlay(void);
+extern int UtcDaliTapGestureTouchBehindGesturedSystemOverlay(void);
extern int UtcDaliTextConstructor(void);
extern int UtcDaliTextCopyConstructor(void);
extern int UtcDaliTextAssignmentOperator(void);
{"UtcDaliDegreeCastOperatorEquals", UtcDaliDegreeCastOperatorEquals, utc_dali_degree_startup, utc_dali_degree_cleanup},
{"UtcDaliDegreeCastOperatorNotEquals", UtcDaliDegreeCastOperatorNotEquals, utc_dali_degree_startup, utc_dali_degree_cleanup},
{"UtcDaliDegreeCastOperatorLessThan", UtcDaliDegreeCastOperatorLessThan, utc_dali_degree_startup, utc_dali_degree_cleanup},
- {"UtcDaliInvalidEvent", UtcDaliInvalidEvent, utc_dali_event_processing_startup, utc_dali_event_processing_cleanup},
- {"UtcDaliInvalidGesture", UtcDaliInvalidGesture, utc_dali_event_processing_startup, utc_dali_event_processing_cleanup},
{"UtcDaliFontNew01", UtcDaliFontNew01, utc_dali_font_startup, utc_dali_font_cleanup},
{"UtcDaliFontNew02", UtcDaliFontNew02, utc_dali_font_startup, utc_dali_font_cleanup},
{"UtcDaliFontNew03", UtcDaliFontNew03, utc_dali_font_startup, utc_dali_font_cleanup},
{"UtcDaliLongPressGestureActorUnstaged", UtcDaliLongPressGestureActorUnstaged, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup},
{"UtcDaliLongPressGestureActorStagedAndDestroyed", UtcDaliLongPressGestureActorStagedAndDestroyed, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup},
{"UtcDaliLongPressGestureSystemOverlay", UtcDaliLongPressGestureSystemOverlay, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup},
+ {"UtcDaliLongPressGestureBehindTouchableSystemOverlay", UtcDaliLongPressGestureBehindTouchableSystemOverlay, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup},
+ {"UtcDaliLongPressGestureTouchBehindGesturedSystemOverlay", UtcDaliLongPressGestureTouchBehindGesturedSystemOverlay, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup},
{"UtcDaliMaterialNew01", UtcDaliMaterialNew01, utc_dali_material_startup, utc_dali_material_cleanup},
{"UtcDaliMaterialDownCast", UtcDaliMaterialDownCast, utc_dali_material_startup, utc_dali_material_cleanup},
{"UtcDaliMaterialSettersAndGetters", UtcDaliMaterialSettersAndGetters, utc_dali_material_startup, utc_dali_material_cleanup},
{"UtcDaliPanGestureActorUnstaged", UtcDaliPanGestureActorUnstaged, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup},
{"UtcDaliPanGestureActorStagedAndDestroyed", UtcDaliPanGestureActorStagedAndDestroyed, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup},
{"UtcDaliPanGestureSystemOverlay", UtcDaliPanGestureSystemOverlay, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup},
+ {"UtcDaliPanGestureBehindTouchableSystemOverlay", UtcDaliPanGestureBehindTouchableSystemOverlay, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup},
+ {"UtcDaliPanGestureTouchBehindGesturedSystemOverlay", UtcDaliPanGestureTouchBehindGesturedSystemOverlay, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup},
{"UtcDaliPanGestureAngleHandling", UtcDaliPanGestureAngleHandling, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup},
{"UtcDaliPanGestureAngleOutOfRange", UtcDaliPanGestureAngleOutOfRange, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup},
{"UtcDaliPanGestureAngleProcessing", UtcDaliPanGestureAngleProcessing, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup},
{"UtcDaliPinchGestureActorUnstaged", UtcDaliPinchGestureActorUnstaged, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup},
{"UtcDaliPinchGestureActorStagedAndDestroyed", UtcDaliPinchGestureActorStagedAndDestroyed, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup},
{"UtcDaliPinchGestureSystemOverlay", UtcDaliPinchGestureSystemOverlay, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup},
+ {"UtcDaliPinchGestureBehindTouchableSystemOverlay", UtcDaliPinchGestureBehindTouchableSystemOverlay, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup},
+ {"UtcDaliPinchGestureTouchBehindGesturedSystemOverlay", UtcDaliPinchGestureTouchBehindGesturedSystemOverlay, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup},
{"UtcDaliPixelHasAlpha", UtcDaliPixelHasAlpha, utc_dali_pixel_startup, utc_dali_pixel_cleanup},
{"UtcDaliPixelGetBytesPerPixel", UtcDaliPixelGetBytesPerPixel, utc_dali_pixel_startup, utc_dali_pixel_cleanup},
{"UtcDaliPixelGetAlphaOffsetAndMask", UtcDaliPixelGetAlphaOffsetAndMask, utc_dali_pixel_startup, utc_dali_pixel_cleanup},
{"UtcDaliTapGestureDetectorRemovedWhilePossible", UtcDaliTapGestureDetectorRemovedWhilePossible, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup},
{"UtcDaliTapGestureActorRemovedWhilePossible", UtcDaliTapGestureActorRemovedWhilePossible, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup},
{"UtcDaliTapGestureSystemOverlay", UtcDaliTapGestureSystemOverlay, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup},
+ {"UtcDaliTapGestureBehindTouchableSystemOverlay", UtcDaliTapGestureBehindTouchableSystemOverlay, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup},
+ {"UtcDaliTapGestureTouchBehindGesturedSystemOverlay", UtcDaliTapGestureTouchBehindGesturedSystemOverlay, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup},
{"UtcDaliTextConstructor", UtcDaliTextConstructor, utc_dali_text_startup, utc_dali_text_cleanup},
{"UtcDaliTextCopyConstructor", UtcDaliTextCopyConstructor, utc_dali_text_startup, utc_dali_text_cleanup},
{"UtcDaliTextAssignmentOperator", UtcDaliTextAssignmentOperator, utc_dali_text_startup, utc_dali_text_cleanup},
+++ /dev/null
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali/dali.h>
-#include <dali/integration-api/events/event.h>
-#include <dali/integration-api/events/gesture-event.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-void utc_dali_event_processing_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_event_processing_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-
-struct InvalidEvent : public Integration::Event
-{
- InvalidEvent() : Event( Event::Type(-1000) ) {}
- ~InvalidEvent() {}
-};
-
-struct InvalidGesture : public Integration::GestureEvent
-{
- InvalidGesture() : GestureEvent( Gesture::Type(-1000), Gesture::Clear ) {}
- ~InvalidGesture() {}
-};
-
-} // anon namespace
-
-int UtcDaliInvalidEvent(void)
-{
- TestApplication application;
-
- try
- {
- InvalidEvent event;
- application.ProcessEvent( event );
- tet_result( TET_FAIL );
- }
- catch ( Dali::DaliException& e )
- {
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliInvalidGesture(void)
-{
- TestApplication application;
-
- try
- {
- InvalidGesture event;
- application.ProcessEvent( event );
- tet_result( TET_FAIL );
- }
- catch ( Dali::DaliException& e )
- {
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
- }
- END_TEST;
-}
#include <dali/integration-api/events/long-press-gesture-event.h>
#include <dali/integration-api/system-overlay.h>
#include <dali-test-suite-utils.h>
+#include <test-touch-utils.h>
using namespace Dali;
Vector2 screenCoords( 50.0f, 50.0f );
application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, screenCoords ) );
application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, screenCoords ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliLongPressGestureBehindTouchableSystemOverlay(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);
+
+ LongPressGestureDetector detector = LongPressGestureDetector::New();
+ detector.Attach(stageActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ // Start long press within the two actors' area
+ Vector2 screenCoords( 50.0f, 50.0f );
+ application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, screenCoords ) );
+ application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, screenCoords ) );
+ 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, screenCoords ) );
DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliLongPressGestureTouchBehindGesturedSystemOverlay(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);
+
+ LongPressGestureDetector detector = LongPressGestureDetector::New();
+ detector.Attach(systemOverlayActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ // Start long press within the two actors' area
+ Vector2 screenCoords( 50.0f, 50.0f );
+ application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, screenCoords ) );
+ application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, screenCoords ) );
+ 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, screenCoords ) );
+ DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
END_TEST;
}
#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()
// 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);
int UtcDaliPanGestureSetPropertiesAlreadyPanning(void)
{
TestApplication application;
+ Integration::SetPanGesturePredictionMode(0);
Actor actor = Actor::New();
actor.SetSize(100.0f, 100.0f);
#include <dali/integration-api/events/pinch-gesture-event.h>
#include <dali/integration-api/system-overlay.h>
#include <dali-test-suite-utils.h>
+#include <test-touch-utils.h>
using namespace Dali;
// Start pan within the actor's area
application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliPinchGestureBehindTouchableSystemOverlay(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);
+
+ PinchGestureDetector detector = PinchGestureDetector::New();
+ detector.Attach(stageActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ Vector2 screenCoords( 50.0f, 50.0f );
+ float scale ( 10.0f );
+ float speed ( 50.0f );
+
+ // Start pinch within the two actors' area
+ application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
+ application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
+ 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, screenCoords ) );
DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPinchGestureTouchBehindGesturedSystemOverlay(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);
+
+ PinchGestureDetector detector = PinchGestureDetector::New();
+ detector.Attach(systemOverlayActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ Vector2 screenCoords( 50.0f, 50.0f );
+ float scale ( 10.0f );
+ float speed ( 50.0f );
+
+ // Start pinch within the two actors' area
+ application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
+ application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
+ 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, screenCoords ) );
+ DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
END_TEST;
}
#include <dali/integration-api/events/tap-gesture-event.h>
#include <dali/integration-api/system-overlay.h>
#include <dali-test-suite-utils.h>
+#include <test-touch-utils.h>
using namespace Dali;
// Do a tap inside actor's area
application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliTapGestureBehindTouchableSystemOverlay(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);
+
+ TapGestureDetector detector = TapGestureDetector::New();
+ detector.Attach(stageActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ Vector2 screenCoords( 50.0f, 50.0f );
+
+ // Do a tap inside both actors' area
+ application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
+ application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
+ 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, screenCoords ) );
+ DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTapGestureTouchBehindGesturedSystemOverlay(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);
+
+ TapGestureDetector detector = TapGestureDetector::New();
+ detector.Attach(systemOverlayActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ Vector2 screenCoords( 50.0f, 50.0f );
+
+ // Do a tap inside both actors' area
+ application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
+ application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
+ 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, screenCoords ) );
DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
END_TEST;
}
#include <dali/internal/event/dynamics/dynamics-world-impl.h>
#endif
+#include <dali/internal/event/events/pan-gesture-detector-impl.h>
+#include <dali/internal/event/events/pinch-gesture-detector-impl.h>
+#include <dali/internal/event/events/long-press-gesture-detector-impl.h>
+#include <dali/internal/event/events/tap-gesture-detector-impl.h>
+
using Dali::Internal::SceneGraph::Node;
using Dali::Internal::SceneGraph::AnimatableProperty;
using Dali::Internal::SceneGraph::PropertyBase;
unsigned int Actor::mActorCounter = 0;
ActorContainer Actor::mNullChildren;
+// Encapsulate actor related gesture information
+struct GestureData
+{
+ /**
+ * Constructor
+ */
+ GestureData()
+ : gesturesRequired( Gesture::Type( 0 ) ),
+ panDetectors( NULL ),
+ pinchDetectors( NULL ),
+ longPressDetectors( NULL ),
+ tapDetectors( NULL )
+ {
+ }
+
+ /**
+ * Destructor
+ */
+ ~GestureData()
+ {
+ delete panDetectors;
+ delete pinchDetectors;
+ delete longPressDetectors;
+ delete tapDetectors;
+ }
+
+ /**
+ * Checks if the containers in GestureData are empty
+ */
+ bool Empty() const
+ {
+ return !panDetectors &&
+ !pinchDetectors &&
+ !longPressDetectors &&
+ !tapDetectors;
+ }
+
+ /**
+ * Template to add a detector to the appropriate container. Dynamically allocates the container
+ * only if it is used.
+ */
+ template< typename DetectorType, typename ContainerType >
+ void AddDetector( ContainerType*& containerPtr, GestureDetector* detector )
+ {
+ if ( NULL == containerPtr )
+ {
+ containerPtr = new ContainerType;
+ }
+
+ containerPtr->push_back( static_cast< DetectorType* >( detector ) );
+ gesturesRequired = Gesture::Type( gesturesRequired | detector->GetType() );
+ }
+
+ /**
+ * Template to remove a detector from the appropriate container. Deletes the container if it is
+ * no longer required.
+ */
+ template< typename ContainerType >
+ void RemoveDetector( ContainerType*& containerPtr, GestureDetector* detector )
+ {
+ if ( NULL != containerPtr )
+ {
+ ContainerType& container( *containerPtr );
+ typename ContainerType::iterator match( std::remove( container.begin(), container.end(), detector ) );
+ DALI_ASSERT_DEBUG( match != container.end() && "Actor does not have the detector" );
+ container.erase( match, container.end() );
+
+ if ( container.empty() )
+ {
+ gesturesRequired = Gesture::Type( gesturesRequired & ~detector->GetType() );
+ delete containerPtr;
+ containerPtr = NULL;
+ }
+ }
+ }
+
+ Gesture::Type gesturesRequired;
+
+ PanGestureDetectorContainer* panDetectors;
+ PinchGestureDetectorContainer* pinchDetectors;
+ LongPressGestureDetectorContainer* longPressDetectors;
+ TapGestureDetectorContainer* tapDetectors;
+};
+
#ifdef DYNAMICS_SUPPORT
// Encapsulate actor related dynamics data
IsNodeConnected();
}
+void Actor::AddGestureDetector( GestureDetector& detector )
+{
+ if ( NULL == mGestureData )
+ {
+ mGestureData = new GestureData;
+ }
+
+ const Gesture::Type type( detector.GetType() );
+ switch ( type )
+ {
+ case Gesture::Pan:
+ {
+ mGestureData->AddDetector< PanGestureDetector, PanGestureDetectorContainer >( mGestureData->panDetectors, &detector );
+ break;
+ }
+
+ case Gesture::Pinch:
+ {
+ mGestureData->AddDetector< PinchGestureDetector, PinchGestureDetectorContainer >( mGestureData->pinchDetectors, &detector );
+ break;
+ }
+
+ case Gesture::LongPress:
+ {
+ mGestureData->AddDetector< LongPressGestureDetector, LongPressGestureDetectorContainer >( mGestureData->longPressDetectors, &detector );
+ break;
+ }
+
+ case Gesture::Tap:
+ {
+ mGestureData->AddDetector< TapGestureDetector, TapGestureDetectorContainer >( mGestureData->tapDetectors, &detector );
+ break;
+ }
+ }
+}
+
+void Actor::RemoveGestureDetector( GestureDetector& detector )
+{
+ if ( NULL != mGestureData )
+ {
+ switch ( detector.GetType() )
+ {
+ case Gesture::Pan:
+ {
+ mGestureData->RemoveDetector< PanGestureDetectorContainer >( mGestureData->panDetectors, &detector );
+ break;
+ }
+
+ case Gesture::Pinch:
+ {
+ mGestureData->RemoveDetector< PinchGestureDetectorContainer >( mGestureData->pinchDetectors, &detector );
+ break;
+ }
+
+ case Gesture::LongPress:
+ {
+ mGestureData->RemoveDetector< LongPressGestureDetectorContainer >( mGestureData->longPressDetectors, &detector );
+ break;
+ }
+
+ case Gesture::Tap:
+ {
+ mGestureData->RemoveDetector< TapGestureDetectorContainer >( mGestureData->tapDetectors, &detector );
+ break;
+ }
+ }
+
+ if ( mGestureData->Empty() )
+ {
+ delete mGestureData;
+ mGestureData = NULL;
+ }
+ }
+}
+
+bool Actor::IsGestureRequred( Gesture::Type type ) const
+{
+ bool required( false );
+ if ( NULL != mGestureData )
+ {
+ required = type & mGestureData->gesturesRequired;
+ }
+ return required;
+}
+
bool Actor::EmitTouchEventSignal(const TouchEvent& event)
{
bool consumed = false;
#ifdef DYNAMICS_SUPPORT
mDynamicsData( NULL ),
#endif
+ mGestureData( NULL ),
mAttachment(),
mShaderEffect(),
mName(),
delete mDynamicsData;
#endif
+ // Cleanup optional gesture data
+ delete mGestureData;
+
// Cleanup optional parent origin and anchor
delete mParentOrigin;
delete mAnchorPoint;
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/events/gesture.h>
#include <dali/public-api/math/viewport.h>
#include <dali/internal/event/common/proxy-object.h>
#include <dali/internal/event/common/stage-def.h>
{
class Actor;
+class GestureDetector;
class RenderTask;
class ShaderEffect;
struct DynamicsData;
+struct GestureData;
typedef IntrusivePtr<Actor> ActorPtr;
typedef IntrusivePtr<ShaderEffect> ShaderEffectPtr;
*/
bool IsHittable() const;
+ // Gestures
+
+ /**
+ * Adds a gesture detector to the actor so that the actor is aware that it requires this type of
+ * gesture.
+ * @param[in] detector The detector being added.
+ * @note A raw pointer to the detector is stored, so the detector MUST remove itself when it is
+ * destroyed using RemoveGestureDetector()
+ */
+ void AddGestureDetector( GestureDetector& detector );
+
+ /**
+ * Removes a previously added gesture detector from the actor. If no more gesture detectors of
+ * this type are registered with this actor then the actor will no longer be hit-tested for that
+ * gesture.
+ * @param[in] detector The detector to remove.
+ */
+ void RemoveGestureDetector( GestureDetector& detector );
+
+ /**
+ * Queries whether the actor requires the gesture type.
+ * @param[in] type The gesture type.
+ */
+ bool IsGestureRequred( Gesture::Type type ) const;
// Signals
DynamicsData* mDynamicsData; ///< optional physics data
#endif
+ GestureData* mGestureData; /// Optional Gesture data. Only created when actor requires gestures
+
ActorAttachmentPtr mAttachment; ///< Optional referenced attachment
ShaderEffectPtr mShaderEffect; ///< Optional referenced shader effect
GestureDetector::GestureDetector(Gesture::Type type)
: mType(type),
- mGestureEventProcessor(ThreadLocalStorage::Get().GetGestureEventProcessor()),
- mSlotDelegate(this)
+ mGestureEventProcessor(ThreadLocalStorage::Get().GetGestureEventProcessor())
{
}
{
for ( GestureDetectorActorContainer::iterator iter = mAttachedActors.begin(), endIter = mAttachedActors.end(); iter != endIter; ++iter )
{
- (*iter)->RemoveObserver( *this );
- (*iter)->TouchedSignal().Disconnect( mSlotDelegate, &GestureDetector::OnTouchEvent );
+ Actor* actor( *iter );
+ actor->RemoveObserver( *this );
+ actor->RemoveGestureDetector( *this );
}
mAttachedActors.clear();
// We need to observe the actor's destruction
actor.AddObserver(*this);
- // Dummy connection to touch event
- actor.TouchedSignal().Connect( mSlotDelegate, &GestureDetector::OnTouchEvent );
+ // Add the detector to the actor (so the actor knows it requires this gesture when going through hit-test algorithm)
+ actor.AddGestureDetector( *this );
// Notification for derived classes
OnActorAttach(actor);
// We no longer need to observe the actor's destruction
actor.RemoveObserver(*this);
- mAttachedActors.erase(match);
+ // Remove detector from actor (so it is set to no longer requiring this gesture when going through the hit-test algorithm)
+ actor.RemoveGestureDetector( *this );
- // Disconnect connection to touch event
- actor.TouchedSignal().Disconnect( mSlotDelegate, &PanGestureDetector::OnTouchEvent );
+ mAttachedActors.erase(match);
// Notification for derived classes
OnActorDetach(actor);
// We no longer need to observe the actor's destruction
actor->RemoveObserver(*this);
+ // Remove detector from actor (so it is set to no longer requiring this gesture when going through the hit-test algorithm)
+ actor->RemoveGestureDetector( *this );
+
// Notification for derived classes
OnActorDetach(*actor);
}
}
}
-bool GestureDetector::OnTouchEvent(Dali::Actor actor, const TouchEvent& event)
-{
- return false;
-}
-
bool GestureDetector::IsSceneObjectRemovable() const
{
return false;
*/
virtual void OnActorDestroyed(Object& object) = 0;
- /**
- * Dummy touch event handler. We do not need to know when touch happens on our actor. We just
- * need to connect a function so that our attached actor is checked during our hit testing.
- * @param[in] actor The hit actor (or one of its parents).
- * @param[in] event The touch event.
- * @return false always as we do not process the event.
- */
- bool OnTouchEvent(Dali::Actor actor, const TouchEvent& event);
-
private: // Default property extensions from ProxyObject
/**
Gesture::Type mType; ///< The gesture detector will detect this type of gesture.
GestureDetectorActorContainer mAttachedActors; ///< Proxy<Node>::Observer is used to provide weak-pointer behaviour
GestureEventProcessor& mGestureEventProcessor; ///< A reference to the gesture event processor.
-
-private:
-
- SlotDelegate< GestureDetector > mSlotDelegate;
};
} // namespace Internal
namespace Internal
{
-GestureProcessor::GestureProcessor()
-: mCurrentGesturedActor( NULL ),
- mGesturedActorDisconnected(false)
+namespace
+{
+
+/**
+ * Functor to check whether an actor requires a particular gesture or not
+ */
+struct GestureHitTestCheck : public HitTestAlgorithm::HitTestInterface
+{
+ GestureHitTestCheck( Gesture::Type type )
+ : mType( type )
+ {
+ }
+
+ virtual bool IsActorHittable( Actor* actor )
+ {
+ return actor->IsGestureRequred( mType ) && // Does the Application or derived actor type require the gesture?
+ actor->IsHittable(); // Is actor sensitive, visible and on the scene?
+ }
+
+ virtual bool DescendActorHierarchy( Actor* actor )
+ {
+ return actor->IsVisible() && // Actor is visible, if not visible then none of its children are visible.
+ actor->IsSensitive(); // Actor is sensitive, if insensitive none of its children should be hittable either.
+ }
+
+ Gesture::Type mType;
+};
+
+} // unnamed namespace
+
+
+GestureProcessor::GestureProcessor( Gesture::Type type )
+: mType( type ),
+ mCurrentGesturedActor( NULL ),
+ mGesturedActorDisconnected( false )
{
}
Vector2 screenCoordinates,
HitTestAlgorithm::Results& hitTestResults)
{
- bool hit = false;
-
- HitTestAlgorithm::HitTest( stage, screenCoordinates, hitTestResults );
- if( hitTestResults.renderTask && hitTestResults.actor )
- {
- if( ! GetImplementation( hitTestResults.renderTask ).IsSystemLevel() )
- {
- hit = true;
- }
- else
- {
- DALI_LOG_ERROR( "Gesture not possible in SystemOverlay" );
- }
- }
- return hit;
+ GestureHitTestCheck hitCheck( mType );
+ HitTestAlgorithm::HitTest( stage, screenCoordinates, hitTestResults, hitCheck );
+ return hitTestResults.renderTask && hitTestResults.actor;
}
void GestureProcessor::SetActor( Dali::Actor actor )
/**
* Protected constructor. Cannot create an instance of GestureProcessor
*/
- GestureProcessor();
+ GestureProcessor( Gesture::Type type );
/**
* Virtual protected destructor.
private: // Data
- Actor* mCurrentGesturedActor; ///< The current actor that has been gestured.
- bool mGesturedActorDisconnected; ///< Indicates whether the gestured actor has been disconnected from the scene
+ Gesture::Type mType; ///< Type of GestureProcessor
+ Actor* mCurrentGesturedActor; ///< The current actor that has been gestured.
+ bool mGesturedActorDisconnected:1; ///< Indicates whether the gestured actor has been disconnected from the scene
};
} // namespace Internal
LongPressGestureProcessor& processor;
};
-LongPressGestureProcessor::LongPressGestureProcessor(
- Stage& stage,
- Integration::GestureManager& gestureManager)
-: mStage( stage ),
+LongPressGestureProcessor::LongPressGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager)
+: GestureProcessor( Gesture::LongPress ),
+ mStage( stage ),
mGestureManager( gestureManager ),
mGestureDetectors(),
mCurrentEmitters(),
if ( currentGesturedActor )
{
HitTestAlgorithm::Results hitTestResults;
- HitTestAlgorithm::HitTest( mStage, longPressEvent.point, hitTestResults );
+ HitTest( mStage, longPressEvent.point, hitTestResults );
if ( hitTestResults.actor && ( currentGesturedActor == &GetImplementation( hitTestResults.actor ) ) )
{
};
PanGestureProcessor::PanGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager )
-: mStage( stage ),
+: GestureProcessor( Gesture::Pan ),
+ mStage( stage ),
mGestureManager( gestureManager ),
mGestureDetectors(),
mCurrentPanEmitters(),
// it can be told when the gesture ends as well.
HitTestAlgorithm::Results hitTestResults;
- HitTestAlgorithm::HitTest( mStage, mPossiblePanPosition, hitTestResults ); // Hit test original possible position...
+ HitTest( mStage, mPossiblePanPosition, hitTestResults ); // Hit test original possible position...
if ( hitTestResults.actor && ( GetCurrentGesturedActor() == &GetImplementation( hitTestResults.actor ) ) )
{
};
PinchGestureProcessor::PinchGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager )
-: mStage(stage),
+: GestureProcessor( Gesture::Pinch ),
+ mStage(stage),
mGestureManager(gestureManager),
mGestureDetectors(),
mCurrentPinchEmitters()
};
TapGestureProcessor::TapGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager)
-: mStage( stage ),
+: GestureProcessor( Gesture::Tap ),
+ mStage( stage ),
mGestureManager( gestureManager ),
mGestureDetectors(),
mMinTapsRequired( 1 ),
if ( GetCurrentGesturedActor() )
{
HitTestAlgorithm::Results hitTestResults;
- HitTestAlgorithm::HitTest( mStage, tapEvent.point, hitTestResults );
+ HitTest( mStage, tapEvent.point, hitTestResults );
if ( hitTestResults.actor && ( GetCurrentGesturedActor() == &GetImplementation( hitTestResults.actor ) ) )
{