From: Joogab Yun Date: Fri, 5 Jun 2020 01:57:43 +0000 (+0900) Subject: Refactoring Gestures Class X-Git-Tag: dali_1.9.28~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F235481%2F55;p=platform%2Fcore%2Fuifw%2Fdali-core.git Refactoring Gestures Class Change-Id: I5e11996bc2a02f7fb0e9ebe958d8c8b794912635 --- diff --git a/automated-tests/src/dali-internal/CMakeLists.txt b/automated-tests/src/dali-internal/CMakeLists.txt index 22a472d..0d5bcdd 100644 --- a/automated-tests/src/dali-internal/CMakeLists.txt +++ b/automated-tests/src/dali-internal/CMakeLists.txt @@ -10,9 +10,14 @@ SET(TC_SOURCES utc-Dali-Internal-Core.cpp utc-Dali-Internal-FixedSizeMemoryPool.cpp utc-Dali-Internal-FrustumCulling.cpp + utc-Dali-Internal-Gesture.cpp utc-Dali-Internal-Handles.cpp + utc-Dali-Internal-LongPressGesture.cpp utc-Dali-Internal-MemoryPoolObjectAllocator.cpp utc-Dali-Internal-OwnerPointer.cpp + utc-Dali-Internal-PinchGesture.cpp + utc-Dali-Internal-RotationGesture.cpp + utc-Dali-Internal-TapGesture.cpp ) LIST(APPEND TC_SOURCES diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Gesture.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Gesture.cpp new file mode 100644 index 0000000..bf2b20e --- /dev/null +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-Gesture.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include +#include + +using namespace Dali; + +void utc_dali_internal_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_internal_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +// TestGesture Struct (Gesture constructor is protected) +struct TestGesture : public Internal::Gesture +{ +public: + TestGesture(Gesture::Type type, Gesture::State state) + : Gesture(type, state) {} + + virtual ~TestGesture() {} +}; + +} // anon namespace + +int UtcDaliGestureConstructorP(void) +{ + TestApplication application; // Reset all test adapter return codes + + Gesture empty; + DALI_TEST_CHECK( !empty ); + + Gesture pan( new TestGesture(Gesture::Pan, Gesture::Started) ); + DALI_TEST_EQUALS(Gesture::Pan, pan.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, pan.GetState(), TEST_LOCATION); + + Gesture pinch( new TestGesture(Gesture::Pinch, Gesture::Clear) ); + DALI_TEST_EQUALS(Gesture::Pinch, pinch.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Clear, pinch.GetState(), TEST_LOCATION); + + // Test copy constructor + Gesture pan2(pan); + DALI_TEST_EQUALS(Gesture::Pan, pan2.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, pan2.GetState(), TEST_LOCATION); + END_TEST; + + // Test move constructor + const auto refCount = pan.GetObjectPtr()->ReferenceCount(); + Gesture pan3( std::move( pan ) ); + DALI_TEST_EQUALS(pan, Gesture(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, pan3.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(pan3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliGestureAssignmentP(void) +{ + TestApplication application; // Reset all test adapter return codes + + // Test Assignment operator + Gesture pan( new TestGesture(Gesture::Pan, Gesture::Finished) ); + DALI_TEST_EQUALS(Gesture::Pan, pan.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, pan.GetState(), TEST_LOCATION); + + Gesture test( new TestGesture(Gesture::Pinch, Gesture::Started) ); + DALI_TEST_EQUALS(Gesture::Pinch, test.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, test.GetState(), TEST_LOCATION); + + // Copy assignment + test = pan; + DALI_TEST_EQUALS(Gesture::Pan, test.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, test.GetState(), TEST_LOCATION); + + // Move assignment + const auto refCount = pan.GetObjectPtr()->ReferenceCount(); + Gesture pan3; + DALI_TEST_EQUALS(pan3, Gesture(), TEST_LOCATION); + pan3 = std::move(pan); + DALI_TEST_EQUALS(pan, Gesture(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, pan3.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(pan3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliGestureGetTypeP(void) +{ + TestApplication application; // Reset all test adapter return codes + + Gesture pan( new TestGesture(Gesture::Pan, Gesture::Started) ); + DALI_TEST_EQUALS(Gesture::Pan, pan.GetType(), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliGestureGetStateP(void) +{ + TestApplication application; // Reset all test adapter return codes + + Gesture pan( new TestGesture(Gesture::Pan, Gesture::Started) ); + DALI_TEST_EQUALS(Gesture::Started, pan.GetState(), TEST_LOCATION); + + GetImplementation(pan).SetState(Gesture::Finished); + DALI_TEST_EQUALS(Gesture::Finished, pan.GetState(), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliGestureGetTimeP(void) +{ + TestApplication application; // Reset all test adapter return codes + + Gesture pan( new TestGesture(Gesture::Pan, Gesture::Started) ); + DALI_TEST_EQUALS(0, pan.GetTime(), TEST_LOCATION); + + GetImplementation(pan).SetTime(61282); + DALI_TEST_EQUALS(61282, pan.GetTime(), TEST_LOCATION); + + END_TEST; +} + diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-LongPressGesture.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-LongPressGesture.cpp new file mode 100644 index 0000000..d1dda5f --- /dev/null +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-LongPressGesture.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include +#include + +using namespace Dali; + +void utc_dali_internal_long_press_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_internal_long_press_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliLongPressGestureConstructorP(void) +{ + TestApplication application; + + LongPressGesture gesture(new Internal::LongPressGesture( Gesture::Started )); + DALI_TEST_EQUALS(1u, gesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture.GetType(), TEST_LOCATION); + + // Test Copy constructor + GetImplementation( gesture ).SetNumberOfTouches( 5u ); + + LongPressGesture gesture2(gesture); + DALI_TEST_EQUALS(5u, gesture2.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture2.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, gesture2.GetState(), TEST_LOCATION); + + // Test move constructor + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + LongPressGesture gesture3( std::move( gesture ) ); + DALI_TEST_EQUALS(gesture, LongPressGesture(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture3.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliLongPressGestureAssignmentP(void) +{ + // Test Assignment operator + LongPressGesture gesture(new Internal::LongPressGesture( Gesture::Started )); + DALI_TEST_EQUALS(1u, gesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture.GetType(), TEST_LOCATION); + + GetImplementation( gesture ).SetNumberOfTouches( 5u ); + + LongPressGesture gesture2(new Internal::LongPressGesture( Gesture::Finished )); + DALI_TEST_EQUALS(Gesture::Finished, gesture2.GetState(), TEST_LOCATION); + gesture2 = gesture; + DALI_TEST_EQUALS(5u, gesture2.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture2.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, gesture2.GetState(), TEST_LOCATION); + + // Move assignment + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + LongPressGesture gesture3; + DALI_TEST_EQUALS(gesture3, Gesture(), TEST_LOCATION); + gesture3 = std::move(gesture); + DALI_TEST_EQUALS(gesture, Gesture(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture3.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliLongPressGestureGetNumberOfTouchesP(void) +{ + TestApplication application; + + LongPressGesture gesture(new Internal::LongPressGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetNumberOfTouches(), 1, TEST_LOCATION); + + GetImplementation(gesture).SetNumberOfTouches(4); + DALI_TEST_EQUALS(gesture.GetNumberOfTouches(), 4, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliLongPressGestureGetScreenPointP(void) +{ + TestApplication application; + + LongPressGesture gesture(new Internal::LongPressGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2::ZERO , TEST_LOCATION); + DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2::ZERO , TEST_LOCATION); + + GetImplementation(gesture).SetScreenPoint(Vector2(100.0f, 300.0f)); + DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2(100.0f, 300.0f), TEST_LOCATION); + DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2::ZERO , TEST_LOCATION); + + END_TEST; +} + +int UtcDaliLongPressGestureGetLocalPointP(void) +{ + TestApplication application; + + LongPressGesture gesture(new Internal::LongPressGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2::ZERO , TEST_LOCATION); + DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2::ZERO , TEST_LOCATION); + + GetImplementation(gesture).SetLocalPoint(Vector2(100.0f, 300.0f)); + DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2(100.0f, 300.0f), TEST_LOCATION); + DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2::ZERO , TEST_LOCATION); + + END_TEST; +} diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-PinchGesture.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-PinchGesture.cpp new file mode 100644 index 0000000..8ce75ac --- /dev/null +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-PinchGesture.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include +#include + +using namespace Dali; + +void utc_dali_internal_pinch_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_internal_pinch_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + +// Positive test case for a method +int UtcDaliPinchGestureConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + PinchGesture gesture(new Internal::PinchGesture( Gesture::Started )); + DALI_TEST_EQUALS(Gesture::Started, gesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.GetScale(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.GetSpeed(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture.GetType(), TEST_LOCATION); + + PinchGesture gesture2(new Internal::PinchGesture( Gesture::Continuing )); + DALI_TEST_EQUALS(Gesture::Continuing, gesture2.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.GetScale(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.GetSpeed(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture2.GetType(), TEST_LOCATION); + + PinchGesture gesture3(new Internal::PinchGesture( Gesture::Finished )); + DALI_TEST_EQUALS(Gesture::Finished, gesture3.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture3.GetScale(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture3.GetSpeed(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture3.GetType(), TEST_LOCATION); + + // Test copy constructor + GetImplementation( gesture3 ).SetScale( 3.0f ); + GetImplementation( gesture3 ).SetSpeed( 5.0f ); + + PinchGesture pinch(gesture3); + DALI_TEST_EQUALS(Gesture::Finished, pinch.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(3.0f, pinch.GetScale(), TEST_LOCATION); + DALI_TEST_EQUALS(5.0f, pinch.GetSpeed(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, pinch.GetType(), TEST_LOCATION); + + // Test move constructor + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + PinchGesture gesture4( std::move( gesture ) ); + DALI_TEST_CHECK(!gesture); + DALI_TEST_EQUALS(Gesture::Pinch, gesture4.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture4.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliPinchGestureAssignment(void) +{ + // Test Assignment operator + PinchGesture gesture(new Internal::PinchGesture( Gesture::Started )); + DALI_TEST_EQUALS(Gesture::Started, gesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.GetScale(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.GetSpeed(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture.GetType(), TEST_LOCATION); + + PinchGesture gesture2(new Internal::PinchGesture( Gesture::Continuing )); + DALI_TEST_EQUALS(Gesture::Continuing, gesture2.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.GetScale(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.GetSpeed(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture2.GetType(), TEST_LOCATION); + + GetImplementation( gesture2 ).SetScale( 3.0f ); + GetImplementation( gesture2 ).SetSpeed( 5.0f ); + + gesture = gesture2; + DALI_TEST_EQUALS(Gesture::Continuing, gesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(3.0f, gesture.GetScale(), TEST_LOCATION); + DALI_TEST_EQUALS(5.0f, gesture.GetSpeed(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture.GetType(), TEST_LOCATION); + + // Move assignment + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + PinchGesture gesture3; + DALI_TEST_EQUALS(gesture3, Gesture(), TEST_LOCATION); + gesture3 = std::move(gesture); + DALI_TEST_CHECK(!gesture); + DALI_TEST_EQUALS(Gesture::Pinch, gesture3.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliPinchGestureSetGetScaleP(void) +{ + PinchGesture gesture(new Internal::PinchGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetScale(), 0.0f, TEST_LOCATION); + + GetImplementation(gesture).SetScale(123.0f); + DALI_TEST_EQUALS(gesture.GetScale(), 123.0f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliPinchGestureSetGetSpeedP(void) +{ + PinchGesture gesture(new Internal::PinchGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetSpeed(), 0.0f, TEST_LOCATION); + + GetImplementation(gesture).SetSpeed(123.0f); + DALI_TEST_EQUALS(gesture.GetSpeed(), 123.0f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliPinchGestureSetGetScreenCenterPointP(void) +{ + PinchGesture gesture(new Internal::PinchGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetScreenCenterPoint(), Vector2::ZERO, TEST_LOCATION); + + GetImplementation(gesture).SetScreenCenterPoint(Vector2(123.0f, 321.0f)); + DALI_TEST_EQUALS(gesture.GetScreenCenterPoint(), Vector2(123.0f,321.0f), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliPinchGestureSetGetLocalCenterPointP(void) +{ + PinchGesture gesture(new Internal::PinchGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetLocalCenterPoint(), Vector2::ZERO, TEST_LOCATION); + + GetImplementation(gesture).SetLocalCenterPoint(Vector2(123.0f,321.0f)); + DALI_TEST_EQUALS(gesture.GetLocalCenterPoint(), Vector2(123.0f,321.0f), TEST_LOCATION); + + END_TEST; +} diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-RotationGesture.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-RotationGesture.cpp new file mode 100644 index 0000000..cb1c032 --- /dev/null +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-RotationGesture.cpp @@ -0,0 +1,138 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include +#include + +using namespace Dali; + +void utc_dali_internal_rotation_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_internal_rotation_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + +// Positive test case for a method +int UtcDaliRotationGestureConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + RotationGesture gesture(new Internal::RotationGesture( Gesture::Started )); + DALI_TEST_EQUALS(Gesture::Started, gesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.GetRotation().radian, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Rotation, gesture.GetType(), TEST_LOCATION); + + RotationGesture gesture2(new Internal::RotationGesture( Gesture::Continuing )); + DALI_TEST_EQUALS(Gesture::Continuing, gesture2.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.GetRotation().radian, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Rotation, gesture2.GetType(), TEST_LOCATION); + + RotationGesture gesture3(new Internal::RotationGesture( Gesture::Finished )); + DALI_TEST_EQUALS(Gesture::Finished, gesture3.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture3.GetRotation().radian, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Rotation, gesture3.GetType(), TEST_LOCATION); + + // Test copy constructor + GetImplementation( gesture3 ).SetRotation( Radian( 3.0f )); + + RotationGesture rotation(gesture3); + DALI_TEST_EQUALS(Gesture::Finished, rotation.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(3.0f, rotation.GetRotation().radian, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Rotation, rotation.GetType(), TEST_LOCATION); + + // Test move constructor + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + RotationGesture gesture4( std::move( gesture ) ); + DALI_TEST_CHECK(!gesture); + DALI_TEST_EQUALS(Gesture::Rotation, gesture4.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture4.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliRotationGestureAssignment(void) +{ + // Test Assignment operator + RotationGesture gesture(new Internal::RotationGesture( Gesture::Started )); + DALI_TEST_EQUALS(Gesture::Started, gesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.GetRotation().radian, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Rotation, gesture.GetType(), TEST_LOCATION); + + RotationGesture gesture2(new Internal::RotationGesture( Gesture::Continuing )); + DALI_TEST_EQUALS(Gesture::Continuing, gesture2.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.GetRotation().radian, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Rotation, gesture2.GetType(), TEST_LOCATION); + + GetImplementation( gesture2 ).SetRotation( Radian( 3.0f )); + + gesture = gesture2; + DALI_TEST_EQUALS(Gesture::Continuing, gesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(3.0f, gesture.GetRotation().radian, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Rotation, gesture.GetType(), TEST_LOCATION); + + // Move assignment + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + RotationGesture gesture3; + DALI_TEST_EQUALS(gesture3, Gesture(), TEST_LOCATION); + gesture3 = std::move(gesture); + DALI_TEST_CHECK(!gesture); + DALI_TEST_EQUALS(Gesture::Rotation, gesture3.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliRotationGestureSetGetRotationP(void) +{ + RotationGesture gesture(new Internal::RotationGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetRotation(), Radian(), TEST_LOCATION); + + GetImplementation(gesture).SetRotation(Dali::ANGLE_270); + DALI_TEST_EQUALS(gesture.GetRotation(), Dali::ANGLE_270, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliRotationGestureSetGetScreenCenterPointP(void) +{ + RotationGesture gesture(new Internal::RotationGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetScreenCenterPoint(), Vector2::ZERO, TEST_LOCATION); + + GetImplementation(gesture).SetScreenCenterPoint(Vector2(123.0f,321.0f)); + DALI_TEST_EQUALS(gesture.GetScreenCenterPoint(), Vector2(123.0f,321.0f), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliRotationGestureSetGetLocalCenterPointP(void) +{ + RotationGesture gesture(new Internal::RotationGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetLocalCenterPoint(), Vector2::ZERO, TEST_LOCATION); + + GetImplementation(gesture).SetLocalCenterPoint(Vector2(123.0f,321.0f)); + DALI_TEST_EQUALS(gesture.GetLocalCenterPoint(), Vector2(123.0f,321.0f), TEST_LOCATION); + + END_TEST; +} diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-TapGesture.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-TapGesture.cpp new file mode 100644 index 0000000..d99af7d --- /dev/null +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-TapGesture.cpp @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include +#include + +using namespace Dali; + +void utc_dali_internal_tap_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_internal_tap_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +// Positive test case for a method +int UtcDaliTapGestureConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + TapGesture gesture(new Internal::TapGesture( Gesture::Started )); + DALI_TEST_EQUALS(1u, gesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture.GetNumberOfTaps(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Tap, gesture.GetType(), TEST_LOCATION); + + // Test Copy constructor + GetImplementation( gesture ).SetNumberOfTouches( 5u ); + GetImplementation( gesture ).SetNumberOfTaps( 2u ); + + TapGesture gesture2(gesture); + DALI_TEST_EQUALS(5u, gesture2.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(2u, gesture2.GetNumberOfTaps(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Tap, gesture2.GetType(), TEST_LOCATION); + + // Test move constructor + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + TapGesture gesture3( std::move( gesture ) ); + DALI_TEST_CHECK(!gesture); + DALI_TEST_EQUALS(Gesture::Tap, gesture3.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTapGestureAssignment(void) +{ + // Test Assignment operator + TapGesture gesture(new Internal::TapGesture( Gesture::Started )); + DALI_TEST_EQUALS(1u, gesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture.GetNumberOfTaps(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Tap, gesture.GetType(), TEST_LOCATION); + + GetImplementation( gesture ).SetNumberOfTouches( 5u ); + GetImplementation( gesture ).SetNumberOfTaps( 2u ); + + TapGesture gesture2; + gesture2 = gesture; + DALI_TEST_EQUALS(5u, gesture2.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(2u, gesture2.GetNumberOfTaps(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Tap, gesture2.GetType(), TEST_LOCATION); + + // Move assignment + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + TapGesture gesture3; + DALI_TEST_EQUALS(gesture3, Gesture(), TEST_LOCATION); + gesture3 = std::move(gesture); + DALI_TEST_CHECK(!gesture); + DALI_TEST_EQUALS(Gesture::Tap, gesture3.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTapGestureSetGetNumberOfTapsP(void) +{ + TapGesture gesture(new Internal::TapGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetNumberOfTaps(), 1u, TEST_LOCATION); + + GetImplementation(gesture).SetNumberOfTaps(123u); + DALI_TEST_EQUALS(gesture.GetNumberOfTaps(), 123u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTapGestureSetGetNumberOfTouchesP(void) +{ + TapGesture gesture(new Internal::TapGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetNumberOfTouches(), 1u, TEST_LOCATION); + + GetImplementation(gesture).SetNumberOfTouches(321u); + DALI_TEST_EQUALS(gesture.GetNumberOfTouches(), 321u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTapGestureSetGetScreenPointP(void) +{ + TapGesture gesture(new Internal::TapGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2::ZERO, TEST_LOCATION); + + GetImplementation(gesture).SetScreenPoint(Vector2(123.0f,321.0f)); + DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2(123.0f,321.0f), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTapGestureSetGetLocalPointP(void) +{ + TapGesture gesture(new Internal::TapGesture(Gesture::Started)); + DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2::ZERO, TEST_LOCATION); + + GetImplementation(gesture).SetLocalPoint(Vector2(123.0f,321.0f)); + DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2(123.0f,321.0f), TEST_LOCATION); + + END_TEST; +} diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt index afa6443..cb569e3 100644 --- a/automated-tests/src/dali/CMakeLists.txt +++ b/automated-tests/src/dali/CMakeLists.txt @@ -31,7 +31,6 @@ SET(TC_SOURCES utc-Dali-FrameBuffer.cpp utc-Dali-FrameCallbackInterface.cpp utc-Dali-Geometry.cpp - utc-Dali-Gesture.cpp utc-Dali-GestureDetector.cpp utc-Dali-Handle.cpp utc-Dali-Hash.cpp @@ -41,7 +40,6 @@ SET(TC_SOURCES utc-Dali-KeyEvent.cpp utc-Dali-Layer.cpp utc-Dali-LocklessBuffer.cpp - utc-Dali-LongPressGesture.cpp utc-Dali-LongPressGestureDetector.cpp utc-Dali-LongPressGestureRecognizer.cpp utc-Dali-MathUtils.cpp @@ -54,7 +52,6 @@ SET(TC_SOURCES utc-Dali-PanGestureDetector.cpp utc-Dali-PanGestureRecognizer.cpp utc-Dali-Path.cpp - utc-Dali-PinchGesture.cpp utc-Dali-PinchGestureDetector.cpp utc-Dali-PinchGestureRecognizer.cpp utc-Dali-Pixel.cpp @@ -72,7 +69,6 @@ SET(TC_SOURCES utc-Dali-Renderer.cpp utc-Dali-RenderTask.cpp utc-Dali-RenderTaskList.cpp - utc-Dali-RotationGesture.cpp utc-Dali-RotationGestureDetector.cpp utc-Dali-RotationGestureRecognizer.cpp utc-Dali-Sampler.cpp @@ -84,7 +80,6 @@ SET(TC_SOURCES utc-Dali-SignalTemplates.cpp utc-Dali-SingletonService.cpp utc-Dali-Stage.cpp - utc-Dali-TapGesture.cpp utc-Dali-TapGestureDetector.cpp utc-Dali-TapGestureRecognizer.cpp utc-Dali-Texture.cpp diff --git a/automated-tests/src/dali/utc-Dali-Gesture.cpp b/automated-tests/src/dali/utc-Dali-Gesture.cpp deleted file mode 100644 index ccd31a6..0000000 --- a/automated-tests/src/dali/utc-Dali-Gesture.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_gesture_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_gesture_cleanup(void) -{ - test_return_value = TET_PASS; -} - -namespace -{ - -// TestGesture Struct (Gesture constructor is protected) -struct TestGesture : public Gesture -{ -public: - TestGesture(Gesture::Type type, Gesture::State state) - : Gesture(type, state) {} - - virtual ~TestGesture() {} -}; - -} // anon namespace - -int UtcDaliGestureConstructor(void) -{ - TestApplication application; // Reset all test adapter return codes - - TestGesture pan(Gesture::Pan, Gesture::Started); - DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, pan.state, TEST_LOCATION); - - TestGesture pinch(Gesture::Pinch, Gesture::Clear); - DALI_TEST_EQUALS(Gesture::Pinch, pinch.type, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Clear, pinch.state, TEST_LOCATION); - - // Test copy constructor - TestGesture pan2(pan); - DALI_TEST_EQUALS(Gesture::Pan, pan2.type, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, pan2.state, TEST_LOCATION); - END_TEST; -} - -int UtcDaliGestureAssignment(void) -{ - // Test Assignment operator - TestGesture pan(Gesture::Pan, Gesture::Finished); - DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, pan.state, TEST_LOCATION); - - TestGesture test(Gesture::Pinch, Gesture::Started); - DALI_TEST_EQUALS(Gesture::Pinch, test.type, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, test.state, TEST_LOCATION); - - test = pan; - DALI_TEST_EQUALS(Gesture::Pan, test.type, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, test.state, TEST_LOCATION); - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-LongPressGesture.cpp b/automated-tests/src/dali/utc-Dali-LongPressGesture.cpp deleted file mode 100644 index b870366..0000000 --- a/automated-tests/src/dali/utc-Dali-LongPressGesture.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_long_press_gesture_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_long_press_gesture_cleanup(void) -{ - test_return_value = TET_PASS; -} - - -// Positive test case for a method -int UtcDaliLongPressGestureConstructor(void) -{ - TestApplication application; // Reset all test adapter return codes - - LongPressGesture gesture( Gesture::Started ); - DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::LongPress, gesture.type, TEST_LOCATION); - - // Test Copy constructor - gesture.numberOfTouches = 5u; - - LongPressGesture gesture2(gesture); - DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::LongPress, gesture2.type, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, gesture2.state, TEST_LOCATION); - END_TEST; -} - -int UtcDaliLongPressGestureAssignment(void) -{ - // Test Assignment operator - LongPressGesture gesture( Gesture::Started ); - DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::LongPress, gesture.type, TEST_LOCATION); - - gesture.numberOfTouches = 5u; - - LongPressGesture gesture2( Gesture::Finished ); - DALI_TEST_EQUALS(Gesture::Finished, gesture2.state, TEST_LOCATION); - gesture2 = gesture; - DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::LongPress, gesture2.type, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, gesture2.state, TEST_LOCATION); - END_TEST; -} - -int UtcDaliLongPressGestureDynamicAllocation(void) -{ - LongPressGesture* gesture = new LongPressGesture( Gesture::Started ); - DALI_TEST_EQUALS(1u, gesture->numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::LongPress, gesture->type, TEST_LOCATION); - delete gesture; - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp index 20c821e..4f58ba8 100644 --- a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp @@ -48,7 +48,7 @@ struct SignalData SignalData() : functorCalled( false ), voidFunctorCalled( false ), - receivedGesture( Gesture::Clear ), + receivedGesture(), pressedActor() {} @@ -57,9 +57,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.numberOfTouches = 0u; - receivedGesture.screenPoint = Vector2(0.0f, 0.0f); - receivedGesture.localPoint = Vector2(0.0f, 0.0f); + receivedGesture.Reset(); pressedActor.Reset(); } @@ -104,7 +102,7 @@ struct UnstageActorFunctor : public GestureReceivedFunctor { GestureReceivedFunctor::operator()( actor, longPress ); - if ( longPress.state == stateToUnstage ) + if ( longPress.GetState() == stateToUnstage ) { scene.Remove( actor ); } @@ -322,8 +320,8 @@ int UtcDaliLongPressGestureSignalReceptionPositive(void) // Do a long press inside actor's area TestGenerateLongPress( application, 50.0f, 50.0f ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION); TestEndLongPress( application, 50.0f, 50.0f); END_TEST; } @@ -351,16 +349,16 @@ int UtcDaliLongPressGestureSignalReceptionDetach(void) // Start long press within the actor's area TestGenerateLongPress( application, 20.0f, 20.0f ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION); TestEndLongPress( application, 20.0f, 20.0f); // repeat the long press within the actor's area - we should still receive the signal data.Reset(); TestGenerateLongPress( application, 50.0f, 50.0f ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION); TestEndLongPress( application, 50.0f, 50.0f); // Detach actor @@ -442,8 +440,8 @@ int UtcDaliLongPressGestureSignalReceptionRotatedActor(void) TestGenerateLongPress( application, 5.0f, 5.0f ); TestEndLongPress( application, 5.0f, 5.0f); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.GetScreenPoint(), 0.1, TEST_LOCATION); // Rotate actor again and render actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) ); @@ -455,8 +453,8 @@ int UtcDaliLongPressGestureSignalReceptionRotatedActor(void) TestGenerateLongPress( application, 5.0f, 5.0f ); TestEndLongPress( application, 5.0f, 5.0f); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.GetScreenPoint(), 0.1, TEST_LOCATION); // Rotate actor again and render actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::YAXIS) ); @@ -506,7 +504,7 @@ int UtcDaliLongPressGestureSignalReceptionChildHit(void) TestEndLongPress( application, 50.0f, 50.0f); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, parent == data.pressedActor, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.GetScreenPoint(), 0.01f, TEST_LOCATION); // Attach child and generate same touch points // (Also proves that you can detach and then re-attach another actor) @@ -519,7 +517,7 @@ int UtcDaliLongPressGestureSignalReceptionChildHit(void) TestEndLongPress( application, 51.0f, 51.0f); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, child == data.pressedActor, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.GetScreenPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -1053,7 +1051,7 @@ int UtcDaliLongPressGestureDisableDetectionDuringLongPressN(void) &application, [&detector, &functorCalled](Actor actor, const LongPressGesture& gesture) { - if( gesture.state == Gesture::Finished ) + if( gesture.GetState() == Gesture::Finished ) { detector.Detach(actor); functorCalled = true; diff --git a/automated-tests/src/dali/utc-Dali-LongPressGestureRecognizer.cpp b/automated-tests/src/dali/utc-Dali-LongPressGestureRecognizer.cpp index ab81b80..27b4494 100644 --- a/automated-tests/src/dali/utc-Dali-LongPressGestureRecognizer.cpp +++ b/automated-tests/src/dali/utc-Dali-LongPressGestureRecognizer.cpp @@ -25,7 +25,6 @@ #include #include - using namespace Dali; /////////////////////////////////////////////////////////////////////////////// @@ -37,7 +36,7 @@ struct SignalData SignalData() : functorCalled(false), voidFunctorCalled(false), - receivedGesture(Gesture::Started) + receivedGesture() {} void Reset() @@ -45,7 +44,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.state = Gesture::Started; + receivedGesture.Reset(); pressedActor.Reset(); } diff --git a/automated-tests/src/dali/utc-Dali-PanGesture.cpp b/automated-tests/src/dali/utc-Dali-PanGesture.cpp index b35ec97..aabb6e6 100644 --- a/automated-tests/src/dali/utc-Dali-PanGesture.cpp +++ b/automated-tests/src/dali/utc-Dali-PanGesture.cpp @@ -10,7 +10,8 @@ * 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 + * See the License for the specific language governing permissions an + * d * limitations under the License. * */ @@ -20,6 +21,7 @@ #include #include #include +#include using namespace Dali; @@ -33,120 +35,128 @@ void utc_dali_pan_gesture_cleanup(void) test_return_value = TET_PASS; } - - -int UtcDaliPanGestureConstructor(void) +int UtcDaliPanGestureConstructorP(void) { TestApplication application; // Reset all test adapter return codes - PanGesture gesture; - DALI_TEST_EQUALS(Gesture::Clear, gesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pan, gesture.type, TEST_LOCATION); + PanGesture gesture = DevelPanGesture::New( Gesture::Clear ); + + DALI_TEST_EQUALS(Gesture::Clear, gesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture.GetType(), TEST_LOCATION); + + PanGesture gesture2 = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(Gesture::Started, gesture2.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture2.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture2.GetType(), TEST_LOCATION); - PanGesture gesture2(Gesture::Started); - DALI_TEST_EQUALS(Gesture::Started, gesture2.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture2.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pan, gesture2.type, TEST_LOCATION); + PanGesture gesture3 = DevelPanGesture::New( Gesture::Continuing ); + DALI_TEST_EQUALS(Gesture::Continuing, gesture3.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture3.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture3.GetType(), TEST_LOCATION); - PanGesture gesture3(Gesture::Continuing); - DALI_TEST_EQUALS(Gesture::Continuing, gesture3.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture3.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pan, gesture3.type, TEST_LOCATION); + PanGesture gesture4 = DevelPanGesture::New( Gesture::Finished ); - PanGesture gesture4(Gesture::Finished); - DALI_TEST_EQUALS(Gesture::Finished, gesture4.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture4.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pan, gesture4.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, gesture4.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture4.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture4.GetType(), TEST_LOCATION); // Test copy constructor - gesture4.numberOfTouches = 3u; + DevelPanGesture::SetNumberOfTouches( gesture4, 3u ); PanGesture pan(gesture4); - DALI_TEST_EQUALS(Gesture::Finished, pan.state, TEST_LOCATION); - DALI_TEST_EQUALS(3u, pan.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, pan.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(3u, pan.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, pan.GetType(), TEST_LOCATION); + + // Test move constructor + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + PanGesture gesture5( std::move( gesture ) ); + DALI_TEST_CHECK(!gesture); + DALI_TEST_EQUALS(Gesture::Pan, gesture5.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture5.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + END_TEST; } -int UtcDaliPanGestureAssignment(void) +int UtcDaliPanGestureAssignmentP(void) { // Test Assignment operator - PanGesture gesture(Gesture::Started); - DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pan, gesture.type, TEST_LOCATION); + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(Gesture::Started, gesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture.GetType(), TEST_LOCATION); - PanGesture gesture2(Gesture::Continuing); - DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture2.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pan, gesture2.type, TEST_LOCATION); + PanGesture gesture2 = DevelPanGesture::New( Gesture::Continuing ); - gesture2.numberOfTouches = 3u; + DALI_TEST_EQUALS(Gesture::Continuing, gesture2.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture2.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture2.GetType(), TEST_LOCATION); + + DevelPanGesture::SetNumberOfTouches( gesture2, 3u ); gesture = gesture2; - DALI_TEST_EQUALS(Gesture::Continuing, gesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(3u, gesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pan, gesture.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, gesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(3u, gesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture.GetType(), TEST_LOCATION); + + // Move assignment + const auto refCount = gesture.GetObjectPtr()->ReferenceCount(); + PanGesture gesture3; + DALI_TEST_EQUALS(gesture3, Gesture(), TEST_LOCATION); + gesture3 = std::move(gesture); + DALI_TEST_CHECK(!gesture); + DALI_TEST_EQUALS(Gesture::Pan, gesture3.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION); + END_TEST; } -int UtcDaliPanGestureGetSpeed(void) +int UtcDaliPanGestureGetSpeedP(void) { - PanGesture gesture(Gesture::Started); + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); DALI_TEST_EQUALS(0.0f, gesture.GetSpeed(), TEST_LOCATION); - gesture.velocity = Vector2(3.0f, -4.0f); + DevelPanGesture::SetVelocity( gesture, Vector2( 3.0f, -4.0f ) ); DALI_TEST_EQUALS(5.0f, gesture.GetSpeed(), TEST_LOCATION); END_TEST; } -int UtcDaliPanGestureGetDistance(void) +int UtcDaliPanGestureGetDistanceP(void) { - PanGesture gesture(Gesture::Started); + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); DALI_TEST_EQUALS(0.0f, gesture.GetDistance(), TEST_LOCATION); - gesture.displacement = Vector2(-30.0f, -40.0f); + DevelPanGesture::SetDisplacement( gesture, Vector2( -30.0f, -40.0f ) ); DALI_TEST_EQUALS(50.0f, gesture.GetDistance(), TEST_LOCATION); END_TEST; } -int UtcDaliPanGestureGetScreenSpeed(void) +int UtcDaliPanGestureGetScreenSpeedP(void) { - PanGesture gesture(Gesture::Started); + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); DALI_TEST_EQUALS(0.0f, gesture.GetScreenSpeed(), TEST_LOCATION); - gesture.screenVelocity = Vector2(3.0f, -4.0f); + DevelPanGesture::SetScreenVelocity( gesture, Vector2( 3.0f, -4.0f ) ); DALI_TEST_EQUALS(5.0f, gesture.GetScreenSpeed(), TEST_LOCATION); END_TEST; } -int UtcDaliPanGestureGetScreenDistance(void) +int UtcDaliPanGestureGetScreenDistanceP(void) { - PanGesture gesture(Gesture::Started); + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); DALI_TEST_EQUALS(0.0f, gesture.GetScreenDistance(), TEST_LOCATION); - gesture.screenDisplacement = Vector2(-30.0f, -40.0f); + DevelPanGesture::SetScreenDisplacement( gesture, Vector2( -30.0f, -40.0f ) ); DALI_TEST_EQUALS(50.0f, gesture.GetScreenDistance(), TEST_LOCATION); END_TEST; } -int UtcDaliPanGestureDynamicAllocation(void) -{ - PanGesture* gesture = new PanGesture( Gesture::Started ); - DALI_TEST_EQUALS(Gesture::Started, gesture->state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture->numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pan, gesture->type, TEST_LOCATION); - delete gesture; - - END_TEST; -} - -int UtcDaliPanGestureDetectorRegisterProperty(void) +int UtcDaliPanGestureDetectorRegisterPropertyP(void) { TestApplication application; @@ -197,3 +207,90 @@ int UtcDaliPanGestureDetectorRegisterProperty(void) END_TEST; } +int UtcDaliPanGestureSetGetTimeP(void) +{ + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(0, gesture.GetTime(), TEST_LOCATION); + + DevelPanGesture::SetTime( gesture, 123123 ); + + DALI_TEST_EQUALS(123123, gesture.GetTime(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSetGetVelocityP(void) +{ + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(Vector2::ZERO, gesture.GetVelocity(), TEST_LOCATION); + + DevelPanGesture::SetVelocity( gesture, Vector2(123.0f, 321.0f) ); + + DALI_TEST_EQUALS(Vector2(123.0f, 321.0f), gesture.GetVelocity(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSetGetDisplacementP(void) +{ + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(Vector2::ZERO, gesture.GetDisplacement(), TEST_LOCATION); + + DevelPanGesture::SetDisplacement( gesture, Vector2(123.0f, 321.0f) ); + + DALI_TEST_EQUALS(Vector2(123.0f, 321.0f), gesture.GetDisplacement(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSetGetPositionP(void) +{ + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(Vector2::ZERO, gesture.GetPosition(), TEST_LOCATION); + + DevelPanGesture::SetPosition( gesture, Vector2(123.0f, 321.0f) ); + + DALI_TEST_EQUALS(Vector2(123.0f, 321.0f), gesture.GetPosition(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSetGetScreenVelocityP(void) +{ + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(Vector2::ZERO, gesture.GetScreenVelocity(), TEST_LOCATION); + + DevelPanGesture::SetScreenVelocity( gesture, Vector2(123.0f, 321.0f) ); + + DALI_TEST_EQUALS(Vector2(123.0f, 321.0f), gesture.GetScreenVelocity(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSetGetScreenDisplacementP(void) +{ + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(Vector2::ZERO, gesture.GetScreenDisplacement(), TEST_LOCATION); + + DevelPanGesture::SetScreenDisplacement( gesture, Vector2(123.0f, 321.0f) ); + + DALI_TEST_EQUALS(Vector2(123.0f, 321.0f), gesture.GetScreenDisplacement(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSetGetScreenPositionP(void) +{ + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(Vector2::ZERO, gesture.GetScreenPosition(), TEST_LOCATION); + + DevelPanGesture::SetScreenPosition( gesture, Vector2(123.0f, 321.0f) ); + + DALI_TEST_EQUALS(Vector2(123.0f, 321.0f), gesture.GetScreenPosition(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSetGetNumberOfTouchesP(void) +{ + PanGesture gesture = DevelPanGesture::New( Gesture::Started ); + DALI_TEST_EQUALS(1u, gesture.GetNumberOfTouches(), TEST_LOCATION); + + DevelPanGesture::SetNumberOfTouches( gesture, 3123 ); + + DALI_TEST_EQUALS(3123, gesture.GetNumberOfTouches(), TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp index b0e245e..3f7ddc7 100644 --- a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp @@ -26,6 +26,7 @@ #include #include #include +#include using namespace Dali; @@ -51,7 +52,7 @@ struct SignalData SignalData() : functorCalled(false), voidFunctorCalled(false), - receivedGesture(Gesture::Clear) + receivedGesture() {} void Reset() @@ -59,12 +60,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.state = Gesture::Clear; - receivedGesture.velocity = Vector2(0.0f, 0.0f); - receivedGesture.displacement = Vector2(0.0f, 0.0f); - receivedGesture.position = Vector2(0.0f, 0.0f); - receivedGesture.screenPosition = Vector2(0.0f, 0.0f); - receivedGesture.numberOfTouches = 0; + receivedGesture.Reset(); pannedActor.Reset(); } @@ -109,7 +105,7 @@ struct UnstageActorFunctor : public GestureReceivedFunctor { GestureReceivedFunctor::operator()( actor, pan ); - if ( pan.state == stateToUnstage ) + if ( pan.GetState() == stateToUnstage ) { scene.Remove( actor ); } @@ -177,20 +173,20 @@ PanGesture GeneratePan( unsigned int time, Vector2 localVelocity = Vector2::ONE, unsigned int numberOfTouches = 1 ) { - PanGesture pan( state ); + Dali::PanGesture pan = DevelPanGesture::New( state ); - pan.time = time; + DevelPanGesture::SetTime( pan, time ); - pan.screenPosition = screenPosition; - pan.position = localPosition; + DevelPanGesture::SetScreenPosition( pan, screenPosition ); + DevelPanGesture::SetPosition( pan, localPosition ); - pan.screenDisplacement = screenDisplacement; - pan.displacement = localDisplacement; + DevelPanGesture::SetScreenDisplacement( pan, screenDisplacement ); + DevelPanGesture::SetDisplacement( pan, localDisplacement ); - pan.screenVelocity = screenVelocity; - pan.velocity = localVelocity; + DevelPanGesture::SetScreenVelocity( pan, screenVelocity ); + DevelPanGesture::SetVelocity( pan, localVelocity ); - pan.numberOfTouches = numberOfTouches; + DevelPanGesture::SetNumberOfTouches( pan, numberOfTouches ); return pan; } @@ -455,10 +451,10 @@ int UtcDaliPanGestureSignalReceptionDownMotionLeave(void) TestStartPan( application, Vector2( 10.0f, 20.0f ), Vector2( 26.0f, 20.0f ), time ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(16.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(0.5f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(16.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.5f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(0.5f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); @@ -469,10 +465,10 @@ int UtcDaliPanGestureSignalReceptionDownMotionLeave(void) time += TestGetFrameInterval(); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(0.0f, -16.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.0f, -16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); @@ -483,10 +479,10 @@ int UtcDaliPanGestureSignalReceptionDownMotionLeave(void) time += TestGetFrameInterval(); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(320.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(320.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(320.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(20.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); @@ -496,10 +492,10 @@ int UtcDaliPanGestureSignalReceptionDownMotionLeave(void) TestEndPan( application, Vector2(314.0f, 4.0f), time ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(-32.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(-2.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-32.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-2.0f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(32.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(2.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); END_TEST; @@ -530,10 +526,10 @@ int UtcDaliPanGestureSignalReceptionDownMotionUp(void) TestStartPan( application, Vector2( 10.0f, 20.0f ), Vector2( 26.0f, 20.0f ), time ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(16.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(0.5f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(16.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.5f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(0.5f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); @@ -544,10 +540,10 @@ int UtcDaliPanGestureSignalReceptionDownMotionUp(void) time += TestGetFrameInterval(); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(0.0f, -16.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.0f, -16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); @@ -557,10 +553,10 @@ int UtcDaliPanGestureSignalReceptionDownMotionUp(void) TestEndPan( application, Vector2(10.0f, 4.0f), time ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(-16.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-16.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); END_TEST; @@ -763,7 +759,7 @@ int UtcDaliPanGestureSignalReceptionRotatedActor(void) TestEndPan( application, Vector2(25.0f, 28.0f), time ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(16.0f, 2.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + DALI_TEST_EQUALS(Vector2(16.0f, 2.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative // Rotate actor again and render a couple of times actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) ); @@ -778,7 +774,7 @@ int UtcDaliPanGestureSignalReceptionRotatedActor(void) TestEndPan( application, Vector2(25.0f, 28.0f), time ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(2.0f, -16.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + DALI_TEST_EQUALS(Vector2(2.0f, -16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative // Rotate actor again and render a couple of times actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS) ); @@ -793,7 +789,7 @@ int UtcDaliPanGestureSignalReceptionRotatedActor(void) TestEndPan( application, Vector2(25.0f, 28.0f), time ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(-16.0f, -2.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + DALI_TEST_EQUALS(Vector2(-16.0f, -2.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative END_TEST; } @@ -838,7 +834,7 @@ int UtcDaliPanGestureSignalReceptionChildHit(void) DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, parent == data.pannedActor, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(-2.0f, 16.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + DALI_TEST_EQUALS(Vector2(-2.0f, 16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative // Attach child and generate same touch points to yield a different displacement // (Also proves that you can detach and then re-attach another actor) @@ -854,7 +850,7 @@ int UtcDaliPanGestureSignalReceptionChildHit(void) DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, child == data.pannedActor, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(16.0f, 2.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + DALI_TEST_EQUALS(Vector2(16.0f, 2.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative END_TEST; } @@ -2824,10 +2820,10 @@ int UtcDaliPanGestureNoTimeDiff(void) TestEndPan( application, Vector2(26.0f, 20.0f), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_CHECK( !std::isinf( data.receivedGesture.velocity.x ) ); - DALI_TEST_CHECK( !std::isinf( data.receivedGesture.velocity.y ) ); - DALI_TEST_CHECK( !std::isinf( data.receivedGesture.screenVelocity.x ) ); - DALI_TEST_CHECK( !std::isinf( data.receivedGesture.screenVelocity.y ) ); + DALI_TEST_CHECK( !std::isinf( data.receivedGesture.GetVelocity().x ) ); + DALI_TEST_CHECK( !std::isinf( data.receivedGesture.GetVelocity().y ) ); + DALI_TEST_CHECK( !std::isinf( data.receivedGesture.GetScreenVelocity().x ) ); + DALI_TEST_CHECK( !std::isinf( data.receivedGesture.GetScreenVelocity().y ) ); data.Reset(); data.Reset(); @@ -2864,7 +2860,7 @@ int UtcDaliPanGestureInterruptedWhenTouchConsumed(void) TestStartPan( application, Vector2( 10.0f, 20.0f ), Vector2( 26.0f, 20.0f ), time ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); data.Reset(); // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture @@ -2874,7 +2870,7 @@ int UtcDaliPanGestureInterruptedWhenTouchConsumed(void) time += TestGetFrameInterval(); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.GetState(), TEST_LOCATION); END_TEST; } @@ -2898,7 +2894,7 @@ int UtcDaliPanGestureDisableDetectionDuringPanN(void) &application, [&detector, &functorCalled](Actor actor, const PanGesture& pan) { - if( pan.state == Gesture::Finished ) + if( pan.GetState() == Gesture::Finished ) { detector.Detach(actor); functorCalled = true; diff --git a/automated-tests/src/dali/utc-Dali-PanGestureRecognizer.cpp b/automated-tests/src/dali/utc-Dali-PanGestureRecognizer.cpp index e79b6a3..d435132 100644 --- a/automated-tests/src/dali/utc-Dali-PanGestureRecognizer.cpp +++ b/automated-tests/src/dali/utc-Dali-PanGestureRecognizer.cpp @@ -24,7 +24,6 @@ #include #include - using namespace Dali; /////////////////////////////////////////////////////////////////////////////// @@ -44,7 +43,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.state = Gesture::Started; + receivedGesture.Reset(); pannedActor.Reset(); } diff --git a/automated-tests/src/dali/utc-Dali-PinchGesture.cpp b/automated-tests/src/dali/utc-Dali-PinchGesture.cpp deleted file mode 100644 index 3058f1f..0000000 --- a/automated-tests/src/dali/utc-Dali-PinchGesture.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_pinch_gesture_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_pinch_gesture_cleanup(void) -{ - test_return_value = TET_PASS; -} - -// Positive test case for a method -int UtcDaliPinchGestureConstructor(void) -{ - TestApplication application; // Reset all test adapter return codes - - PinchGesture gesture(Gesture::Started); - DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture.scale, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture.speed, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pinch, gesture.type, TEST_LOCATION); - - PinchGesture gesture2(Gesture::Continuing); - DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture2.scale, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture2.speed, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pinch, gesture2.type, TEST_LOCATION); - - PinchGesture gesture3(Gesture::Finished); - DALI_TEST_EQUALS(Gesture::Finished, gesture3.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture3.scale, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture3.speed, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pinch, gesture3.type, TEST_LOCATION); - - // Test copy constructor - gesture3.scale = 3.0f; - gesture3.speed = 5.0f; - - PinchGesture pinch(gesture3); - DALI_TEST_EQUALS(Gesture::Finished, pinch.state, TEST_LOCATION); - DALI_TEST_EQUALS(3.0f, pinch.scale, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, pinch.speed, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pinch, pinch.type, TEST_LOCATION); - END_TEST; -} - -int UtcDaliPinchGestureAssignment(void) -{ - // Test Assignment operator - PinchGesture gesture(Gesture::Started); - DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture.scale, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture.speed, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pinch, gesture.type, TEST_LOCATION); - - PinchGesture gesture2(Gesture::Continuing); - DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture2.scale, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture2.speed, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pinch, gesture2.type, TEST_LOCATION); - - gesture2.scale = 3.0f; - gesture2.speed = 5.0f; - - gesture = gesture2; - DALI_TEST_EQUALS(Gesture::Continuing, gesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(3.0f, gesture.scale, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, gesture.speed, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pinch, gesture.type, TEST_LOCATION); - END_TEST; -} - -int UtcDaliPinchGestureDynamicAllocation(void) -{ - PinchGesture* gesture = new PinchGesture( Gesture::Started ); - DALI_TEST_EQUALS(Gesture::Started, gesture->state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture->scale, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture->speed, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Pinch, gesture->type, TEST_LOCATION); - delete gesture; - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp index 3ba550d..a7fb992 100644 --- a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp @@ -46,7 +46,7 @@ struct SignalData SignalData() : functorCalled(false), voidFunctorCalled(false), - receivedGesture(Gesture::Started) + receivedGesture() {} void Reset() @@ -54,11 +54,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.state = Gesture::Started; - receivedGesture.scale = 0.0f; - receivedGesture.speed = 0.0f; - receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f); - receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f); + receivedGesture.Reset(); pinchedActor.Reset(); } @@ -103,7 +99,7 @@ struct UnstageActorFunctor : public GestureReceivedFunctor { GestureReceivedFunctor::operator()( actor, pinch ); - if ( pinch.state == stateToUnstage ) + if ( pinch.GetState() == stateToUnstage ) { scene.Remove( actor ); } @@ -283,40 +279,44 @@ int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void) TestStartPinch( application, Vector2( 5.0f, 20.0f ), Vector2( 35.0f, 20.0f ), Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.666f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(66.666f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.666f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(66.666f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Continue the pan within the actor's area - we should still receive the signal data.Reset(); TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.2666f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(80.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.2666f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(80.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Pan Gesture leaves actor's area - we should still receive the signal data.Reset(); TestContinuePinch( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(1.333f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(213.333f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1.333f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(213.333f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Gesture ends - we would receive a finished state data.Reset(); TestEndPinch( application, Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), Vector2( 305.0f, 10.0f ), Vector2( 315.0f, 10.0f ), 1500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.333f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(600.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.333f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(600.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -344,30 +344,33 @@ int UtcDaliPinchGestureSignalReceptionDownMotionUp(void) TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.555f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(106.667f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.555f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(106.667f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.277f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(66.666f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.277f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(66.666f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Gesture ends within actor's area - we would receive a finished state data.Reset(); TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -395,7 +398,7 @@ int UtcDaliPinchGestureSignalReceptionDetach(void) TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal @@ -403,14 +406,14 @@ int UtcDaliPinchGestureSignalReceptionDetach(void) TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); // Gesture ends within actor's area data.Reset(); TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.GetState(), TEST_LOCATION); // Detach actor detector.DetachAll(); @@ -446,14 +449,14 @@ int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void) TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); // Detach actor during the pinch, we should not receive the next event detector.DetachAll(); @@ -501,14 +504,14 @@ int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); // Remove the actor from stage and reset the data application.GetScene().Remove(actor); @@ -555,9 +558,10 @@ int UtcDaliPinchGestureSignalReceptionRotatedActor(void) TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(70.0f, 30.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Rotate actor again and render and notify actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) ); @@ -571,9 +575,10 @@ int UtcDaliPinchGestureSignalReceptionRotatedActor(void) TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(30.0f, 30.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Rotate actor again and render and notify actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS) ); @@ -587,9 +592,10 @@ int UtcDaliPinchGestureSignalReceptionRotatedActor(void) TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 5000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(30.0f, 70.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -631,9 +637,9 @@ int UtcDaliPinchGestureSignalReceptionChildHit(void) Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION); - DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); // Attach child and generate same touch points to yield same results // (Also proves that you can detach and then re-attach another actor) @@ -648,9 +654,10 @@ int UtcDaliPinchGestureSignalReceptionChildHit(void) Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION); - DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 80.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -1132,7 +1139,7 @@ int UtcDaliPinchGestureInterruptedWhenTouchConsumed(void) Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); data.Reset(); // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture @@ -1142,7 +1149,7 @@ int UtcDaliPinchGestureInterruptedWhenTouchConsumed(void) Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.GetState(), TEST_LOCATION); data.Reset(); // Start another pinch, we should not even get the callback this time @@ -1173,7 +1180,7 @@ int UtcDaliPinchGestureDisableDetectionDuringPinchN(void) &application, [&detector, &functorCalled](Actor actor, const PinchGesture& gesture) { - if( gesture.state == Gesture::Finished ) + if( gesture.GetState() == Gesture::Finished ) { detector.Detach(actor); functorCalled = true; diff --git a/automated-tests/src/dali/utc-Dali-PinchGestureRecognizer.cpp b/automated-tests/src/dali/utc-Dali-PinchGestureRecognizer.cpp index 940dc90..5a8096f 100644 --- a/automated-tests/src/dali/utc-Dali-PinchGestureRecognizer.cpp +++ b/automated-tests/src/dali/utc-Dali-PinchGestureRecognizer.cpp @@ -35,7 +35,7 @@ struct SignalData SignalData() : functorCalled(false), voidFunctorCalled(false), - receivedGesture(Gesture::Started) + receivedGesture() {} void Reset() @@ -43,7 +43,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.state = Gesture::Started; + receivedGesture.Reset(); pinchedActor.Reset(); } @@ -677,7 +677,7 @@ int UtcDaliPinchGestureRecognizerMinimumTouchEvents(void) application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) ); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) ); - DALI_TEST_EQUALS( Gesture::Started, data.receivedGesture.state, TEST_LOCATION ); + DALI_TEST_EQUALS( Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -723,7 +723,7 @@ int UtcDaliPinchGestureRecognizerMinimumTouchEventsAfterStart(void) application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) ); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) ); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 170 ) ); @@ -731,12 +731,12 @@ int UtcDaliPinchGestureRecognizerMinimumTouchEventsAfterStart(void) application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 190 ) ); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 200 ) ); // > Test : not enough touch events to make the gesture state "Continuing" - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 210 ) ); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 220 ) ); // > Test : 6 touch events after start make the gesture state "Continuing" - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-RotationGesture.cpp b/automated-tests/src/dali/utc-Dali-RotationGesture.cpp deleted file mode 100644 index e140a98..0000000 --- a/automated-tests/src/dali/utc-Dali-RotationGesture.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_rotation_gesture_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_rotation_gesture_cleanup(void) -{ - test_return_value = TET_PASS; -} - -// Positive test case for a method -int UtcDaliRotationGestureConstructor(void) -{ - TestApplication application; // Reset all test adapter return codes - - RotationGesture gesture(Gesture::Started); - DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture.rotation.radian, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Rotation, gesture.type, TEST_LOCATION); - - RotationGesture gesture2(Gesture::Continuing); - DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture2.rotation.radian, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Rotation, gesture2.type, TEST_LOCATION); - - RotationGesture gesture3(Gesture::Finished); - DALI_TEST_EQUALS(Gesture::Finished, gesture3.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture3.rotation.radian, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Rotation, gesture3.type, TEST_LOCATION); - - // Test copy constructor - gesture3.rotation = 3.0f; - - RotationGesture rotation(gesture3); - DALI_TEST_EQUALS(Gesture::Finished, rotation.state, TEST_LOCATION); - DALI_TEST_EQUALS(3.0f, rotation.rotation.radian, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Rotation, rotation.type, TEST_LOCATION); - END_TEST; -} - -int UtcDaliRotationGestureAssignment(void) -{ - // Test Assignment operator - RotationGesture gesture(Gesture::Started); - DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture.rotation.radian, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Rotation, gesture.type, TEST_LOCATION); - - RotationGesture gesture2(Gesture::Continuing); - DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture2.rotation.radian, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Rotation, gesture2.type, TEST_LOCATION); - - gesture2.rotation.radian = 3.0f; - - gesture = gesture2; - DALI_TEST_EQUALS(Gesture::Continuing, gesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(3.0f, gesture.rotation.radian, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Rotation, gesture.type, TEST_LOCATION); - END_TEST; -} - -int UtcDaliRotationGestureDynamicAllocation(void) -{ - RotationGesture* gesture = new RotationGesture( Gesture::Started ); - DALI_TEST_EQUALS(Gesture::Started, gesture->state, TEST_LOCATION); - DALI_TEST_EQUALS(0.0f, gesture->rotation.radian, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Rotation, gesture->type, TEST_LOCATION); - delete gesture; - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-RotationGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-RotationGestureDetector.cpp index 48fa876..c9648ca 100644 --- a/automated-tests/src/dali/utc-Dali-RotationGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-RotationGestureDetector.cpp @@ -46,7 +46,7 @@ struct SignalData SignalData() : functorCalled(false), voidFunctorCalled(false), - receivedGesture(Gesture::Started) + receivedGesture() {} void Reset() @@ -54,10 +54,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.state = Gesture::Started; - receivedGesture.rotation = 0.0f; - receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f); - receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f); + receivedGesture.Reset(); rotatedActor.Reset(); } @@ -102,7 +99,7 @@ struct UnstageActorFunctor : public GestureReceivedFunctor { GestureReceivedFunctor::operator()( actor, rotation ); - if ( rotation.state == stateToUnstage ) + if ( rotation.GetState() == stateToUnstage ) { scene.Remove( actor ); } @@ -282,36 +279,40 @@ int UtcDaliRotationGestureSignalReceptionDownMotionLeave(void) TestStartRotation( application, Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 20.0f ), Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 30.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.244f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(12.5f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.244f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(12.5f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(12.48f, 17.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Continue the pan within the actor's area - we should still receive the signal data.Reset(); TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Pan Gesture leaves actor's area - we should still receive the signal data.Reset(); TestContinueRotation( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Gesture ends - we would receive a finished state data.Reset(); TestEndRotation( application, Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), Vector2( 305.0f, 10.0f ), Vector2( 315.0f, 10.0f ), 1500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -339,27 +340,30 @@ int UtcDaliRotationGestureSignalReceptionDownMotionUp(void) TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), Vector2( 10.0f, 20.0f ), Vector2( 31.0f, 29.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(0.404892f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.404892f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Continue the rotation within the actor's area - we should still receive the signal data.Reset(); TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 15.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(-0.343024f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(-0.343024f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Gesture ends within actor's area - we would receive a finished state data.Reset(); TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(-0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(-0.463648f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -387,7 +391,7 @@ int UtcDaliRotationGestureSignalReceptionDetach(void) TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); // Continue the rotation within the actor's area - we should still receive the signal @@ -395,14 +399,14 @@ int UtcDaliRotationGestureSignalReceptionDetach(void) TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); // Gesture ends within actor's area data.Reset(); TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.GetState(), TEST_LOCATION); // Detach actor detector.DetachAll(); @@ -438,14 +442,14 @@ int UtcDaliRotationGestureSignalReceptionDetachWhileRotationing(void) TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); // Continue the rotation within the actor's area - we should still receive the signal data.Reset(); TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); // Detach actor during the rotation, we should not receive the next event detector.DetachAll(); @@ -493,14 +497,14 @@ int UtcDaliRotationGestureSignalReceptionActorDestroyedWhileRotationing(void) TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); // Continue the rotation within the actor's area - we should still receive the signal data.Reset(); TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); // Remove the actor from stage and reset the data application.GetScene().Remove(actor); @@ -547,8 +551,9 @@ int UtcDaliRotationGestureSignalReceptionRotatedActor(void) TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(67.5f, 27.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Rotate actor again and render and notify actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) ); @@ -562,8 +567,9 @@ int UtcDaliRotationGestureSignalReceptionRotatedActor(void) TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 3000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(27.0f, 32.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Rotate actor again and render and notify actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS) ); @@ -577,8 +583,9 @@ int UtcDaliRotationGestureSignalReceptionRotatedActor(void) TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 5000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(32.5f, 73.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -620,8 +627,9 @@ int UtcDaliRotationGestureSignalReceptionChildHit(void) Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 25.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, parent == data.rotatedActor, TEST_LOCATION); - DALI_TEST_EQUALS(0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.463648f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Attach child and generate same touch points to yield same results // (Also proves that you can detach and then re-attach another actor) @@ -636,8 +644,9 @@ int UtcDaliRotationGestureSignalReceptionChildHit(void) Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 35.0f ), 3000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, child == data.rotatedActor, TEST_LOCATION); - DALI_TEST_EQUALS(0.982794f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(24.0f, 27.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.982794f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(24.0f, 27.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(27.5f, 76.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -1119,7 +1128,7 @@ int UtcDaliRotationGestureInterruptedWhenTouchConsumed(void) Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); data.Reset(); // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture @@ -1128,7 +1137,7 @@ int UtcDaliRotationGestureInterruptedWhenTouchConsumed(void) TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.GetState(), TEST_LOCATION); data.Reset(); // Start another rotation, we should not even get the callback this time @@ -1158,7 +1167,7 @@ int UtcDaliRotationGestureDisableDetectionDuringRotationN(void) &application, [&detector, &functorCalled](Actor actor, const RotationGesture& gesture) { - if( gesture.state == Gesture::Finished ) + if( gesture.GetState() == Gesture::Finished ) { detector.Detach(actor); functorCalled = true; diff --git a/automated-tests/src/dali/utc-Dali-RotationGestureRecognizer.cpp b/automated-tests/src/dali/utc-Dali-RotationGestureRecognizer.cpp index 85ba2e3..09d2c78 100644 --- a/automated-tests/src/dali/utc-Dali-RotationGestureRecognizer.cpp +++ b/automated-tests/src/dali/utc-Dali-RotationGestureRecognizer.cpp @@ -23,7 +23,6 @@ #include #include - using namespace Dali; void utc_dali_rotation_gesture_recognizer_startup(void) @@ -45,7 +44,7 @@ struct SignalData SignalData() : functorCalled(false), voidFunctorCalled(false), - receivedGesture(Gesture::Started) + receivedGesture() {} void Reset() @@ -53,10 +52,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.state = Gesture::Started; - receivedGesture.rotation = 0.0f; - receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f); - receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f); + receivedGesture.Reset(); rotatedActor.Reset(); } @@ -87,6 +83,19 @@ struct GestureReceivedFunctor SignalData& signalData; }; +Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time ) +{ + Integration::TouchEvent touchEvent; + Integration::Point point; + point.SetState( state ); + point.SetScreenPosition( screenPosition ); + point.SetDeviceClass( Device::Class::TOUCH ); + point.SetDeviceSubclass( Device::Subclass::NONE ); + touchEvent.points.push_back( point ); + touchEvent.time = time; + return touchEvent; +} + Integration::TouchEvent GenerateDoubleTouch( PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time ) { Integration::TouchEvent touchEvent; @@ -107,6 +116,77 @@ Integration::TouchEvent GenerateDoubleTouch( PointState::Type stateA, const Vect } // anon namespace /////////////////////////////////////////////////////////////////////////////// +int UtcDaliRotationGestureRecognizerRealistic(void) +{ + TestApplication application; + + RotationGestureDetector detector = RotationGestureDetector::New(); + + 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(); + + detector.Attach(actor); + + SignalData data; + GestureReceivedFunctor functor(data); + detector.DetectedSignal().Connect(&application, functor); + + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 100 ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 20.0f ), 105 ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 110 ) ); + application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 25.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 115 ) ); + application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 85.0f ), 120 ) ); + application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 35.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 125 ) ); + application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 75.0f ), 130 ) ); + application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 45.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 135 ) ); + application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 50.0f ), PointState::MOTION, Vector2( 20.0f, 65.0f ), 140 ) ); + application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 60.0f ), 145 ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 56.0f ), 155 ) ); + + application.SendNotification(); + + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliRotationGestureRecognizerBasicInterrupted(void) +{ + TestApplication application; + + RotationGestureDetector detector = RotationGestureDetector::New(); + + 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(); + + detector.Attach(actor); + + SignalData data; + GestureReceivedFunctor functor(data); + detector.DetectedSignal().Connect(&application, functor); + + // application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 150 ) ); + // application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 20.0f, 25.0f ), 151 ) ); + application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 20.0f, 30.0f ), 152 ) ); + + application.SendNotification(); + + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + END_TEST; +} int UtcDaliRotationGestureRecognizerMinimumTouchEvents(void) { @@ -133,7 +213,7 @@ int UtcDaliRotationGestureRecognizerMinimumTouchEvents(void) application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) ); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) ); - DALI_TEST_EQUALS( Gesture::Started, data.receivedGesture.state, TEST_LOCATION ); + DALI_TEST_EQUALS( Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); @@ -177,7 +257,7 @@ int UtcDaliRotationGestureRecognizerMinimumTouchEventsAfterStart(void) application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) ); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) ); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 170 ) ); @@ -185,12 +265,12 @@ int UtcDaliRotationGestureRecognizerMinimumTouchEventsAfterStart(void) application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 190 ) ); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 200 ) ); // > Test : not enough touch events to make the gesture state "Continuing" - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 210 ) ); application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 220 ) ); // > Test : 6 touch events after start make the gesture state "Continuing" - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-TapGesture.cpp b/automated-tests/src/dali/utc-Dali-TapGesture.cpp deleted file mode 100644 index e53dcbb..0000000 --- a/automated-tests/src/dali/utc-Dali-TapGesture.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_tap_gesture_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_tap_gesture_cleanup(void) -{ - test_return_value = TET_PASS; -} - - -// Positive test case for a method -int UtcDaliTapGestureConstructor(void) -{ - TestApplication application; // Reset all test adapter return codes - - TapGesture gesture; - DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture.numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Tap, gesture.type, TEST_LOCATION); - - // Test Copy constructor - gesture.numberOfTouches = 5u; - gesture.numberOfTaps = 2u; - - TapGesture gesture2(gesture); - DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(2u, gesture2.numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Tap, gesture2.type, TEST_LOCATION); - END_TEST; -} - -int UtcDaliTapGestureAssignment(void) -{ - // Test Assignment operator - TapGesture gesture; - DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture.numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Tap, gesture.type, TEST_LOCATION); - - gesture.numberOfTouches = 5u; - gesture.numberOfTaps = 2u; - - TapGesture gesture2; - gesture2 = gesture; - DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(2u, gesture2.numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Tap, gesture2.type, TEST_LOCATION); - END_TEST; -} - -int UtcDaliTapGestureDynamicAllocation(void) -{ - TapGesture* gesture = new TapGesture; - DALI_TEST_EQUALS(1u, gesture->numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS(1u, gesture->numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Tap, gesture->type, TEST_LOCATION); - delete gesture; - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp index c6b8858..8d04551 100644 --- a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp @@ -53,10 +53,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.numberOfTaps = 0u; - receivedGesture.numberOfTouches = 0u; - receivedGesture.screenPoint = Vector2(0.0f, 0.0f); - receivedGesture.localPoint = Vector2(0.0f, 0.0f); + receivedGesture.Reset(); tappedActor.Reset(); } @@ -330,9 +327,9 @@ int UtcDaliTapGestureSignalReceptionPositive(void) // Do a tap inside actor's area TestGenerateTap( application, 50.0f, 50.0f, 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION); END_TEST; } @@ -359,17 +356,17 @@ int UtcDaliTapGestureSignalReceptionDetach(void) // Start tap within the actor's area TestGenerateTap( application, 20.0f, 20.0f, 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION); // repeat the tap within the actor's area - we should still receive the signal data.Reset(); TestGenerateTap( application, 50.0f, 50.0f, 700 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION); // Detach actor detector.DetachAll(); @@ -449,9 +446,9 @@ int UtcDaliTapGestureSignalReceptionRotatedActor(void) // Do tap, only check finished value TestGenerateTap( application, 5.0f, 5.0f, 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.GetScreenPoint(), 0.1, TEST_LOCATION); // Rotate actor again and render actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) ); @@ -462,9 +459,9 @@ int UtcDaliTapGestureSignalReceptionRotatedActor(void) data.Reset(); TestGenerateTap( application, 5.0f, 5.0f, 700 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); - DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); - DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.GetScreenPoint(), 0.1, TEST_LOCATION); // Rotate actor again and render actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::YAXIS) ); @@ -515,7 +512,7 @@ int UtcDaliTapGestureSignalReceptionChildHit(void) TestGenerateTap( application, 50.0f, 50.0f, 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.GetScreenPoint(), 0.01f, TEST_LOCATION); // Attach child and generate same touch points // (Also proves that you can detach and then re-attach another actor) @@ -527,7 +524,7 @@ int UtcDaliTapGestureSignalReceptionChildHit(void) TestGenerateTap( application, 51.0f, 51.0f, 700 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.GetScreenPoint(), 0.01f, TEST_LOCATION); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-TapGestureRecognizer.cpp b/automated-tests/src/dali/utc-Dali-TapGestureRecognizer.cpp index 13c3e77..f1669c2 100644 --- a/automated-tests/src/dali/utc-Dali-TapGestureRecognizer.cpp +++ b/automated-tests/src/dali/utc-Dali-TapGestureRecognizer.cpp @@ -43,7 +43,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.state = Gesture::Started; + receivedGesture.Reset(); tappedActor.Reset(); } diff --git a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp index 54685ee..ebe23b6 100644 --- a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp +++ b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp @@ -36,7 +36,7 @@ struct SignalData SignalData() : functorCalled( false ), voidFunctorCalled( false ), - receivedGesture( Gesture::Clear ), + receivedGesture( ), pressedActor() {} @@ -45,9 +45,7 @@ struct SignalData functorCalled = false; voidFunctorCalled = false; - receivedGesture.numberOfTouches = 0u; - receivedGesture.screenPoint = Vector2(0.0f, 0.0f); - receivedGesture.localPoint = Vector2(0.0f, 0.0f); + receivedGesture.Reset(); pressedActor.Reset(); } diff --git a/dali/devel-api/events/pan-gesture-devel.cpp b/dali/devel-api/events/pan-gesture-devel.cpp new file mode 100644 index 0000000..a25c48c --- /dev/null +++ b/dali/devel-api/events/pan-gesture-devel.cpp @@ -0,0 +1,78 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include + + +namespace Dali +{ + +namespace DevelPanGesture +{ + +Dali::PanGesture New( Gesture::State state ) +{ + return PanGesture( new Internal::PanGesture( state ) ); +} + +void SetTime( Dali::PanGesture& gesture, uint32_t time ) +{ + GetImplementation( gesture ).SetTime( time ); +} + +void SetVelocity( Dali::PanGesture& gesture, const Vector2& velocity) +{ + GetImplementation( gesture ).SetVelocity( velocity ); +} + +void SetDisplacement( Dali::PanGesture& gesture, const Vector2& displacement) +{ + GetImplementation( gesture ).SetDisplacement( displacement ); +} + +void SetPosition( Dali::PanGesture& gesture, const Vector2& position) +{ + GetImplementation( gesture ).SetPosition( position ); +} + +void SetScreenVelocity( Dali::PanGesture& gesture, const Vector2& screenVelocity) +{ + GetImplementation( gesture ).SetScreenVelocity( screenVelocity ); +} + +void SetScreenDisplacement( Dali::PanGesture& gesture, const Vector2& screenDisplacement) +{ + GetImplementation( gesture ).SetScreenDisplacement( screenDisplacement ); +} + +void SetScreenPosition( Dali::PanGesture& gesture, const Vector2& screenPosition) +{ + GetImplementation( gesture ).SetScreenPosition( screenPosition ); +} + +void SetNumberOfTouches( Dali::PanGesture& gesture, uint32_t numberOfTouches ) +{ + GetImplementation( gesture ).SetNumberOfTouches( numberOfTouches ); +} + +} // namespace DevelPanGesture + +} // namespace Dali diff --git a/dali/devel-api/events/pan-gesture-devel.h b/dali/devel-api/events/pan-gesture-devel.h new file mode 100644 index 0000000..aabda19 --- /dev/null +++ b/dali/devel-api/events/pan-gesture-devel.h @@ -0,0 +1,97 @@ +#ifndef DALI_PAN_GESTURE_DEVEL_H +#define DALI_PAN_GESTURE_DEVEL_H + +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace DevelPanGesture +{ + +/** + * @brief Create a PanGeture for internal. + * @param[in] state The state of the PanGesture + */ +DALI_CORE_API Dali::PanGesture New(Gesture::State state); + +/** + * @brief Set the time the gesture took place. + * @param[in] gesture The PanGesture to set + * @param[in] time The time the gesture took place + */ +DALI_CORE_API void SetTime(Dali::PanGesture& gesture, uint32_t time); + +/** + * @brief Set the velocity at which the user is moving their fingers. + * @param[in] gesture The PanGesture to set + * @param[in] velocity The Vector2 in local coordinates to set + */ +DALI_CORE_API void SetVelocity(Dali::PanGesture& gesture, const Vector2& velocity); + +/** + * @brief Set the displacement. + * @param[in] gesture The PanGesture to set + * @param[in] displacement The Vector2 in local coordinates to set + */ +DALI_CORE_API void SetDisplacement(Dali::PanGesture& gesture, const Vector2& displacement); + +/** + * @brief Set the current touch position of the primary touch point in local actor coordinates. + * @param[in] gesture The PanGesture to set. + * @param[in] position The current touch position to set. + */ +DALI_CORE_API void SetPosition(Dali::PanGesture& gesture, const Vector2& position); + +/** + * @brief Set the velocity at which the user is moving their fingers. + * @param[in] gesture The PanGesture to set + * @param[in] screenVelocity The Vector2 in screen coordinates to set + */ +DALI_CORE_API void SetScreenVelocity(Dali::PanGesture& gesture, const Vector2& screenVelocity); + +/** + * @brief Set the screen displacement. + * @param[in] gesture The PanGesture to set + * @param[in] screenDisplacement The Vector2 in screen coordinates to set + */ +DALI_CORE_API void SetScreenDisplacement(Dali::PanGesture& gesture, const Vector2& screenDisplacement); + +/** + * @brief Set the current touch position of the primary touch point in screen coordinates. + * @param[in] gesture The PanGesture to set. + * @param[in] screenPosition The Vector2 in screen coordinates to set. + */ +DALI_CORE_API void SetScreenPosition(Dali::PanGesture& gesture, const Vector2& screenPosition); + +/** + * @brief Set the total number of fingers touching the screen in a pan gesture. + * @param[in] gesture The PanGesture to set + * @param[in] numberOfTouches The total number of fingers touching the screen to set + */ +DALI_CORE_API void SetNumberOfTouches(Dali::PanGesture& gesture, uint32_t numberOfTouches); + +} // namespace DevelPanGesture + +} // namespace Dali + +#endif // DALI_PAN_GESTURE_DEVEL_H diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 8006968..e756df5 100644 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -14,8 +14,9 @@ SET( devel_api_src_files ${devel_api_src_dir}/common/stage-devel.cpp ${devel_api_src_dir}/common/stage.cpp ${devel_api_src_dir}/events/hit-test-algorithm.cpp - ${devel_api_src_dir}/events/long-press-gesture-detector-devel.cpp ${devel_api_src_dir}/events/key-event-devel.cpp + ${devel_api_src_dir}/events/long-press-gesture-detector-devel.cpp + ${devel_api_src_dir}/events/pan-gesture-devel.cpp ${devel_api_src_dir}/events/touch-point.cpp ${devel_api_src_dir}/events/wheel-event-devel.cpp ${devel_api_src_dir}/images/distance-field.cpp @@ -71,8 +72,9 @@ SET( devel_api_core_common_header_files SET( devel_api_core_events_header_files ${devel_api_src_dir}/events/hit-test-algorithm.h - ${devel_api_src_dir}/events/long-press-gesture-detector-devel.h ${devel_api_src_dir}/events/key-event-devel.h + ${devel_api_src_dir}/events/long-press-gesture-detector-devel.h + ${devel_api_src_dir}/events/pan-gesture-devel.h ${devel_api_src_dir}/events/touch-point.h ${devel_api_src_dir}/events/wheel-event-devel.h ) diff --git a/dali/internal/event/events/actor-gesture-data.cpp b/dali/internal/event/events/actor-gesture-data.cpp index 1967bac..382c303 100644 --- a/dali/internal/event/events/actor-gesture-data.cpp +++ b/dali/internal/event/events/actor-gesture-data.cpp @@ -86,27 +86,27 @@ GestureDetectorContainer*& ActorGestureData::GetContainerPtr( Gesture::Type type { switch ( type ) { - case Gesture::Pan: + case Dali::Gesture::Pan: { return panDetectors; } - case Gesture::Pinch: + case Dali::Gesture::Pinch: { return pinchDetectors; } - case Gesture::LongPress: + case Dali::Gesture::LongPress: { return longPressDetectors; } - case Gesture::Tap: + case Dali::Gesture::Tap: { return tapDetectors; } - case Gesture::Rotation: + case Dali::Gesture::Rotation: { return rotationDetectors; } diff --git a/dali/internal/event/events/gesture-event-processor.cpp b/dali/internal/event/events/gesture-event-processor.cpp index e6eb904..f77ea5c 100644 --- a/dali/internal/event/events/gesture-event-processor.cpp +++ b/dali/internal/event/events/gesture-event-processor.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include @@ -65,35 +65,35 @@ void GestureEventProcessor::AddGestureDetector(GestureDetector* gestureDetector, { switch (gestureDetector->GetType()) { - case Gesture::LongPress: + case Dali::Gesture::LongPress: { LongPressGestureDetector* longPress = static_cast(gestureDetector); mLongPressGestureProcessor.AddGestureDetector(longPress, scene); break; } - case Gesture::Pan: + case Dali::Gesture::Pan: { PanGestureDetector* pan = static_cast(gestureDetector); mPanGestureProcessor.AddGestureDetector(pan, scene, envOptionMinimumPanDistance, envOptionMinimumPanEvents); break; } - case Gesture::Pinch: + case Dali::Gesture::Pinch: { PinchGestureDetector* pinch = static_cast(gestureDetector); mPinchGestureProcessor.AddGestureDetector(pinch, scene); break; } - case Gesture::Tap: + case Dali::Gesture::Tap: { TapGestureDetector* tap = static_cast(gestureDetector); mTapGestureProcessor.AddGestureDetector(tap, scene); break; } - case Gesture::Rotation: + case Dali::Gesture::Rotation: { RotationGestureDetector* rotation = static_cast(gestureDetector); mRotationGestureProcessor.AddGestureDetector(rotation, scene); @@ -106,35 +106,35 @@ void GestureEventProcessor::RemoveGestureDetector(GestureDetector* gestureDetect { switch (gestureDetector->GetType()) { - case Gesture::LongPress: + case Dali::Gesture::LongPress: { LongPressGestureDetector* longPress = static_cast(gestureDetector); mLongPressGestureProcessor.RemoveGestureDetector(longPress); break; } - case Gesture::Pan: + case Dali::Gesture::Pan: { PanGestureDetector* pan = static_cast(gestureDetector); mPanGestureProcessor.RemoveGestureDetector(pan); break; } - case Gesture::Pinch: + case Dali::Gesture::Pinch: { PinchGestureDetector* pinch = static_cast(gestureDetector); mPinchGestureProcessor.RemoveGestureDetector(pinch); break; } - case Gesture::Tap: + case Dali::Gesture::Tap: { TapGestureDetector* tap = static_cast(gestureDetector); mTapGestureProcessor.RemoveGestureDetector(tap); break; } - case Gesture::Rotation: + case Dali::Gesture::Rotation: { RotationGestureDetector* rotation = static_cast(gestureDetector); mRotationGestureProcessor.RemoveGestureDetector(rotation); @@ -147,35 +147,35 @@ void GestureEventProcessor::GestureDetectorUpdated(GestureDetector* gestureDetec { switch (gestureDetector->GetType()) { - case Gesture::LongPress: + case Dali::Gesture::LongPress: { LongPressGestureDetector* longPress = static_cast(gestureDetector); mLongPressGestureProcessor.GestureDetectorUpdated(longPress); break; } - case Gesture::Pan: + case Dali::Gesture::Pan: { PanGestureDetector* pan = static_cast(gestureDetector); mPanGestureProcessor.GestureDetectorUpdated(pan); break; } - case Gesture::Pinch: + case Dali::Gesture::Pinch: { PinchGestureDetector* pinch = static_cast(gestureDetector); mPinchGestureProcessor.GestureDetectorUpdated(pinch); break; } - case Gesture::Tap: + case Dali::Gesture::Tap: { TapGestureDetector* tap = static_cast(gestureDetector); mTapGestureProcessor.GestureDetectorUpdated(tap); break; } - case Gesture::Rotation: + case Dali::Gesture::Rotation: { // Nothing to do break; @@ -183,11 +183,11 @@ void GestureEventProcessor::GestureDetectorUpdated(GestureDetector* gestureDetec } } -void GestureEventProcessor::SetGestureProperties( const Gesture& gesture ) +void GestureEventProcessor::SetGestureProperties( const Dali::Gesture& gesture ) { - DALI_ASSERT_DEBUG( gesture.type == Gesture::Pan && "Only PanGesture has a scene object\n" ); + DALI_ASSERT_DEBUG( gesture.GetType() == Dali::Gesture::Pan && "Only PanGesture has a scene object\n" ); - const PanGesture& pan = static_cast< const PanGesture& >( gesture ); + const Dali::PanGesture& pan = static_cast< const Dali::PanGesture& >( gesture ); if( mPanGestureProcessor.SetPanGestureProperties( pan ) ) { // We may not be updating so we need to ask the render controller for an update. diff --git a/dali/internal/event/events/gesture-event-processor.h b/dali/internal/event/events/gesture-event-processor.h index 58083f3..d1d6355 100644 --- a/dali/internal/event/events/gesture-event-processor.h +++ b/dali/internal/event/events/gesture-event-processor.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H /* - * Copyright (c) 2019 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. @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include #include #include #include @@ -30,8 +31,6 @@ namespace Dali { -struct Gesture; - namespace Integration { @@ -105,7 +104,7 @@ public: // To be called by gesture detectors * @param[in] gesture The gesture whose values will be used in the Update object. * @note If we are in the middle of processing the gesture being set, then this call is ignored. */ - void SetGestureProperties( const Gesture& gesture ); + void SetGestureProperties( const Dali::Gesture& gesture ); public: // Called by Core diff --git a/dali/internal/event/events/gesture-event.h b/dali/internal/event/events/gesture-event.h index 952fbad..9085749 100644 --- a/dali/internal/event/events/gesture-event.h +++ b/dali/internal/event/events/gesture-event.h @@ -19,8 +19,8 @@ */ // INTERNAL INCLUDES -#include #include +#include namespace Dali { diff --git a/dali/internal/event/events/gesture-impl.h b/dali/internal/event/events/gesture-impl.h new file mode 100644 index 0000000..f0a733b --- /dev/null +++ b/dali/internal/event/events/gesture-impl.h @@ -0,0 +1,152 @@ +#ifndef DALI_INTERNAL_GESTURE_H +#define DALI_INTERNAL_GESTURE_H + +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +class Gesture; +typedef IntrusivePtr GesturePtr; + +/** + * This is the abstract base structure for any gestures that the adaptor detects and wishes to send + * to the Core. + */ +class Gesture : public BaseObject +{ +public: + + using State = Dali::Gesture::State; + using Type = Dali::Gesture::Type; + +public: + + /** + * @brief Get the gesture type. + * + * @return The gesture type. + */ + inline Type GetType() const + { + return mGestureType; + } + + /** + * @brief Set the state of the gesture. + * @param[in] state The state of the gesture to set + */ + inline void SetState( State state ) + { + mState = state; + } + + /** + * @brief Get the state of the gesture. + * + * @return The state of the gesture. + */ + inline State GetState() const + { + return mState; + } + + /** + * @brief Set The time the gesture took place. + * @param[in] time The time the gesture took place. to set + */ + inline void SetTime( uint32_t time ) + { + mTime = time; + } + + /** + * @brief Get the time the gesture took place. + * + * @return The time the gesture took place. + */ + inline uint32_t GetTime() const + { + return mTime; + } + + Gesture(const Gesture&) = delete; ///< Deleted copy constructor + Gesture(Gesture&&) = delete; ///< Deleted move constructor + Gesture& operator=(const Gesture&) = delete; ///< Deleted copy assignment operator + Gesture& operator=(Gesture&&) = delete; ///< Deleted move assignment operator + +protected: + + /** + * This constructor is only used by derived classes. + * @param[in] gestureType The type of gesture event. + * @param[in] gestureState The state of the gesture event. + */ + Gesture(Type gestureType, State gestureState) + : mGestureType( gestureType ), + mState( gestureState ) + { + } + + /** + * @brief Virtual destructor. + * + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~Gesture() = default; + +private: + Type mGestureType; + State mState; + uint32_t mTime{0u}; +}; + +} // namespace Internal + +/** + * Helper methods for public API. + */ +inline Internal::Gesture& GetImplementation(Dali::Gesture& gesture) +{ + DALI_ASSERT_ALWAYS( gesture && "gesture handle is empty" ); + + BaseObject& handle = gesture.GetBaseObject(); + + return static_cast(handle); +} + +inline const Internal::Gesture& GetImplementation(const Dali::Gesture& gesture) +{ + DALI_ASSERT_ALWAYS( gesture && "gesture handle is empty" ); + + const BaseObject& handle = gesture.GetBaseObject(); + + return static_cast(handle); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_GESTURE_H diff --git a/dali/internal/event/events/gesture-requests.h b/dali/internal/event/events/gesture-requests.h index 85fbf68..a74f35a 100644 --- a/dali/internal/event/events/gesture-requests.h +++ b/dali/internal/event/events/gesture-requests.h @@ -64,7 +64,7 @@ struct PanGestureRequest : public GestureRequest * Default Constructor */ PanGestureRequest() - : GestureRequest(Gesture::Pan), + : GestureRequest(Dali::Gesture::Pan), minTouches(1), maxTouches(1) { @@ -94,7 +94,7 @@ struct TapGestureRequest : public GestureRequest * Default Constructor */ TapGestureRequest() - : GestureRequest(Gesture::Tap), + : GestureRequest(Dali::Gesture::Tap), minTaps(1), maxTaps(1), minTouches(1), @@ -128,7 +128,7 @@ struct LongPressGestureRequest : public GestureRequest * Default Constructor */ LongPressGestureRequest() - : GestureRequest(Gesture::LongPress), + : GestureRequest(Dali::Gesture::LongPress), minTouches(1), maxTouches(1) { diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.cpp b/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.cpp index 21adbe5..9f8fe0a 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.cpp +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -22,7 +22,7 @@ #include // for strcmp // INTERNAL INCLUDES -#include + #include #include @@ -72,14 +72,14 @@ LongPressGestureDetectorPtr LongPressGestureDetector::New(unsigned int minTouche } LongPressGestureDetector::LongPressGestureDetector() -: GestureDetector(Gesture::LongPress), +: GestureDetector(Dali::Gesture::LongPress), mMinimumTouchesRequired(DEFAULT_TOUCHES_REQUIRED), mMaximumTouchesRequired(DEFAULT_TOUCHES_REQUIRED) { } LongPressGestureDetector::LongPressGestureDetector(unsigned int minTouches, unsigned int maxTouches) -: GestureDetector(Gesture::LongPress), +: GestureDetector(Dali::Gesture::LongPress), mMinimumTouchesRequired(minTouches), mMaximumTouchesRequired(maxTouches) { @@ -132,7 +132,7 @@ unsigned int LongPressGestureDetector::GetMaximumTouchesRequired() const return mMaximumTouchesRequired; } -void LongPressGestureDetector::EmitLongPressGestureSignal(Dali::Actor pressedActor, const LongPressGesture& longPress) +void LongPressGestureDetector::EmitLongPressGestureSignal(Dali::Actor pressedActor, const Dali::LongPressGesture& longPress) { // Guard against destruction during signal emission Dali::LongPressGestureDetector handle( this ); diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.h b/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.h index 561012b..3a57574 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.h +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_IMPL_H /* - * Copyright (c) 2019 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. @@ -25,8 +25,6 @@ namespace Dali { -struct LongPressGesture; - namespace Internal { @@ -110,7 +108,7 @@ public: * @param[in] pressedActor The pressed actor. * @param[in] longPress The long press */ - void EmitLongPressGestureSignal(Dali::Actor pressedActor, const LongPressGesture& longPress); + void EmitLongPressGestureSignal(Dali::Actor pressedActor, const Dali::LongPressGesture& longPress); public: // Signals diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-event.cpp b/dali/internal/event/events/long-press-gesture/long-press-gesture-event.cpp index c707f05..5d9f12d 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-event.cpp +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -25,7 +25,7 @@ namespace Internal { LongPressGestureEvent::LongPressGestureEvent( Gesture::State state ) -: GestureEvent( Gesture::LongPress, state ), +: GestureEvent( Dali::Gesture::LongPress, state ), numberOfTouches(1) { } diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-impl.h b/dali/internal/event/events/long-press-gesture/long-press-gesture-impl.h new file mode 100644 index 0000000..d133b3a --- /dev/null +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-impl.h @@ -0,0 +1,147 @@ +#ifndef DALI_INTERNAL_LONG_PRESS_GESTURE_H +#define DALI_INTERNAL_LONG_PRESS_GESTURE_H + +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +class LongPressGesture; +typedef IntrusivePtr< LongPressGesture > LongPressGesturePtr; + +/** + * @copydoc Dali::LongPressGesture + */ +class LongPressGesture final : public Gesture +{ +public: + + /** + * Default Constructor + * @param[in] state Started, when we detect a long press. + * Finished, when all touches are finished. + */ + LongPressGesture( Gesture::State state ) + : Gesture( Dali::Gesture::LongPress, state ) + { + } + + LongPressGesture(const LongPressGesture&) = delete; ///< Deleted copy constructor + LongPressGesture(LongPressGesture&&) = delete; ///< Deleted move constructor + LongPressGesture& operator=(const LongPressGesture&) = delete; ///< Deleted copy assignment operator + LongPressGesture& operator=(LongPressGesture&&) = delete; ///< Deleted move assignment operator + + /** + * @brief Set the number of touch points. + * @param[in] numberOfTouches The number of touch points to set. + */ + inline void SetNumberOfTouches( uint32_t numberOfTouches ) + { + mNumberOfTouches = numberOfTouches; + } + + /** + * @copydoc Dali::LongPressGesture::GetNumberOfTouches() + */ + inline uint32_t GetNumberOfTouches() const + { + return mNumberOfTouches; + } + + /** + * @brief Set This is the point, in screen coordinates. + * @param[in] screenPoint The point in screen coordinates to set. + */ + inline void SetScreenPoint( const Vector2& screenPoint ) + { + mScreenPoint = screenPoint; + } + + /** + * @copydoc Dali::LongPressGesture::GetScreenPoint() + */ + inline const Vector2& GetScreenPoint() const + { + return mScreenPoint; + } + + /** + * @brief Set This is the point, in local actor coordinates. + * @param[in] localPoint The point in local actor coordinates to set. + */ + inline void SetLocalPoint( const Vector2& localPoint ) + { + mLocalPoint = localPoint; + } + + /** + * @copydoc Dali::LongPressGesture::GetLocalPoint() + */ + inline const Vector2& GetLocalPoint() const + { + return mLocalPoint; + } + +private: + + /** + * @brief Virtual destructor + * + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~LongPressGesture() = default; + +private: + Vector2 mScreenPoint; + Vector2 mLocalPoint; + uint32_t mNumberOfTouches{1u}; +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods + +inline Internal::LongPressGesture& GetImplementation( Dali::LongPressGesture& longPressGesture ) +{ + DALI_ASSERT_ALWAYS( longPressGesture && "longPressGesture handle is empty" ); + + BaseObject& object = longPressGesture.GetBaseObject(); + + return static_cast< Internal::LongPressGesture& >( object ); +} + +inline const Internal::LongPressGesture& GetImplementation( const Dali::LongPressGesture& longPressGesture ) +{ + DALI_ASSERT_ALWAYS( longPressGesture && "longPressGesture handle is empty" ); + + const BaseObject& object = longPressGesture.GetBaseObject(); + + return static_cast< const Internal::LongPressGesture& >( object ); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_LONG_PRESS_GESTURE_H diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp b/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp index b754301..6e223c7 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp @@ -24,7 +24,7 @@ // INTERNAL INCLUDES #include #include -#include +#include #include #include #include @@ -57,17 +57,17 @@ void EmitLongPressSignal( const LongPressGestureEvent& longPressEvent, Vector2 localPoint) { - LongPressGesture longPress(longPressEvent.state); - longPress.time = longPressEvent.time; - longPress.numberOfTouches = longPressEvent.numberOfTouches; - longPress.screenPoint = longPressEvent.point; - longPress.localPoint = localPoint; + Internal::LongPressGesturePtr longPress( new Internal::LongPressGesture(longPressEvent.state ) ); + longPress->SetTime( longPressEvent.time ); + longPress->SetNumberOfTouches( longPressEvent.numberOfTouches ); + longPress->SetScreenPoint( longPressEvent.point ); + longPress->SetLocalPoint( localPoint ); Dali::Actor actorHandle( actor ); const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end(); for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter ) { - static_cast< LongPressGestureDetector* >( *iter )->EmitLongPressGestureSignal( actorHandle, longPress ); + static_cast< LongPressGestureDetector* >( *iter )->EmitLongPressGestureSignal( actorHandle, Dali::LongPressGesture( longPress.Get() ) ); } } @@ -102,7 +102,7 @@ struct IsNotAttachedFunctor } // unnamed namespace LongPressGestureProcessor::LongPressGestureProcessor() -: GestureProcessor( Gesture::LongPress ), +: GestureProcessor( Dali::Gesture::LongPress ), mLongPressGestureDetectors(), mCurrentEmitters(), mCurrentRenderTask(), @@ -121,7 +121,7 @@ void LongPressGestureProcessor::Process( Scene& scene, const LongPressGestureEve { switch ( longPressEvent.state ) { - case Gesture::Possible: + case Dali::Gesture::Possible: { mCurrentEmitters.clear(); ResetActor(); @@ -134,7 +134,7 @@ void LongPressGestureProcessor::Process( Scene& scene, const LongPressGestureEve break; } - case Gesture::Started: + case Dali::Gesture::Started: { Actor* currentGesturedActor = GetCurrentGesturedActor(); if ( currentGesturedActor ) @@ -161,7 +161,7 @@ void LongPressGestureProcessor::Process( Scene& scene, const LongPressGestureEve break; } - case Gesture::Finished: + case Dali::Gesture::Finished: { // The gesture should only be sent to the gesture detector which first received it so that it // can be told when the gesture ends as well. @@ -195,20 +195,20 @@ void LongPressGestureProcessor::Process( Scene& scene, const LongPressGestureEve break; } - case Gesture::Cancelled: + case Dali::Gesture::Cancelled: { mCurrentEmitters.clear(); ResetActor(); break; } - case Gesture::Continuing: + case Dali::Gesture::Continuing: { DALI_ABORT( "Incorrect state received from Integration layer: Continuing\n" ); break; } - case Gesture::Clear: + case Dali::Gesture::Clear: { DALI_ABORT( "Incorrect state received from Integration layer: Clear\n" ); break; diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.cpp b/dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.cpp index 7f9a34b..e4a9e02 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.cpp +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.cpp @@ -43,7 +43,7 @@ const float MAXIMUM_MOTION_ALLOWED = 60.0f; } // unnamed namespace LongPressGestureRecognizer::LongPressGestureRecognizer(Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request, uint32_t minimumHoldingTime ) -: GestureRecognizer( screenSize, Gesture::LongPress ), +: GestureRecognizer( screenSize, Dali::Gesture::LongPress ), mObserver( observer ), mState( Clear ), mMinimumTouchesRequired( request.minTouches ), @@ -91,7 +91,7 @@ void LongPressGestureRecognizer::SendEvent(const Integration::TouchEvent& event) // A long press gesture may be possible, tell Core about this and change state to Touched. mState = Touched; - EmitGesture( Gesture::Possible ); + EmitGesture( Dali::Gesture::Possible ); } break; @@ -103,7 +103,7 @@ void LongPressGestureRecognizer::SendEvent(const Integration::TouchEvent& event) if (pointCount > mMaximumTouchesRequired) { // A long press did not occur, tell Core that it was cancelled and change state to Failed. - EmitGesture( Gesture::Cancelled ); + EmitGesture( Dali::Gesture::Cancelled ); mTouchPositions.clear(); platformAbstraction.CancelTimer(mTimerId); mTimerId = 0; @@ -130,7 +130,7 @@ void LongPressGestureRecognizer::SendEvent(const Integration::TouchEvent& event) case PointState::INTERRUPTED: { // System has interrupted us, long press is not possible, inform Core - EmitGesture( Gesture::Cancelled ); + EmitGesture( Dali::Gesture::Cancelled ); mTouchPositions.clear(); platformAbstraction.CancelTimer(mTimerId); mTimerId = 0; @@ -147,7 +147,7 @@ void LongPressGestureRecognizer::SendEvent(const Integration::TouchEvent& event) if (distanceSquared > ( MAXIMUM_MOTION_ALLOWED * MAXIMUM_MOTION_ALLOWED ) ) { // We have moved more than the allowable motion for a long press gesture. Inform Core and change state to Failed. - EmitGesture( Gesture::Cancelled ); + EmitGesture( Dali::Gesture::Cancelled ); platformAbstraction.CancelTimer(mTimerId); mTimerId = 0; mState = Failed; @@ -180,7 +180,7 @@ void LongPressGestureRecognizer::SendEvent(const Integration::TouchEvent& event) if(mState == Finished) { // When the last touch point is lifted, we should inform the Core that the Long press has finished. - EmitGesture(Gesture::Finished); + EmitGesture(Dali::Gesture::Finished); } mTouchPositions.clear(); mState = Clear; // Reset state to clear when last touch point is lifted. @@ -207,7 +207,7 @@ void LongPressGestureRecognizer::SetMinimumHoldingTime( uint32_t time ) bool LongPressGestureRecognizer::TimerCallback() { - EmitGesture(Gesture::Started); + EmitGesture(Dali::Gesture::Started); mState = Finished; @@ -221,8 +221,8 @@ void LongPressGestureRecognizer::EmitGesture(Gesture::State state) unsigned int touchPoints ( static_cast( mTouchPositions.size() ) ); // We should tell Core about the Possible and Cancelled states regardless of whether we have satisfied long press requirements. - if ( (state == Gesture::Possible) || - (state == Gesture::Cancelled) || + if ( (state == Dali::Gesture::Possible) || + (state == Dali::Gesture::Cancelled) || (touchPoints >= mMinimumTouchesRequired) ) { LongPressGestureEvent longPress( state ); @@ -236,7 +236,7 @@ void LongPressGestureRecognizer::EmitGesture(Gesture::State state) longPress.point /= static_cast( touchPoints ); longPress.time = mTouchTime; - if ( state != Gesture::Possible ) + if ( state != Dali::Gesture::Possible ) { longPress.time += mMinimumHoldingTime; } diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.h b/dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.h index cb2cbfa..66369e3 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.h +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_LONG_PRESS_GESTURE_RECOGNIZER_H /* - * Copyright (c) 2019 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. @@ -96,7 +96,7 @@ private: * Emits the long press gesture if all conditions are applicable. * @param[in] state The state of this gesture event. */ - void EmitGesture(Gesture::State state); + void EmitGesture( Gesture::State state ); private: diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.cpp b/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.cpp index d29befc..84592c8 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -259,7 +259,7 @@ bool PanGestureDetector::CheckAngleAllowed( Radian angle ) const return allowed; } -void PanGestureDetector::EmitPanGestureSignal(Dali::Actor actor, const PanGesture& pan) +void PanGestureDetector::EmitPanGestureSignal(Dali::Actor actor, const Dali::PanGesture& pan) { if ( !mDetectedSignal.Empty() ) { @@ -290,13 +290,13 @@ bool PanGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerI return connected; } -void PanGestureDetector::SetPanGestureProperties( const PanGesture& pan ) +void PanGestureDetector::SetPanGestureProperties( const Dali::PanGesture& pan ) { ThreadLocalStorage::Get().GetGestureEventProcessor().SetGestureProperties( pan ); } PanGestureDetector::PanGestureDetector( const SceneGraph::PanGesture& sceneObject ) -: GestureDetector(Gesture::Pan, &sceneObject ), +: GestureDetector( Dali::Gesture::Pan, &sceneObject ), mMinimumTouches(1), mMaximumTouches(1) { diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.h b/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.h index 03aa7e2..39d5d9d 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.h +++ b/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_PAN_GESTURE_DETECTOR_H /* - * Copyright (c) 2019 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. @@ -23,6 +23,7 @@ #include #include #include +#include namespace Dali { @@ -137,7 +138,7 @@ public: * @param[in] actor The panned actor. * @param[in] pan The pan gesture. */ - void EmitPanGestureSignal(Dali::Actor actor, const PanGesture& pan); + void EmitPanGestureSignal(Dali::Actor actor, const Dali::PanGesture& pan); public: // Signals @@ -165,7 +166,7 @@ public: // Override Pan Gesture /** * @copydoc Dali::PanGestureDetector::SetPanGestureProperties() */ - static void SetPanGestureProperties( const PanGesture& pan ); + static void SetPanGestureProperties( const Dali::PanGesture& pan ); protected: diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-event.cpp b/dali/internal/event/events/pan-gesture/pan-gesture-event.cpp index cc1bd1c..17a6cec 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-event.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -26,7 +26,7 @@ namespace Internal PanGestureEvent::PanGestureEvent(Gesture::State state) -: GestureEvent(Gesture::Pan, state), +: GestureEvent(Dali::Gesture::Pan, state), timeDelta(0), numberOfTouches(1) { diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-impl.h b/dali/internal/event/events/pan-gesture/pan-gesture-impl.h new file mode 100644 index 0000000..d727263 --- /dev/null +++ b/dali/internal/event/events/pan-gesture/pan-gesture-impl.h @@ -0,0 +1,252 @@ +#ifndef DALI_INTERNAL_PAN_GESTURE_H +#define DALI_INTERNAL_PAN_GESTURE_H + +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +class PanGesture; +typedef IntrusivePtr< PanGesture > PanGesturePtr; + +/** + * @copydoc Dali::PanGesture + */ +class PanGesture final : public Gesture +{ +public: + + /** + * @brief Default constructor + */ + PanGesture(Gesture::State state) + : Gesture(Dali::Gesture::Pan, state) + { + } + + PanGesture(const PanGesture&) = delete; ///< Deleted copy constructor + PanGesture(PanGesture&&) = delete; ///< Deleted move constructor + PanGesture& operator=(const PanGesture&) = delete; ///< Deleted copy assignment operator + PanGesture& operator=(PanGesture&&) = delete; ///< Deleted move assignment operator + + /** + * @brief Set The velocity at which the user is moving their fingers. + * @param[in] velocity The Vector2 in local coordinates to set. + */ + inline void SetVelocity(const Vector2& velocity) + { + mVelocity = velocity; + } + + /** + * @copydoc Dali::PanGesture::GetVelocity() + */ + inline const Vector2& GetVelocity() const + { + return mVelocity; + } + + /** + * @brief Set This is a Vector2 showing how much the user has panned (dragged) since the last pan gesture or, + * if the gesture has just started, then the amount panned since the user touched the screen. + * @param[in] displacement The Vector2 in local coordinates to set. + */ + inline void SetDisplacement(const Vector2& displacement) + { + mDisplacement = displacement; + } + + /** + * @copydoc Dali::PanGesture::GetDisplacement() + */ + inline const Vector2& GetDisplacement() const + { + return mDisplacement; + } + + /** + * @brief Set This current touch position of the primary touch point in local actor coordinates. + * @param[in] velocity The current touch position to set. + */ + inline void SetPosition(const Vector2& position) + { + mPosition = position; + } + + /** + * @copydoc Dali::PanGesture::GetPosition() + */ + inline const Vector2& GetPosition() const + { + return mPosition; + } + + /** + * @brief Set The velocity at which the user is moving their fingers. + * @param[in] screenVelocity The Vector2 in screen coordinates to set. + */ + inline void SetScreenVelocity(const Vector2& screenVelocity) + { + mScreenVelocity = screenVelocity; + } + + /** + * @copydoc Dali::PanGesture::GetScreenVelocity() + */ + inline const Vector2& GetScreenVelocity() const + { + return mScreenVelocity; + } + + /** + * @brief Set This is a Vector2 showing how much the user has panned (dragged) since the last pan gesture or, + * if the gesture has just started, then the amount panned since the user touched the screen. + * @param[in] screenDisplacement The Vector2 in screen coordinates to set. + */ + inline void SetScreenDisplacement(const Vector2& screenDisplacement) + { + mScreenDisplacement = screenDisplacement; + } + + /** + * @copydoc Dali::PanGesture::GetScreenDisplacement() + */ + inline const Vector2& GetScreenDisplacement() const + { + return mScreenDisplacement; + } + + /** + * @brief Set This current touch position of the primary touch point in screen coordinates. + * @param[in] screenPosition The Vector2 in screen coordinates to set. + */ + inline void SetScreenPosition(const Vector2& screenPosition) + { + mScreenPosition = screenPosition; + } + + /** + * @copydoc Dali::PanGesture::GetScreenPosition() + */ + inline const Vector2& GetScreenPosition() const + { + return mScreenPosition; + } + + /** + * @brief The total number of fingers touching the screen in a pan gesture. + * @param[in] numberOfTouches The total number of fingers touching the screen to set. + */ + inline void SetNumberOfTouches(uint32_t numberOfTouches) + { + mNumberOfTouches = numberOfTouches; + } + + /** + * @brief The total number of fingers touching the screen in a pan gesture. + */ + inline uint32_t GetNumberOfTouches() const + { + return mNumberOfTouches; + } + + /** + * @copydoc Dali::PanGesture::GetSpeed() + */ + inline float GetSpeed() const + { + return mVelocity.Length(); + } + + /** + * @copydoc Dali::PanGesture::GetDistance() + */ + inline float GetDistance() const + { + return mDisplacement.Length(); + } + + /** + * @copydoc Dali::PanGesture::GetScreenSpeed() + */ + inline float GetScreenSpeed() const + { + return mScreenVelocity.Length(); + } + + /** + * @copydoc Dali::PanGesture::GetScreenDistance() + */ + inline float GetScreenDistance() const + { + return mScreenDisplacement.Length(); + } + +private: + + /** + * @brief Virtual destructor + * + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~PanGesture() = default; + +private: + Vector2 mVelocity; + Vector2 mDisplacement; + Vector2 mPosition; + Vector2 mScreenVelocity; + Vector2 mScreenDisplacement; + Vector2 mScreenPosition; + uint32_t mNumberOfTouches{1u}; +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods + +inline Internal::PanGesture& GetImplementation( Dali::PanGesture& panGesture ) +{ + DALI_ASSERT_ALWAYS( panGesture && "panGesture handle is empty" ); + + BaseObject& object = panGesture.GetBaseObject(); + + return static_cast< Internal::PanGesture& >( object ); +} + +inline const Internal::PanGesture& GetImplementation( const Dali::PanGesture& panGesture ) +{ + DALI_ASSERT_ALWAYS( panGesture && "panGesture handle is empty" ); + + const BaseObject& object = panGesture.GetBaseObject(); + + return static_cast< const Internal::PanGesture& >( object ); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_PAN_GESTURE_H diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp b/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp index 92154aa..8b7a3c6 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include namespace Dali @@ -123,7 +124,7 @@ struct IsNotAttachedAndOutsideTouchesRangeFunctor } // unnamed namespace PanGestureProcessor::PanGestureProcessor( SceneGraph::UpdateManager& updateManager ) -: GestureProcessor( Gesture::Pan ), +: GestureProcessor( Dali::Gesture::Pan ), mPanGestureDetectors(), mCurrentPanEmitters(), mCurrentRenderTask(), @@ -156,7 +157,7 @@ void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent switch( panEvent.state ) { - case Gesture::Possible: + case Dali::Gesture::Possible: { mCurrentPanEmitters.clear(); ResetActor(); @@ -170,7 +171,7 @@ void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent break; } - case Gesture::Started: + case Dali::Gesture::Started: { // Requires a core update mNeedsUpdate = true; @@ -206,7 +207,7 @@ void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent break; } - case Gesture::Continuing: + case Dali::Gesture::Continuing: { // Requires a core update mNeedsUpdate = true; @@ -214,8 +215,8 @@ void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent DALI_FALLTHROUGH; } - case Gesture::Finished: - case Gesture::Cancelled: + case Dali::Gesture::Finished: + case Dali::Gesture::Cancelled: { // Only send subsequent pan gesture signals if we processed the pan gesture when it started. // Check if actor is still touchable. @@ -240,7 +241,7 @@ void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent currentGesturedActor->ScreenToLocal( *mCurrentRenderTask.Get(), actorCoords.x, actorCoords.y, panEvent.currentPosition.x, panEvent.currentPosition.y ); // EmitPanSignal checks whether we have a valid actor and whether the container we are passing in has emitters before it emits the pan. - EmitPanSignal( currentGesturedActor, outsideTouchesRangeEmitters, panEvent, actorCoords, Gesture::Finished, mCurrentRenderTask); + EmitPanSignal( currentGesturedActor, outsideTouchesRangeEmitters, panEvent, actorCoords, Dali::Gesture::Finished, mCurrentRenderTask); EmitPanSignal( currentGesturedActor, mCurrentPanEmitters, panEvent, actorCoords, panEvent.state, mCurrentRenderTask); } @@ -251,7 +252,7 @@ void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent } // Clear current gesture detectors if pan gesture has ended or been cancelled. - if ( ( panEvent.state == Gesture::Finished ) || ( panEvent.state == Gesture::Cancelled ) ) + if ( ( panEvent.state == Dali::Gesture::Finished ) || ( panEvent.state == Dali::Gesture::Cancelled ) ) { mCurrentPanEmitters.clear(); ResetActor(); @@ -266,7 +267,7 @@ void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent break; } - case Gesture::Clear: + case Dali::Gesture::Clear: { DALI_ABORT( "Incorrect state received from Integration layer: Clear\n" ); break; @@ -337,16 +338,18 @@ void PanGestureProcessor::GestureDetectorUpdated( PanGestureDetector* gestureDet UpdateDetection(); } -bool PanGestureProcessor::SetPanGestureProperties( const PanGesture& pan ) +bool PanGestureProcessor::SetPanGestureProperties( const Dali::PanGesture& pan ) { // If we are currently processing a pan gesture then just ignore if ( mCurrentPanEmitters.empty() && mSceneObject ) { + const PanGesture& panImpl( GetImplementation(pan) ); + // We update the scene object directly rather than sending a message. // Sending a message could cause unnecessary delays, the scene object ensure thread safe behaviour. - mSceneObject->AddGesture( pan ); + mSceneObject->AddGesture( panImpl ); - if( Gesture::Started == pan.state || Gesture::Continuing == pan.state ) + if( Dali::Gesture::Started == panImpl.GetState() || Dali::Gesture::Continuing == panImpl.GetState() ) { mNeedsUpdate = true; } @@ -500,57 +503,62 @@ void PanGestureProcessor::EmitPanSignal( Actor* actor, { if ( actor && !gestureDetectors.empty() ) { - PanGesture pan(state); - pan.time = panEvent.time; + Internal::PanGesturePtr pan( new Internal::PanGesture(state ) ); + + pan->SetTime( panEvent.time ); - pan.numberOfTouches = panEvent.numberOfTouches; - pan.screenPosition = panEvent.currentPosition; - pan.position = localCurrent; + pan->SetNumberOfTouches( panEvent.numberOfTouches ); + pan->SetScreenPosition( panEvent.currentPosition ); + pan->SetPosition( localCurrent ); RenderTask& renderTaskImpl( *renderTask.Get() ); Vector2 localPrevious; actor->ScreenToLocal( renderTaskImpl, localPrevious.x, localPrevious.y, panEvent.previousPosition.x, panEvent.previousPosition.y ); - pan.displacement = localCurrent - localPrevious; + pan->SetDisplacement( localCurrent - localPrevious ); Vector2 previousPos( panEvent.previousPosition ); - if ( state == Gesture::Started ) + if ( state == Dali::Gesture::Started ) { previousPos = mPossiblePanPosition; } - pan.screenDisplacement = panEvent.currentPosition - previousPos; + pan->SetScreenDisplacement( panEvent.currentPosition - previousPos ); // Avoid dividing by 0 if ( panEvent.timeDelta > 0 ) { - pan.velocity.x = pan.displacement.x / static_cast( panEvent.timeDelta ); - pan.velocity.y = pan.displacement.y / static_cast( panEvent.timeDelta ); - - pan.screenVelocity.x = pan.screenDisplacement.x / static_cast( panEvent.timeDelta ); - pan.screenVelocity.y = pan.screenDisplacement.y / static_cast( panEvent.timeDelta ); + Vector2 velocity; + velocity.x = pan->GetDisplacement().x / static_cast( panEvent.timeDelta ); + velocity.y = pan->GetDisplacement().y / static_cast( panEvent.timeDelta ); + pan->SetVelocity( velocity ); + + Vector2 screenVelocity; + screenVelocity.x = pan->GetScreenDisplacement().x / static_cast( panEvent.timeDelta ); + screenVelocity.y = pan->GetScreenDisplacement().y / static_cast( panEvent.timeDelta ); + pan->SetScreenVelocity( screenVelocity ); } // When the gesture ends, we may incorrectly get a ZERO velocity (as we have lifted our finger without any movement) // so we should use the last recorded velocity instead in this scenario. - if ( ( state == Gesture::Finished ) && ( pan.screenVelocity == Vector2::ZERO ) && + if ( ( state == Dali::Gesture::Finished ) && ( pan->GetScreenVelocity() == Vector2::ZERO ) && ( panEvent.timeDelta < MAXIMUM_TIME_WITH_VALID_LAST_VELOCITY ) ) { - pan.velocity = mLastVelocity; - pan.screenVelocity = mLastScreenVelocity; + pan->SetVelocity( mLastVelocity ); + pan->SetScreenVelocity( mLastScreenVelocity ); } else { // Store the current velocity for future iterations. - mLastVelocity = pan.velocity; - mLastScreenVelocity = pan.screenVelocity; + mLastVelocity = pan->GetVelocity(); + mLastScreenVelocity = pan->GetScreenVelocity(); } if ( mSceneObject ) { // We update the scene object directly rather than sending a message. // Sending a message could cause unnecessary delays, the scene object ensure thread safe behaviour. - mSceneObject->AddGesture( pan ); + mSceneObject->AddGesture( *pan.Get() ); } Dali::Actor actorHandle( actor ); @@ -558,7 +566,7 @@ void PanGestureProcessor::EmitPanSignal( Actor* actor, const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end(); for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter ) { - static_cast< PanGestureDetector* >( *iter )->EmitPanGestureSignal( actorHandle, pan ); + static_cast< PanGestureDetector* >( *iter )->EmitPanGestureSignal( actorHandle, Dali::PanGesture( pan.Get() ) ); } } } diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-processor.h b/dali/internal/event/events/pan-gesture/pan-gesture-processor.h index f831d8a..9d08e51 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-processor.h +++ b/dali/internal/event/events/pan-gesture/pan-gesture-processor.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_EVENT_PAN_GESTURE_EVENT_PROCESSOR_H /* - * Copyright (c) 2019 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. @@ -102,7 +102,7 @@ public: // To be called by GestureEventProcessor * @return true if Core::Update required * @note If we are already processing a normal pan, then this call is ignored. */ - bool SetPanGestureProperties( const PanGesture& pan ); + bool SetPanGestureProperties( const Dali::PanGesture& pan ); /** * Called to provide pan-gesture profiling information. diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp index 0a0964c..57ce7fa 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp @@ -46,7 +46,7 @@ const unsigned int MINIMUM_MOTION_EVENTS_BEFORE_PAN(2); } // unnamed namespace PanGestureRecognizer::PanGestureRecognizer( Observer& observer, Vector2 screenSize, const PanGestureRequest& request, int32_t minimumDistance, int32_t minimumPanEvents ) -: GestureRecognizer( screenSize, Gesture::Pan ), +: GestureRecognizer( screenSize, Dali::Gesture::Pan ), mObserver( observer ), mState( Clear ), mThresholdAdjustmentsRemaining( 0 ), @@ -89,7 +89,7 @@ void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event) { // If our pan had started and we are interrupted, then tell Core that pan is cancelled. mTouchEvents.push_back(event); - SendPan(Gesture::Cancelled, event); + SendPan(Dali::Gesture::Cancelled, event); } mState = Clear; // We should change our state to Clear. mTouchEvents.clear(); @@ -109,7 +109,7 @@ void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event) { // We have satisfied the minimum touches required for a pan, tell core that a gesture may be possible and change our state accordingly. mState = Possible; - SendPan(Gesture::Possible, event); + SendPan(Dali::Gesture::Possible, event); } mTouchEvents.push_back(event); @@ -134,7 +134,7 @@ void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event) { // If the touch point(s) have moved enough distance to be considered a pan, then tell Core that the pan gesture has started and change our state accordingly. mState = Started; - SendPan(Gesture::Started, event); + SendPan(Dali::Gesture::Started, event); } } else if (primaryPointState == PointState::UP) @@ -142,14 +142,14 @@ void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event) Vector2 delta(event.points[0].GetScreenPosition() - mPrimaryTouchDownLocation); if (delta.LengthSquared() >= static_cast( mMinimumDistanceSquared ) ) { - SendPan(Gesture::Started, event); + SendPan(Dali::Gesture::Started, event); mTouchEvents.push_back(event); - SendPan(Gesture::Finished, event); + SendPan(Dali::Gesture::Finished, event); } else { // If we have lifted the primary touch point then tell core the pan is cancelled and change our state to Clear. - SendPan(Gesture::Cancelled, event); + SendPan(Dali::Gesture::Cancelled, event); } mState = Clear; mTouchEvents.clear(); @@ -158,7 +158,7 @@ void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event) else { // We do not satisfy pan conditions, tell Core our Gesture has been cancelled. - SendPan(Gesture::Cancelled, event); + SendPan(Dali::Gesture::Cancelled, event); if (pointCount == 1 && primaryPointState == PointState::UP) { @@ -186,13 +186,13 @@ void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event) { case PointState::MOTION: // Pan is continuing, tell Core. - SendPan(Gesture::Continuing, event); + SendPan(Dali::Gesture::Continuing, event); break; case PointState::UP: // Pan is finally finished when our primary point is lifted, tell Core and change our state to Clear. mState = Clear; - SendPan(Gesture::Finished, event); + SendPan(Dali::Gesture::Finished, event); mTouchEvents.clear(); break; @@ -205,7 +205,7 @@ void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event) if(iter->GetState() == PointState::UP) { // The number of touch points will be less than the minimum required. Inform core and change our state to Finished. - SendPan(Gesture::Finished, event); + SendPan(Dali::Gesture::Finished, event); mState = Finished; break; } @@ -220,7 +220,7 @@ void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event) else { // We have gone outside of the pan requirements, inform Core that the gesture is finished. - SendPan(Gesture::Finished, event); + SendPan(Dali::Gesture::Finished, event); if (pointCount == 1 && primaryPointState == PointState::UP) { @@ -275,7 +275,7 @@ void PanGestureRecognizer::SendPan(Gesture::State state, const Integration::Touc uint32_t previousTime( previousEvent.time ); // If we've just started then we want to remove the threshold from Core calculations. - if ( state == Gesture::Started ) + if ( state == Dali::Gesture::Started ) { previousPosition = mPrimaryTouchDownLocation; previousTime = mPrimaryTouchDownTime; diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.h b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.h index 3a74263..946f6e1 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.h +++ b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_EVENT_PAN_GESTURE_RECOGNIZER_H /* - * Copyright (c) 2019 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. diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.cpp b/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.cpp index 0369322..d1d9776 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.cpp +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -58,7 +58,7 @@ PinchGestureDetectorPtr PinchGestureDetector::New() } PinchGestureDetector::PinchGestureDetector() -: GestureDetector(Gesture::Pinch) +: GestureDetector(Dali::Gesture::Pinch) { } @@ -66,7 +66,7 @@ PinchGestureDetector::~PinchGestureDetector() { } -void PinchGestureDetector::EmitPinchGestureSignal(Dali::Actor actor, const PinchGesture& pinch) +void PinchGestureDetector::EmitPinchGestureSignal(Dali::Actor actor, const Dali::PinchGesture& pinch) { // Guard against destruction during signal emission Dali::PinchGestureDetector handle( this ); diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.h b/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.h index 41113a3..72aab7f 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.h +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H /* - * Copyright (c) 2019 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. @@ -20,13 +20,12 @@ // INTERNAL INCLUDES #include +#include #include namespace Dali { -struct PinchGesture; - namespace Internal { @@ -61,7 +60,7 @@ public: * @param[in] actor The pinched actor. * @param[in] pinch The pinch gesture. */ - void EmitPinchGestureSignal(Dali::Actor actor, const PinchGesture& pinch); + void EmitPinchGestureSignal(Dali::Actor actor, const Dali::PinchGesture& pinch); public: // Signals diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-event.cpp b/dali/internal/event/events/pinch-gesture/pinch-gesture-event.cpp index 161ddca..f525129 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-event.cpp +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -28,7 +28,7 @@ namespace Internal { PinchGestureEvent::PinchGestureEvent(Gesture::State state) -: GestureEvent(Gesture::Pinch, state), +: GestureEvent(Dali::Gesture::Pinch, state), scale(0.0f), speed(0.0f), centerPoint() diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-event.h b/dali/internal/event/events/pinch-gesture/pinch-gesture-event.h index 3aaf3e5..881fe26 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-event.h +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-event.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_EVENT_PINCH_GESTURE_EVENT_H /* - * Copyright (c) 2019 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. diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-impl.h b/dali/internal/event/events/pinch-gesture/pinch-gesture-impl.h new file mode 100644 index 0000000..7cfa82b --- /dev/null +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-impl.h @@ -0,0 +1,164 @@ +#ifndef DALI_INTERNAL_PINCH_GESTURE_H +#define DALI_INTERNAL_PINCH_GESTURE_H + +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +class PinchGesture; +typedef IntrusivePtr< PinchGesture > PinchGesturePtr; + +/** + * @copydoc Dali::PinchGesture + */ +class PinchGesture final : public Gesture +{ +public: + + /** + * @brief Default constructor + */ + PinchGesture( Gesture::State state ) + : Gesture(Dali::Gesture::Pinch, state) + { + } + + PinchGesture(const PinchGesture&) = delete; ///< Deleted copy constructor + PinchGesture(PinchGesture&&) = delete; ///< Deleted move constructor + PinchGesture& operator=(const PinchGesture&) = delete; ///< Deleted copy assignment operator + PinchGesture& operator=(PinchGesture&&) = delete; ///< Deleted move assignment operator + + /** + * @brief The scale factor from the start of the pinch gesture till the latest pinch gesture. + * @param[in] scale The scale to set. + */ + inline void SetScale( float scale ) + { + mScale = scale; + } + + /** + * @copydoc Dali::PinchGesture::GetScale() + */ + inline float GetScale() const + { + return mScale; + } + + /** + * @brief The speed at which the user is moving their fingers. + * @param[in] speed The speed to set. + */ + inline void SetSpeed( float speed ) + { + mSpeed = speed; + } + + /** + * @copydoc Dali::PinchGesture::GetSpeed() + */ + inline float GetSpeed() const + { + return mSpeed; + } + + /** + * @brief The center point of the two points that caused the pinch gesture in screen coordinates. + * @param[in] screenCenterPoint The point in screen coordinates to set. + */ + inline void SetScreenCenterPoint( const Vector2& screenCenterPoint ) + { + mScreenCenterPoint = screenCenterPoint; + } + + /** + * @copydoc Dali::PinchGesture::GetScreenCenterPoint() + */ + inline const Vector2& GetScreenCenterPoint() const + { + return mScreenCenterPoint; + } + + /** + * @brief The center point of the two points that caused the pinch gesture in local actor coordinates. + * @param[in] localCenterPoint The point in local actor coordinates to set. + */ + inline void SetLocalCenterPoint( const Vector2& localCenterPoint ) + { + mLocalCenterPoint = localCenterPoint; + } + + /** + * @copydoc Dali::PinchGesture::GetLocalCenterPoint() + */ + inline const Vector2& GetLocalCenterPoint() const + { + return mLocalCenterPoint; + } + +private: + + /** + * @brief Virtual destructor + * + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~PinchGesture() = default; + +private: + Vector2 mScreenCenterPoint; + Vector2 mLocalCenterPoint; + float mScale{0.0f}; + float mSpeed{0.0f}; +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods + +inline Internal::PinchGesture& GetImplementation( Dali::PinchGesture& pinchGesture ) +{ + DALI_ASSERT_ALWAYS( pinchGesture && "pinchGesture handle is empty" ); + + BaseObject& object = pinchGesture.GetBaseObject(); + + return static_cast< Internal::PinchGesture& >( object ); +} + +inline const Internal::PinchGesture& GetImplementation( const Dali::PinchGesture& pinchGesture ) +{ + DALI_ASSERT_ALWAYS( pinchGesture && "pinchGesture handle is empty" ); + + const BaseObject& object = pinchGesture.GetBaseObject(); + + return static_cast< const Internal::PinchGesture& >( object ); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_PINCH_GESTURE_H diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-processor.cpp b/dali/internal/event/events/pinch-gesture/pinch-gesture-processor.cpp index 73e7b37..324f9ff 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-processor.cpp +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-processor.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace Dali @@ -56,20 +57,20 @@ void EmitPinchSignal( const PinchGestureEvent& pinchEvent, Vector2 localCenter) { - PinchGesture pinch(pinchEvent.state); - pinch.time = pinchEvent.time; + Internal::PinchGesturePtr pinch( new Internal::PinchGesture(pinchEvent.state ) ); + pinch->SetTime( pinchEvent.time ); - pinch.scale = pinchEvent.scale; - pinch.speed = pinchEvent.speed; - pinch.screenCenterPoint = pinchEvent.centerPoint; + pinch->SetScale( pinchEvent.scale ); + pinch->SetSpeed( pinchEvent.speed ); + pinch->SetScreenCenterPoint( pinchEvent.centerPoint ); - pinch.localCenterPoint = localCenter; + pinch->SetLocalCenterPoint( localCenter ); Dali::Actor actorHandle( actor ); const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end(); for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter ) { - static_cast< PinchGestureDetector* >( *iter )->EmitPinchGestureSignal( actorHandle, pinch ); + static_cast< PinchGestureDetector* >( *iter )->EmitPinchGestureSignal( actorHandle, Dali::PinchGesture( pinch.Get() ) ); } } @@ -104,7 +105,7 @@ struct IsNotAttachedFunctor } // unnamed namespace PinchGestureProcessor::PinchGestureProcessor() -: GestureProcessor( Gesture::Pinch ), +: GestureProcessor( Dali::Gesture::Pinch ), mPinchGestureDetectors(), mCurrentPinchEmitters(), mCurrentPinchEvent(NULL), @@ -170,7 +171,7 @@ void PinchGestureProcessor::Process( Scene& scene, const PinchGestureEvent& pinc { switch ( pinchEvent.state ) { - case Gesture::Started: + case Dali::Gesture::Started: { // The pinch gesture should only be sent to the gesture detector which first received it so that // it can be told when the gesture ends as well. @@ -192,9 +193,9 @@ void PinchGestureProcessor::Process( Scene& scene, const PinchGestureEvent& pinc break; } - case Gesture::Continuing: - case Gesture::Finished: - case Gesture::Cancelled: + case Dali::Gesture::Continuing: + case Dali::Gesture::Finished: + case Dali::Gesture::Cancelled: { // Only send subsequent pinch gesture signals if we processed the pinch gesture when it started. // Check if actor is still touchable. @@ -223,7 +224,7 @@ void PinchGestureProcessor::Process( Scene& scene, const PinchGestureEvent& pinc } // Clear current emitters if pinch gesture has ended or been cancelled. - if ( pinchEvent.state == Gesture::Finished || pinchEvent.state == Gesture::Cancelled ) + if ( pinchEvent.state == Dali::Gesture::Finished || pinchEvent.state == Dali::Gesture::Cancelled ) { mCurrentPinchEmitters.clear(); ResetActor(); @@ -238,12 +239,12 @@ void PinchGestureProcessor::Process( Scene& scene, const PinchGestureEvent& pinc break; } - case Gesture::Clear: + case Dali::Gesture::Clear: { DALI_ABORT( "Incorrect state received from Integration layer: Clear\n" ); break; } - case Gesture::Possible: + case Dali::Gesture::Possible: { DALI_ABORT( "Incorrect state received from Integration layer: Possible\n" ); break; diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp b/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp index a552ca7..7d1df48 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp @@ -66,7 +66,7 @@ inline float GetDefaultMinimumPinchDistance( const Vector2& dpi ) } // unnamed namespace PinchGestureRecognizer::PinchGestureRecognizer( Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart ) -: GestureRecognizer( screenSize, Gesture::Pinch ), +: GestureRecognizer( screenSize, Dali::Gesture::Pinch ), mObserver( observer ), mState( Clear ), mTouchEvents(), @@ -149,7 +149,7 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event) mStartingDistance = GetDistance(mTouchEvents.begin()->points[0], mTouchEvents.begin()->points[1]); // Send pinch started - SendPinch(Gesture::Started, event); + SendPinch(Dali::Gesture::Started, event); mState = Started; } @@ -175,14 +175,14 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event) { // System interruption occurred, pinch should be cancelled mTouchEvents.clear(); - SendPinch(Gesture::Cancelled, event); + SendPinch(Dali::Gesture::Cancelled, event); mState = Clear; mTouchEvents.clear(); } else if (pointCount != 2) { // Send pinch finished event - SendPinch(Gesture::Finished, event); + SendPinch(Dali::Gesture::Finished, event); mState = Clear; mTouchEvents.clear(); @@ -196,7 +196,7 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event) { mTouchEvents.push_back(event); // Send pinch finished event - SendPinch(Gesture::Finished, event); + SendPinch(Dali::Gesture::Finished, event); mState = Clear; mTouchEvents.clear(); @@ -208,7 +208,7 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event) if( mTouchEvents.size() >= mMinimumTouchEventsAfterStart ) { // Send pinch continuing - SendPinch(Gesture::Continuing, event); + SendPinch(Dali::Gesture::Continuing, event); mTouchEvents.clear(); } @@ -261,7 +261,7 @@ void PinchGestureRecognizer::SendPinch(Gesture::State state, const Integration:: else { // Something has gone wrong, just cancel the gesture. - gesture.state = Gesture::Cancelled; + gesture.state = Dali::Gesture::Cancelled; } gesture.time = currentEvent.time; diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.h b/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.h index 7bc429d..6d91450 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.h +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_EVENT_PINCH_GESTURE_RECOGNIZER_H /* - * Copyright (c) 2019 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. diff --git a/dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.cpp b/dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.cpp index debf1d0..b26f8f8 100644 --- a/dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.cpp +++ b/dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.cpp @@ -58,11 +58,11 @@ RotationGestureDetectorPtr RotationGestureDetector::New() } RotationGestureDetector::RotationGestureDetector() -: GestureDetector( Gesture::Rotation ) +: GestureDetector( Dali::Gesture::Rotation ) { } -void RotationGestureDetector::EmitRotationGestureSignal( Dali::Actor actor, const RotationGesture& rotation ) +void RotationGestureDetector::EmitRotationGestureSignal( Dali::Actor actor, const Dali::RotationGesture& rotation ) { // Guard against destruction during signal emission Dali::RotationGestureDetector handle( this ); diff --git a/dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.h b/dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.h index 8af877a..dca87d8 100644 --- a/dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.h +++ b/dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.h @@ -20,13 +20,12 @@ // INTERNAL INCLUDES #include +#include #include namespace Dali { -struct RotationGesture; - namespace Internal { @@ -66,7 +65,7 @@ public: * @param[in] actor The rotated actor * @param[in] rotation The rotation gesture */ - void EmitRotationGestureSignal( Dali::Actor actor, const RotationGesture& rotation ); + void EmitRotationGestureSignal( Dali::Actor actor, const Dali::RotationGesture& rotation ); public: // Signals diff --git a/dali/internal/event/events/rotation-gesture/rotation-gesture-event.h b/dali/internal/event/events/rotation-gesture/rotation-gesture-event.h index 436c7cd..31891e9 100644 --- a/dali/internal/event/events/rotation-gesture/rotation-gesture-event.h +++ b/dali/internal/event/events/rotation-gesture/rotation-gesture-event.h @@ -47,7 +47,7 @@ struct RotationGestureEvent : public GestureEvent * @param[in] state The state of the gesture */ RotationGestureEvent( Gesture::State state ) - : GestureEvent( Gesture::Rotation, state ) + : GestureEvent( Dali::Gesture::Rotation, state ) { } diff --git a/dali/internal/event/events/rotation-gesture/rotation-gesture-impl.h b/dali/internal/event/events/rotation-gesture/rotation-gesture-impl.h new file mode 100644 index 0000000..95fbc41 --- /dev/null +++ b/dali/internal/event/events/rotation-gesture/rotation-gesture-impl.h @@ -0,0 +1,146 @@ +#ifndef DALI_INTERNAL_ROTATION_GESTURE_H +#define DALI_INTERNAL_ROTATION_GESTURE_H + +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +class RotationGesture; +typedef IntrusivePtr< RotationGesture > RotationGesturePtr; + +/** + * @copydoc Dali::RotationGesture + */ +class RotationGesture final : public Gesture +{ +public: + + /** + * @brief Default constructor + */ + RotationGesture( Gesture::State state ) + : Gesture( Dali::Gesture::Rotation, state ) + { + } + + RotationGesture(const RotationGesture&) = delete; ///< Deleted copy constructor + RotationGesture(RotationGesture&&) = delete; ///< Deleted move constructor + RotationGesture& operator=(const RotationGesture&) = delete; ///< Deleted copy assignment operator + RotationGesture& operator=(RotationGesture&&) = delete; ///< Deleted move assignment operator + + /** + * @brief The overall rotation from the start of the rotation gesture till the latest rotation gesture. + * @param[in] rotation The rotation to set. + */ + inline void SetRotation( const Radian& rotation ) + { + mRotation = rotation; + } + + /** + * @copydoc Dali::RotationGesture::GetRotation() + */ + inline const Radian& GetRotation() const + { + return mRotation; + } + + /** + * @brief The center point of the two points that caused the rotation gesture in screen coordinates. + * @param[in] screenCenterPoint The point in screen coordinates to set. + */ + inline void SetScreenCenterPoint( const Vector2& screenCenterPoint ) + { + mScreenCenterPoint = screenCenterPoint; + } + + /** + * @copydoc Dali::RotationGesture::GetScreenCenterPoint() + */ + inline const Vector2& GetScreenCenterPoint() const + { + return mScreenCenterPoint; + } + + /** + * @brief The center point of the two points that caused the rotation gesture in local actor coordinates. + * @param[in] localCenterPoint The point in local actor coordinates to set. + */ + inline void SetLocalCenterPoint( const Vector2& localCenterPoint ) + { + mLocalCenterPoint = localCenterPoint; + } + + /** + * @copydoc Dali::RotationGesture::GetLocalCenterPoint() + */ + inline const Vector2& GetLocalCenterPoint() const + { + return mLocalCenterPoint; + } + +private: + + /** + * @brief Virtual destructor + * + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~RotationGesture() = default; + +private: + Radian mRotation; + Vector2 mScreenCenterPoint; + Vector2 mLocalCenterPoint; +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods + +inline Internal::RotationGesture& GetImplementation( Dali::RotationGesture& rotationGesture ) +{ + DALI_ASSERT_ALWAYS( rotationGesture && "rotationGesture handle is empty" ); + + BaseObject& object = rotationGesture.GetBaseObject(); + + return static_cast< Internal::RotationGesture& >( object ); +} + +inline const Internal::RotationGesture& GetImplementation( const Dali::RotationGesture& rotationGesture ) +{ + DALI_ASSERT_ALWAYS( rotationGesture && "rotationGesture handle is empty" ); + + const BaseObject& object = rotationGesture.GetBaseObject(); + + return static_cast< const Internal::RotationGesture& >( object ); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_ROTATION_GESTURE_H diff --git a/dali/internal/event/events/rotation-gesture/rotation-gesture-processor.cpp b/dali/internal/event/events/rotation-gesture/rotation-gesture-processor.cpp index 45a7719..13287df 100644 --- a/dali/internal/event/events/rotation-gesture/rotation-gesture-processor.cpp +++ b/dali/internal/event/events/rotation-gesture/rotation-gesture-processor.cpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace Dali { @@ -56,17 +57,17 @@ void EmitRotationSignal( const RotationGestureEvent& rotationEvent, Vector2 localCenter) { - RotationGesture rotation(rotationEvent.state); - rotation.time = rotationEvent.time; - rotation.rotation = rotationEvent.rotation; - rotation.screenCenterPoint = rotationEvent.centerPoint; - rotation.localCenterPoint = localCenter; + Internal::RotationGesturePtr rotation( new Internal::RotationGesture(rotationEvent.state ) ); + rotation->SetTime( rotationEvent.time ); + rotation->SetRotation( rotationEvent.rotation ); + rotation->SetScreenCenterPoint( rotationEvent.centerPoint ); + rotation->SetLocalCenterPoint( localCenter ); Dali::Actor actorHandle( actor ); const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end(); for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter ) { - static_cast< RotationGestureDetector* >( *iter )->EmitRotationGestureSignal( actorHandle, rotation ); + static_cast< RotationGestureDetector* >( *iter )->EmitRotationGestureSignal( actorHandle, Dali::RotationGesture( rotation.Get() ) ); } } @@ -101,7 +102,7 @@ struct IsNotAttachedFunctor } // unnamed namespace RotationGestureProcessor::RotationGestureProcessor() -: GestureProcessor( Gesture::Rotation ), +: GestureProcessor( Dali::Gesture::Rotation ), mRotationGestureDetectors(), mCurrentRotationEmitters(), mCurrentRotationEvent( nullptr ), @@ -114,7 +115,7 @@ void RotationGestureProcessor::Process( Scene& scene, const RotationGestureEvent { switch ( rotationEvent.state ) { - case Gesture::Started: + case Dali::Gesture::Started: { // The rotation gesture should only be sent to the gesture detector which first received it so that // it can be told when the gesture ends as well. @@ -136,9 +137,9 @@ void RotationGestureProcessor::Process( Scene& scene, const RotationGestureEvent break; } - case Gesture::Continuing: - case Gesture::Finished: - case Gesture::Cancelled: + case Dali::Gesture::Continuing: + case Dali::Gesture::Finished: + case Dali::Gesture::Cancelled: { // Only send subsequent rotation gesture signals if we processed the rotation gesture when it started. // Check if actor is still touchable. @@ -167,7 +168,7 @@ void RotationGestureProcessor::Process( Scene& scene, const RotationGestureEvent } // Clear current emitters if rotation gesture has ended or been cancelled. - if ( rotationEvent.state == Gesture::Finished || rotationEvent.state == Gesture::Cancelled ) + if ( rotationEvent.state == Dali::Gesture::Finished || rotationEvent.state == Dali::Gesture::Cancelled ) { mCurrentRotationEmitters.clear(); ResetActor(); @@ -182,8 +183,8 @@ void RotationGestureProcessor::Process( Scene& scene, const RotationGestureEvent break; } - case Gesture::Clear: - case Gesture::Possible: + case Dali::Gesture::Clear: + case Dali::Gesture::Possible: { // Nothing to do break; diff --git a/dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.cpp b/dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.cpp index c4911aa..36b7fa2 100644 --- a/dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.cpp +++ b/dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.cpp @@ -55,7 +55,7 @@ inline Vector2 GetCenterPoint( const Integration::Point& point1, const Integrati } // unnamed namespace RotationGestureRecognizer::RotationGestureRecognizer( Observer& observer, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart ) -: GestureRecognizer( Gesture::Rotation ), +: GestureRecognizer( Dali::Gesture::Rotation ), mObserver( observer ), mState( Clear ), mTouchEvents(), @@ -117,7 +117,7 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event mStartingAngle = GetAngle( mTouchEvents.begin()->points[0], mTouchEvents.begin()->points[1] ); // Send rotation started - SendRotation( Gesture::Started, event ); + SendRotation( Dali::Gesture::Started, event ); mState = Started; } @@ -142,14 +142,14 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event { // System interruption occurred, rotation should be cancelled mTouchEvents.clear(); - SendRotation(Gesture::Cancelled, event); + SendRotation(Dali::Gesture::Cancelled, event); mState = Clear; mTouchEvents.clear(); } else if( pointCount != 2 ) { // Send rotation finished event - SendRotation( Gesture::Finished, event ); + SendRotation( Dali::Gesture::Finished, event ); mState = Clear; mTouchEvents.clear(); @@ -164,7 +164,7 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event { mTouchEvents.push_back( event ); // Send rotation finished event - SendRotation( Gesture::Finished, event ); + SendRotation( Dali::Gesture::Finished, event ); mState = Clear; mTouchEvents.clear(); @@ -176,7 +176,7 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event if( mTouchEvents.size() >= mMinimumTouchEventsAfterStart ) { // Send rotation continuing - SendRotation( Gesture::Continuing, event ); + SendRotation( Dali::Gesture::Continuing, event ); mTouchEvents.clear(); } @@ -200,7 +200,6 @@ void RotationGestureRecognizer::SetMinimumTouchEventsAfterStart( uint32_t value void RotationGestureRecognizer::SendRotation( Gesture::State state, const Integration::TouchEvent& currentEvent ) { RotationGestureEvent gesture( state ); - if( !mTouchEvents.empty() ) { // Assert if we have been holding TouchEvents that do not have 2 points @@ -223,7 +222,7 @@ void RotationGestureRecognizer::SendRotation( Gesture::State state, const Integr else { // Something has gone wrong, just cancel the gesture. - gesture.state = Gesture::Cancelled; + gesture.state = Dali::Gesture::Cancelled; } gesture.time = currentEvent.time; diff --git a/dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.h b/dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.h index 0890f2c..14c21f9 100644 --- a/dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.h +++ b/dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_EVENT_ROTATION_GESTURE_RECOGNIZER_H /* - * Copyright (c) 2019 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. diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.cpp b/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.cpp index 93c4712..f999d9b 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.cpp +++ b/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -64,7 +64,7 @@ TapGestureDetectorPtr TapGestureDetector::New( unsigned int tapsRequired ) } TapGestureDetector::TapGestureDetector() -: GestureDetector( Gesture::Tap ), +: GestureDetector( Dali::Gesture::Tap ), mMinimumTapsRequired( DEFAULT_TAPS_REQUIRED ), mMaximumTapsRequired( DEFAULT_TAPS_REQUIRED ), mTouchesRequired( DEFAULT_TOUCHES_REQUIRED ) @@ -72,7 +72,7 @@ TapGestureDetector::TapGestureDetector() } TapGestureDetector::TapGestureDetector( unsigned int tapsRequired ) -: GestureDetector( Gesture::Tap ), +: GestureDetector( Dali::Gesture::Tap ), mMinimumTapsRequired( tapsRequired ), mMaximumTapsRequired( tapsRequired ), mTouchesRequired( DEFAULT_TOUCHES_REQUIRED ) @@ -137,7 +137,7 @@ unsigned int TapGestureDetector::GetTouchesRequired() const return mTouchesRequired; } -void TapGestureDetector::EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap) +void TapGestureDetector::EmitTapGestureSignal(Dali::Actor tappedActor, const Dali::TapGesture& tap) { // Guard against destruction during signal emission Dali::TapGestureDetector handle( this ); diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.h b/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.h index 5d368b2..77fa988 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.h +++ b/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_TAP_GESTURE_DETECTOR_H /* - * Copyright (c) 2019 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. @@ -20,13 +20,12 @@ // INTERNAL INCLUDES #include +#include #include namespace Dali { -struct TapGesture; - namespace Internal { @@ -106,7 +105,7 @@ public: * @param[in] tappedActor The tapped actor. * @param[in] tap The tap gesture. */ - void EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap); + void EmitTapGestureSignal(Dali::Actor tappedActor, const Dali::TapGesture& tap); public: // Signals diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-event.cpp b/dali/internal/event/events/tap-gesture/tap-gesture-event.cpp index d9f5171..eb53266 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-event.cpp +++ b/dali/internal/event/events/tap-gesture/tap-gesture-event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -25,7 +25,7 @@ namespace Internal { TapGestureEvent::TapGestureEvent( Gesture::State state ) -: GestureEvent(Gesture::Tap, state), +: GestureEvent(Dali::Gesture::Tap, state), numberOfTaps(1), numberOfTouches(1) { diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-event.h b/dali/internal/event/events/tap-gesture/tap-gesture-event.h index ee84e60..c158991 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-event.h +++ b/dali/internal/event/events/tap-gesture/tap-gesture-event.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_EVENT_TAP_GESTURE_H /* - * Copyright (c) 2019 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. diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-impl.h b/dali/internal/event/events/tap-gesture/tap-gesture-impl.h new file mode 100644 index 0000000..cdbef66 --- /dev/null +++ b/dali/internal/event/events/tap-gesture/tap-gesture-impl.h @@ -0,0 +1,164 @@ +#ifndef DALI_INTERNAL_TAP_GESTURE_H +#define DALI_INTERNAL_TAP_GESTURE_H + +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +class TapGesture; +typedef IntrusivePtr< TapGesture > TapGesturePtr; + +/** + * @copydoc Dali::TapGesture + */ +class TapGesture final : public Gesture +{ +public: + + /** + * @brief Default constructor + */ + TapGesture( Gesture::State state ) + : Gesture(Dali::Gesture::Tap, state) + { + } + + TapGesture(const TapGesture&) = delete; ///< Deleted copy constructor + TapGesture(TapGesture&&) = delete; ///< Deleted move constructor + TapGesture& operator=(const TapGesture&) = delete; ///< Deleted copy assignment operator + TapGesture& operator=(TapGesture&&) = delete; ///< Deleted move assignment operator + + /** + * @brief The number of taps in this tap gesture. + * @param[in] numberOfTaps The number of taps to set. + */ + inline void SetNumberOfTaps( uint32_t numberOfTaps ) + { + mNumberOfTaps = numberOfTaps; + } + + /** + * @copydoc Dali::TapGesture::GetNumberOfTaps() + */ + inline uint32_t GetNumberOfTaps() const + { + return mNumberOfTaps; + } + + /** + * @brief The number of touch points in this tap gesture, i.e. the number of fingers the user had on the screen to generate the tap gesture. + * @param[in] numberOfTouches The number of touch points in this tap gesture to set. + */ + inline void SetNumberOfTouches( uint32_t numberOfTouches ) + { + mNumberOfTouches = numberOfTouches; + } + + /** + * @copydoc Dali::TapGesture::GetPointCount() + */ + inline uint32_t GetNumberOfTouches() const + { + return mNumberOfTouches; + } + + /** + * @brief This is the point, in screen coordinates, where the tap occurred. + * @param[in] screenPoint The point in screen coordinates to set. + */ + inline void SetScreenPoint( const Vector2& screenPoint ) + { + mScreenPoint = screenPoint; + } + + /** + * @copydoc Dali::TapGesture::GetDeviceId() + */ + inline const Vector2& GetScreenPoint() const + { + return mScreenPoint; + } + + /** + * @brief This is the point, in local actor coordinates, where the tap occurred. + * @param[in] localPoint The point in local actor coordinates to set. + */ + inline void SetLocalPoint( const Vector2& localPoint ) + { + mLocalPoint = localPoint; + } + + /** + * @copydoc Dali::TapGesture::GetGetState() + */ + inline const Vector2& GetLocalPoint() const + { + return mLocalPoint; + } + +private: + + /** + * @brief Virtual destructor + * + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~TapGesture() = default; + +private: + Vector2 mScreenPoint; + Vector2 mLocalPoint; + uint32_t mNumberOfTaps{1u}; + uint32_t mNumberOfTouches{1u}; +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods + +inline Internal::TapGesture& GetImplementation( Dali::TapGesture& tapGesture ) +{ + DALI_ASSERT_ALWAYS( tapGesture && "TapGesture handle is empty" ); + + BaseObject& object = tapGesture.GetBaseObject(); + + return static_cast< Internal::TapGesture& >( object ); +} + +inline const Internal::TapGesture& GetImplementation( const Dali::TapGesture& tapGesture ) +{ + DALI_ASSERT_ALWAYS( tapGesture && "TapGesture handle is empty" ); + + const BaseObject& object = tapGesture.GetBaseObject(); + + return static_cast< const Internal::TapGesture& >( object ); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_TAP_GESTURE_H diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-processor.cpp b/dali/internal/event/events/tap-gesture/tap-gesture-processor.cpp index cf74b6f..b327904 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-processor.cpp +++ b/dali/internal/event/events/tap-gesture/tap-gesture-processor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -56,25 +57,25 @@ void EmitTapSignal( const TapGestureEvent& tapEvent, Vector2 localPoint) { - TapGesture tap; - tap.time = tapEvent.time; - tap.numberOfTaps = tapEvent.numberOfTaps; - tap.numberOfTouches = tapEvent.numberOfTouches; - tap.screenPoint = tapEvent.point; - tap.localPoint = localPoint; + Internal::TapGesturePtr tap( new Internal::TapGesture(tapEvent.state) ); + tap->SetTime( tapEvent.time ); + tap->SetNumberOfTaps(tapEvent.numberOfTaps); + tap->SetNumberOfTouches(tapEvent.numberOfTouches); + tap->SetScreenPoint(tapEvent.point); + tap->SetLocalPoint(localPoint); Dali::Actor actorHandle( actor ); const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end(); for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter ) { - static_cast< TapGestureDetector* >( *iter )->EmitTapGestureSignal( actorHandle, tap ); + static_cast< TapGestureDetector* >( *iter )->EmitTapGestureSignal( actorHandle, Dali::TapGesture( tap.Get() ) ); } } } // unnamed namespace TapGestureProcessor::TapGestureProcessor() -: GestureProcessor( Gesture::Tap ), +: GestureProcessor( Dali::Gesture::Tap ), mTapGestureDetectors(), mMinTapsRequired( 1 ), mMaxTapsRequired( 1 ), @@ -93,7 +94,7 @@ void TapGestureProcessor::Process( Scene& scene, const TapGestureEvent& tapEvent { switch ( tapEvent.state ) { - case Gesture::Possible: + case Dali::Gesture::Possible: { // Do a hit test and if an actor has been hit then save to see if tap event is still valid on a tap( same actor being hit ) HitTestAlgorithm::Results hitTestResults; @@ -112,7 +113,7 @@ void TapGestureProcessor::Process( Scene& scene, const TapGestureEvent& tapEvent break; } - case Gesture::Started: + case Dali::Gesture::Started: { // Ensure that we're processing a hit on the current actor and that we've already processed a touch down HitTestAlgorithm::Results hitTestResults; @@ -130,24 +131,24 @@ void TapGestureProcessor::Process( Scene& scene, const TapGestureEvent& tapEvent break; } - case Gesture::Cancelled: + case Dali::Gesture::Cancelled: { mPossibleProcessed = false; ResetActor(); break; } - case Gesture::Continuing: + case Dali::Gesture::Continuing: { DALI_ABORT( "Incorrect state received from Integration layer: Continuing\n" ); break; } - case Gesture::Finished: + case Dali::Gesture::Finished: { DALI_ABORT( "Incorrect state received from Integration layer: Finished\n" ); break; } - case Gesture::Clear: + case Dali::Gesture::Clear: { DALI_ABORT( "Incorrect state received from Integration layer: Clear\n" ); break; diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.cpp b/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.cpp index c8707dc..9170dea 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.cpp +++ b/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.cpp @@ -43,7 +43,7 @@ const unsigned long MAXIMUM_TIME_ALLOWED = 500u; } // unnamed namespace TapGestureRecognizer::TapGestureRecognizer( Observer& observer, Vector2 screenSize, const TapGestureRequest& request) -: GestureRecognizer( screenSize, Gesture::Tap ), +: GestureRecognizer( screenSize, Dali::Gesture::Tap ), mObserver(observer), mState(Clear), mMinimumTapsRequired(request.minTaps), @@ -122,7 +122,7 @@ void TapGestureRecognizer::SendEvent(const Integration::TouchEvent& event) else { ++mTapsRegistered; - EmitGesture( Gesture::Started, event.time ); + EmitGesture( Dali::Gesture::Started, event.time ); mState = Clear; } } @@ -166,7 +166,7 @@ void TapGestureRecognizer::SendEvent(const Integration::TouchEvent& event) mState = Failed; // We have entered a multi-touch event so emit registered gestures if required. - EmitGesture(Gesture::Started, event.time); + EmitGesture(Dali::Gesture::Started, event.time); } } @@ -182,7 +182,7 @@ void TapGestureRecognizer::SetupForTouchDown( const Integration::TouchEvent& eve void TapGestureRecognizer::EmitPossibleState( const Integration::TouchEvent& event ) { - TapGestureEvent tapEvent( Gesture::Possible ); + TapGestureEvent tapEvent( Dali::Gesture::Possible ); tapEvent.point = mTouchPosition; tapEvent.time = event.time; @@ -200,7 +200,7 @@ void TapGestureRecognizer::Update(const GestureRequest& request) void TapGestureRecognizer::EmitGesture( Gesture::State state, uint32_t time ) { - if ( (state == Gesture::Cancelled) || + if ( (state == Dali::Gesture::Cancelled) || (mTapsRegistered >= mMinimumTapsRequired && mTapsRegistered <= mMaximumTapsRequired) ) { @@ -211,7 +211,7 @@ void TapGestureRecognizer::EmitGesture( Gesture::State state, uint32_t time ) void TapGestureRecognizer::EmitSingleTap( uint32_t time, const Integration::Point& point ) { - TapGestureEvent event( Gesture::Started ); + TapGestureEvent event( Dali::Gesture::Started ); const Vector2& screen( point.GetScreenPosition() ); Vector2 distanceDelta(std::abs(mTouchPosition.x - screen.x), std::abs(mTouchPosition.y - screen.y)); @@ -219,7 +219,7 @@ void TapGestureRecognizer::EmitSingleTap( uint32_t time, const Integration::Poin if (distanceDelta.x > MAXIMUM_MOTION_ALLOWED || distanceDelta.y > MAXIMUM_MOTION_ALLOWED ) { - event.state = Gesture::Cancelled; + event.state = Dali::Gesture::Cancelled; } mTapsRegistered = 1u; EmitTap( time, event ); diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.h b/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.h index be4a002..f65eb63 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.h +++ b/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_H /* - * Copyright (c) 2019 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. diff --git a/dali/internal/update/gestures/scene-graph-pan-gesture.cpp b/dali/internal/update/gestures/scene-graph-pan-gesture.cpp index 217b78a..3f1247e 100644 --- a/dali/internal/update/gestures/scene-graph-pan-gesture.cpp +++ b/dali/internal/update/gestures/scene-graph-pan-gesture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 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. @@ -86,7 +86,7 @@ PanGesture::~PanGesture() delete mProfiling; } -void PanGesture::AddGesture( const Dali::PanGesture& gesture ) +void PanGesture::AddGesture( const Internal::PanGesture& gesture ) { Dali::Mutex::ScopedLock lock( mMutex ); mGestures[ mWritePosition ] = gesture; @@ -267,13 +267,13 @@ bool PanGesture::ReadGestures( FrameGestureInfo& info, unsigned int currentTimes // add event to history mPanHistory.push_back( currentGesture ); - if( currentGesture.state == Gesture::Started ) + if( currentGesture.state == Dali::Gesture::Started ) { info.justStarted = true; // clear just finished as we have started new pan info.justFinished = false; } - info.justFinished |= ( currentGesture.state == Gesture::Finished || currentGesture.state == Gesture::Cancelled ); + info.justFinished |= ( currentGesture.state == Dali::Gesture::Finished || currentGesture.state == Dali::Gesture::Cancelled ); // Update our read position. previousReadPosition = mReadPosition; @@ -304,7 +304,7 @@ bool PanGesture::ReadAndResampleGestures( FrameGestureInfo& info, unsigned int c info.frameGesture.screen.velocity += lastReadGesture.screen.velocity; info.frameGesture.local.velocity += lastReadGesture.local.velocity; - if( lastReadGesture.state == Gesture::Started ) + if( lastReadGesture.state == Dali::Gesture::Started ) { // Clear just finished as we have started new pan. info.justFinished = false; @@ -312,7 +312,7 @@ bool PanGesture::ReadAndResampleGestures( FrameGestureInfo& info, unsigned int c } else { - info.justFinished |= ( lastReadGesture.state == Gesture::Finished || lastReadGesture.state == Gesture::Cancelled ); + info.justFinished |= ( lastReadGesture.state == Dali::Gesture::Finished || lastReadGesture.state == Dali::Gesture::Cancelled ); } // Add event to history @@ -759,7 +759,7 @@ bool PanGesture::InputRateConversion( PanInfo& rateConvertedGesture, unsigned in readGesture.screen.displacement, readGesture.screen.velocity, readGesture.state ) ); } - if( readGesture.state == Gesture::Started ) + if( readGesture.state == Dali::Gesture::Started ) { // Clear pan data. mPanHistory.clear(); @@ -792,7 +792,7 @@ bool PanGesture::InputRateConversion( PanInfo& rateConvertedGesture, unsigned in } else { - justFinished |= ( readGesture.state == Gesture::Finished || readGesture.state == Gesture::Cancelled ); + justFinished |= ( readGesture.state == Dali::Gesture::Finished || readGesture.state == Dali::Gesture::Cancelled ); } rateConvertedGesture.screen.position += readGesture.screen.position; diff --git a/dali/internal/update/gestures/scene-graph-pan-gesture.h b/dali/internal/update/gestures/scene-graph-pan-gesture.h index 70ebdfb..cf21919 100644 --- a/dali/internal/update/gestures/scene-graph-pan-gesture.h +++ b/dali/internal/update/gestures/scene-graph-pan-gesture.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_PAN_GESTURE_H /* - * Copyright (c) 2019 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. @@ -21,14 +21,14 @@ // INTERNAL INCLUDES #include #include -#include +#include #include #include namespace Dali { -struct PanGesture; +class PanGesture; namespace Internal { @@ -118,7 +118,7 @@ public: */ PanInfo() : time( 0u ), - state( Gesture::Clear ), + state( Dali::Gesture::Clear ), read( true ) { } @@ -156,18 +156,18 @@ public: * Assignment operator * @param[in] gesture A Dali::Gesture */ - PanInfo& operator=( const Dali::PanGesture& rhs ) + PanInfo& operator=( const Internal::PanGesture& rhs ) { - time = rhs.time; - state = rhs.state; + time = rhs.GetTime(); + state = rhs.GetState(); - local.velocity = rhs.velocity; - local.displacement = rhs.displacement; - local.position = rhs.position; + local.velocity = rhs.GetVelocity(); + local.displacement = rhs.GetDisplacement(); + local.position = rhs.GetPosition(); - screen.velocity = rhs.screenVelocity; - screen.displacement = rhs.screenDisplacement; - screen.position = rhs.screenPosition; + screen.velocity = rhs.GetScreenVelocity(); + screen.displacement = rhs.GetScreenDisplacement(); + screen.position = rhs.GetScreenPosition(); return *this; } @@ -203,7 +203,7 @@ public: * Adds a PanGesture to the internal circular-buffer waiting to be handled by UpdateProperties. * @param[in] gesture The latest pan gesture. */ - void AddGesture( const Dali::PanGesture& gesture ); + void AddGesture( const Internal::PanGesture& gesture ); /** * @brief Removes pan events from the history that are older than maxAge, leaving at least minEvents diff --git a/dali/public-api/events/gesture.cpp b/dali/public-api/events/gesture.cpp index 0ceaadf..2af5ea8 100644 --- a/dali/public-api/events/gesture.cpp +++ b/dali/public-api/events/gesture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -18,37 +18,46 @@ // CLASS HEADER #include +// INTERNAL INCLUDES +#include + namespace Dali { -Gesture::Gesture( const Gesture& rhs ) -: type(rhs.type), - state(rhs.state), - time(rhs.time) +Gesture::Gesture() { } -Gesture& Gesture::operator=( const Gesture& rhs ) +Gesture::Gesture(Internal::Gesture* internal) +: BaseHandle(internal) { - if( this != &rhs ) - { - type = rhs.type; - state = rhs.state; - time = rhs.time; - } - - return *this; } +Gesture::Gesture( const Gesture& rhs ) = default; + +Gesture::Gesture( Gesture&& rhs ) = default; + +Gesture& Gesture::operator=( const Gesture& rhs ) = default; + +Gesture& Gesture::operator=( Gesture&& rhs ) = default; + Gesture::~Gesture() { } -Gesture::Gesture(Type gestureType, State gestureState) -: type(gestureType), - state(gestureState), - time(0) +Gesture::Type Gesture::GetType() const +{ + return GetImplementation(*this).GetType(); +} + +Gesture::State Gesture::GetState() const +{ + return GetImplementation(*this).GetState(); +} + +uint32_t Gesture::GetTime() const { + return GetImplementation(*this).GetTime(); } } // namespace Dali diff --git a/dali/public-api/events/gesture.h b/dali/public-api/events/gesture.h index 0e9a6ff..e634b9a 100644 --- a/dali/public-api/events/gesture.h +++ b/dali/public-api/events/gesture.h @@ -23,6 +23,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -31,6 +32,11 @@ namespace Dali * @{ */ +namespace Internal DALI_INTERNAL +{ +class Gesture; +} + /** * @brief Base structure for different gestures that an application can receive. * @@ -41,35 +47,58 @@ namespace Dali * To receive a particular gesture, the application has to create and connect to the appropriate * GestureDetector. * - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @note An instance of this class cannot be created. * @see GestureDetector * */ -struct DALI_CORE_API Gesture +class DALI_CORE_API Gesture : public BaseHandle { +public: + + /** + * @brief Creates an uninitialized Gesture handle. + * + * Calling member functions with an uninitialized Actor handle is not allowed. + * @SINCE_1_9.28 + */ + Gesture(); + /** * @brief Copy constructor. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ Gesture( const Gesture& rhs ); /** + * @brief Move constructor. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the handle to move + */ + Gesture( Gesture&& rhs ); + + /** * @brief Assignment operator. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle * @return A reference to this */ Gesture& operator=( const Gesture& rhs ); - // Destruction + /** + * @brief Move assignment operator. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the handle to move + * @return A reference to this + */ + Gesture& operator=( Gesture&& rhs ); /** - * @brief Virtual destructor. - * @SINCE_1_0.0 + * @brief Non virtual destructor. + * @SINCE_1_9.28 */ - virtual ~Gesture(); + ~Gesture(); /** * @brief Enumeration for type of gesture. @@ -98,37 +127,40 @@ struct DALI_CORE_API Gesture Possible ///< A gesture is possible. @SINCE_1_0.0 }; - // Data - /** * @brief The gesture type. + * @SINCE_1_9.28 + * @return The gesture type */ - Type type; + Type GetType() const; /** * @brief The gesture state. * * Please see the description in the sub-classes to see the states * used by the actual gesture. + * @SINCE_1_9.28 + * @return The state of the gesture */ - State state; + State GetState() const; /** * @brief The time the gesture took place. + * @SINCE_1_9.28 + * @return The time the gesture took place */ - uint32_t time; + uint32_t GetTime() const; -protected: // Creation +public: // Not intended for application developers + /// @cond internal /** - * @brief This constructor is only used by derived classes. - * - * @SINCE_1_0.0 - * @param[in] gestureType The type of gesture event. - * @param[in] gestureState The state of the gesture event. + * @brief Internal constructor. + * @SINCE_1_9.28 + * @param[in] gesture Pointer to internal gesture */ - Gesture(Type gestureType, State gestureState); - + explicit DALI_INTERNAL Gesture(Internal::Gesture* gesture); + /// @endcond }; /** diff --git a/dali/public-api/events/long-press-gesture-detector.h b/dali/public-api/events/long-press-gesture-detector.h index 97049c9..937ec77 100644 --- a/dali/public-api/events/long-press-gesture-detector.h +++ b/dali/public-api/events/long-press-gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_LONG_PRESS_GESTURE_DETECTOR_H /* - * Copyright (c) 2019 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. @@ -37,7 +37,7 @@ namespace Internal DALI_INTERNAL class LongPressGestureDetector; } -struct LongPressGesture; +class LongPressGesture; /** * @brief This class emits a signals when a long press gesture occurs that meets the requirements set by the application. diff --git a/dali/public-api/events/long-press-gesture.cpp b/dali/public-api/events/long-press-gesture.cpp index e329c82..1b99fce 100644 --- a/dali/public-api/events/long-press-gesture.cpp +++ b/dali/public-api/events/long-press-gesture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -18,38 +18,42 @@ // CLASS HEADER #include +// INTERNAL INCLUDES +#include + namespace Dali { -LongPressGesture::LongPressGesture(Gesture::State state) -: Gesture( Gesture::LongPress, state ), - numberOfTouches( 1 ) +LongPressGesture::LongPressGesture( Internal::LongPressGesture* internal ) +: Gesture( internal ) { } -LongPressGesture::LongPressGesture( const LongPressGesture& rhs ) -: Gesture( rhs ), - numberOfTouches( rhs.numberOfTouches ), - screenPoint( rhs.screenPoint ), - localPoint( rhs.localPoint ) +LongPressGesture::LongPressGesture() = default; + +LongPressGesture::LongPressGesture( const LongPressGesture& rhs ) = default; + +LongPressGesture::LongPressGesture( LongPressGesture&& rhs ) = default; + +LongPressGesture& LongPressGesture::operator=( const LongPressGesture& rhs ) = default; + +LongPressGesture& LongPressGesture::operator=( LongPressGesture&& rhs ) = default; + +LongPressGesture::~LongPressGesture() = default; + +uint32_t LongPressGesture::GetNumberOfTouches() const { + return GetImplementation( *this ).GetNumberOfTouches(); } -LongPressGesture& LongPressGesture::operator=( const LongPressGesture& rhs ) +const Vector2& LongPressGesture::GetScreenPoint() const { - if( this != &rhs ) - { - Gesture::operator=(rhs); - numberOfTouches = rhs.numberOfTouches; - screenPoint = rhs.screenPoint; - localPoint = rhs.localPoint; - } - - return *this; + return GetImplementation( *this ).GetScreenPoint(); } -LongPressGesture::~LongPressGesture() +const Vector2& LongPressGesture::GetLocalPoint() const { + return GetImplementation( *this ).GetLocalPoint(); } } // namespace Dali diff --git a/dali/public-api/events/long-press-gesture.h b/dali/public-api/events/long-press-gesture.h index 893bcaf..6da5e26 100644 --- a/dali/public-api/events/long-press-gesture.h +++ b/dali/public-api/events/long-press-gesture.h @@ -2,7 +2,7 @@ #define DALI_LONG_PRESS_GESTURE_H /* - * Copyright (c) 2019 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. @@ -24,6 +24,12 @@ namespace Dali { + +namespace Internal DALI_INTERNAL +{ +class LongPressGesture; +} + /** * @addtogroup dali_core_events * @{ @@ -37,64 +43,96 @@ namespace Dali * * Long press gesture finishes when all touches have been released. * - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @see LongPressGestureDetector */ -struct DALI_CORE_API LongPressGesture : public Gesture +class DALI_CORE_API LongPressGesture : public Gesture { - // Construction & Destruction +public: /** - * @brief Constructor. + * @brief Creates an uninitialized LongPressGesture handle. * - * @SINCE_1_0.0 - * @param[in] state The state of the gesture + * Calling member functions with an uninitialized Actor handle is not allowed. + * @SINCE_1_9.28 */ - LongPressGesture(Gesture::State state); + LongPressGesture(); /** * @brief Copy constructor. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ LongPressGesture( const LongPressGesture& rhs ); /** + * @brief Move constructor. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the handle to move + */ + LongPressGesture( LongPressGesture&& rhs ); + + /** * @brief Assignment operator. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle * @return A reference to this */ LongPressGesture& operator=( const LongPressGesture& rhs ); /** - * @brief Virtual destructor. - * @SINCE_1_0.0 + * @brief Move assignment operator. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the moved handle + * @return A reference to this */ - virtual ~LongPressGesture(); + LongPressGesture& operator=( LongPressGesture&& rhs ); - // Data + /** + * @brief Non virtual destructor. + * @SINCE_1_9.28 + */ + ~LongPressGesture(); /** - * @brief The number of touch points in this long press gesture, i.e. the number of fingers the user had - * on the screen to generate the long press gesture. + * @brief The number of touch points in this long press gesture. + * + * In other words, the number of fingers the user had on the screen to generate the long press gesture. + * @SINCE_1_9.28 + * @return The number of touch points */ - uint32_t numberOfTouches; + uint32_t GetNumberOfTouches() const; /** * @brief This is the point, in screen coordinates, where the long press occurred. * * If a multi-touch long press, then this is the centroid of all the touch points. + * @SINCE_1_9.28 + * @return The point where the long press occurred (in screen coordinates) */ - Vector2 screenPoint; + const Vector2& GetScreenPoint() const; /** * @brief This is the point, in local actor coordinates, where the long press occurred. * * If a multi-touch long press, then this is the centroid of all the touch points. + * @SINCE_1_9.28 * @return The point where tap has occurred (in local actor coordinates) */ - Vector2 localPoint; + const Vector2& GetLocalPoint() const; + +public: // Not intended for application developers + + /// @cond internal + /** + * @brief This constructor is used internally to Create an initialized LongPressGesture handle. + * + * @param[in] longPressGesture A pointer to a newly allocated Dali resource + * @SINCE_1_9.28 + */ + explicit DALI_INTERNAL LongPressGesture( Internal::LongPressGesture* longPressGesture ); + /// @endcond + }; /** diff --git a/dali/public-api/events/pan-gesture-detector.cpp b/dali/public-api/events/pan-gesture-detector.cpp index 637c76c..8accd54 100644 --- a/dali/public-api/events/pan-gesture-detector.cpp +++ b/dali/public-api/events/pan-gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -128,7 +128,7 @@ PanGestureDetector::DetectedSignalType& PanGestureDetector::DetectedSignal() return GetImplementation(*this).DetectedSignal(); } -void PanGestureDetector::SetPanGestureProperties( const PanGesture& pan ) +void PanGestureDetector::SetPanGestureProperties( const Dali::PanGesture& pan ) { Internal::PanGestureDetector::SetPanGestureProperties( pan ); } diff --git a/dali/public-api/events/pan-gesture-detector.h b/dali/public-api/events/pan-gesture-detector.h index 024e8ec..ec687d3 100644 --- a/dali/public-api/events/pan-gesture-detector.h +++ b/dali/public-api/events/pan-gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_PAN_GESTURE_DETECTOR_H /* - * Copyright (c) 2019 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. @@ -23,6 +23,7 @@ // INTERNAL INCLUDES #include +#include #include #include @@ -36,8 +37,6 @@ namespace Internal DALI_INTERNAL class PanGestureDetector; } -struct PanGesture; - /** * @addtogroup dali_core_events * @{ diff --git a/dali/public-api/events/pan-gesture.cpp b/dali/public-api/events/pan-gesture.cpp index a2a8f44..0550f54 100644 --- a/dali/public-api/events/pan-gesture.cpp +++ b/dali/public-api/events/pan-gesture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -20,73 +20,81 @@ // INTERNAL INCLUDES #include +#include namespace Dali { -PanGesture::PanGesture() -: Gesture(Gesture::Pan, Gesture::Clear), - numberOfTouches(1) +PanGesture::PanGesture( Internal::PanGesture* internal ) +: Gesture( internal ) { } -PanGesture::PanGesture(Gesture::State state) -: Gesture(Gesture::Pan, state), - numberOfTouches(1) +PanGesture::PanGesture() = default; + +PanGesture::PanGesture( const PanGesture& rhs ) = default; + +PanGesture::PanGesture( PanGesture&& rhs ) = default; + +PanGesture& PanGesture::operator=( const PanGesture& rhs ) = default; + +PanGesture& PanGesture::operator=( PanGesture&& rhs ) = default; + +PanGesture::~PanGesture() = default; + +const Vector2& PanGesture::GetVelocity() const +{ + return GetImplementation( *this ).GetVelocity(); +} + +const Vector2& PanGesture::GetDisplacement() const +{ + return GetImplementation( *this ).GetDisplacement(); +} + +const Vector2& PanGesture::GetPosition() const +{ + return GetImplementation( *this ).GetPosition(); +} + +const Vector2& PanGesture::GetScreenVelocity() const { + return GetImplementation( *this ).GetScreenVelocity(); } -PanGesture::PanGesture( const PanGesture& rhs ) -: Gesture( rhs ), - velocity( rhs.velocity ), - displacement( rhs.displacement ), - position( rhs.position ), - screenVelocity( rhs.screenVelocity ), - screenDisplacement( rhs.screenDisplacement ), - screenPosition( rhs.screenPosition ), - numberOfTouches( rhs.numberOfTouches ) +const Vector2& PanGesture::GetScreenDisplacement() const { + return GetImplementation( *this ).GetScreenDisplacement(); } -PanGesture& PanGesture::operator=( const PanGesture& rhs ) +const Vector2& PanGesture::GetScreenPosition() const { - if( this != &rhs ) - { - Gesture::operator=(rhs); - velocity = rhs.velocity; - displacement = rhs.displacement; - position = rhs.position; - screenVelocity = rhs.screenVelocity; - screenDisplacement = rhs.screenDisplacement; - screenPosition = rhs.screenPosition; - numberOfTouches = rhs.numberOfTouches; - } - - return *this; + return GetImplementation( *this ).GetScreenPosition(); } -PanGesture::~PanGesture() +uint32_t PanGesture::GetNumberOfTouches() const { + return GetImplementation( *this ).GetNumberOfTouches(); } float PanGesture::GetSpeed() const { - return velocity.Length(); + return GetImplementation( *this ).GetSpeed(); } float PanGesture::GetDistance() const { - return displacement.Length(); + return GetImplementation( *this ).GetDistance(); } float PanGesture::GetScreenSpeed() const { - return screenVelocity.Length(); + return GetImplementation( *this ).GetScreenSpeed(); } float PanGesture::GetScreenDistance() const { - return screenDisplacement.Length(); + return GetImplementation( *this ).GetScreenDistance(); } } // namespace Dali diff --git a/dali/public-api/events/pan-gesture.h b/dali/public-api/events/pan-gesture.h index 8c2432b..3087863 100644 --- a/dali/public-api/events/pan-gesture.h +++ b/dali/public-api/events/pan-gesture.h @@ -2,7 +2,7 @@ #define DALI_PAN_GESTURE_H /* - * Copyright (c) 2019 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. @@ -24,6 +24,12 @@ namespace Dali { + +namespace Internal DALI_INTERNAL +{ +class PanGesture; +} + /** * @addtogroup dali_core_events * @{ @@ -43,48 +49,55 @@ namespace Dali * - Cancelled by the system. * * A pan gesture will continue to be sent to the actor under than initial pan until it ends. - * @SINCE_1_0.0 + * @SINCE_1_9.28 */ -struct DALI_CORE_API PanGesture: public Gesture +class DALI_CORE_API PanGesture: public Gesture { - // Construction & Destruction - - /** - * @brief Default Constructor. - * @SINCE_1_0.0 - */ - PanGesture(); +public: /** - * @brief Constructor. + * @brief Creates an uninitialized PanGesture handle. * - * @SINCE_1_0.0 - * @param[in] state The state of the gesture + * Calling member functions with an uninitialized Actor handle is not allowed. + * @SINCE_1_9.28 */ - PanGesture(Gesture::State state); + PanGesture(); /** * @brief Copy constructor. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ PanGesture( const PanGesture& rhs ); /** + * @brief Move constructor. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the moved handle + */ + PanGesture( PanGesture&& rhs ); + + /** * @brief Assignment operator. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle * @return A reference to this */ PanGesture& operator=( const PanGesture& rhs ); /** - * @brief Virtual destructor. - * @SINCE_1_0.0 + * @brief Move assignment operator. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the moved handle + * @return A reference to this */ - virtual ~PanGesture(); + PanGesture& operator=( PanGesture&& rhs ); - // Data + /** + * @brief Non virtual destructor. + * @SINCE_1_9.28 + */ + ~PanGesture(); /** * @brief The velocity at which the user is moving their fingers. @@ -93,8 +106,10 @@ struct DALI_CORE_API PanGesture: public Gesture * A positive x value shows that the user is panning to the right, a negative x value means the opposite. * A positive y value shows that the user is panning downwards, a negative y values means upwards. * This value represents the local coordinates of the actor attached to the PanGestureDetector. + * @SINCE_1_9.28 + * @return The velocity of the pan */ - Vector2 velocity; + const Vector2& GetVelocity() const; /** * @brief This is a Vector2 showing how much the user has panned (dragged) since the last pan gesture or, @@ -104,13 +119,17 @@ struct DALI_CORE_API PanGesture: public Gesture * A positive y value shows that the user is panning downwards, a negative y value means upwards. * This value is in local actor coordinates, the actor being the one attached to the * PanGestureDetector. + * @SINCE_1_9.28 + * @return The displacement of the pan */ - Vector2 displacement; + const Vector2& GetDisplacement() const; /** * @brief This current touch position of the primary touch point in local actor coordinates. + * @SINCE_1_9.28 + * @return The current position of the pan (in local actor coordinates) */ - Vector2 position; + const Vector2& GetPosition() const; /** * @brief The velocity at which the user is moving their fingers. @@ -119,8 +138,10 @@ struct DALI_CORE_API PanGesture: public Gesture * A positive x value shows that the user is panning to the right, a negative x value means the opposite. * A positive y value shows that the user is panning downwards, a negative y values means upwards. * This value represents the screen coordinates. + * @SINCE_1_9.28 + * @return The velocity of the pan (in screen coordinates) */ - Vector2 screenVelocity; + const Vector2& GetScreenVelocity() const; /** * @brief This is a Vector2 showing how much the user has panned (dragged) since the last pan gesture or, @@ -129,18 +150,24 @@ struct DALI_CORE_API PanGesture: public Gesture * A positive x value shows that the user is panning to the right, a negative x value means the opposite. * A positive y value shows that the user is panning downwards, a negative y value means upwards. * This value is in screen coordinates. + * @SINCE_1_9.28 + * @return The displacement of the pan (in screen coordinates) */ - Vector2 screenDisplacement; + const Vector2& GetScreenDisplacement() const; /** * @brief This current touch position of the primary touch point in screen coordinates. + * @SINCE_1_9.28 + * @return The current position of the pan (in screen coordinates) */ - Vector2 screenPosition; + const Vector2& GetScreenPosition() const; /** * @brief The total number of fingers touching the screen in a pan gesture. + * @SINCE_1_9.28 + * @return The number of touches in the pan */ - uint32_t numberOfTouches; + uint32_t GetNumberOfTouches() const; // Convenience Methods @@ -148,7 +175,7 @@ struct DALI_CORE_API PanGesture: public Gesture * @brief Returns the speed at which the user is moving their fingers. * * This is the pixel movement per millisecond. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @return The speed of the pan (in pixels per millisecond) */ float GetSpeed() const; @@ -158,7 +185,7 @@ struct DALI_CORE_API PanGesture: public Gesture * if the gesture has just started, then the distance moved since the user touched the screen. * * This is always a positive value. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @return The distance, as a float, a user's finger has panned */ float GetDistance() const; @@ -167,7 +194,7 @@ struct DALI_CORE_API PanGesture: public Gesture * @brief Returns the speed at which the user is moving their fingers relative to screen coordinates. * * This is the pixel movement per millisecond. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @return The speed of the pan (in pixels per millisecond) */ float GetScreenSpeed() const; @@ -178,10 +205,23 @@ struct DALI_CORE_API PanGesture: public Gesture * since the user touched the screen. * * This is always a positive value. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @return The distance, as a float, a user's finger has panned */ float GetScreenDistance() const; + +public: // Not intended for application developers + + /// @cond internal + /** + * @brief This constructor is used internally to Create an initialized PanGesture handle. + * + * @param[in] panGesture A pointer to a newly allocated Dali resource + * @SINCE_1_9.28 + */ + explicit DALI_INTERNAL PanGesture( Internal::PanGesture* panGesture ); + /// @endcond + }; /** diff --git a/dali/public-api/events/pinch-gesture-detector.h b/dali/public-api/events/pinch-gesture-detector.h index db06235..9daf911 100644 --- a/dali/public-api/events/pinch-gesture-detector.h +++ b/dali/public-api/events/pinch-gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_PINCH_GESTURE_DETECTOR_H /* - * Copyright (c) 2019 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. @@ -34,7 +34,7 @@ namespace Internal DALI_INTERNAL class PinchGestureDetector; } -struct PinchGesture; +class PinchGesture; /** * @brief This class looks for pinching gestures involving two touches. diff --git a/dali/public-api/events/pinch-gesture.cpp b/dali/public-api/events/pinch-gesture.cpp index 9c72c25..4281665 100644 --- a/dali/public-api/events/pinch-gesture.cpp +++ b/dali/public-api/events/pinch-gesture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -20,42 +20,46 @@ // INTERNAL INCLUDES #include +#include namespace Dali { -PinchGesture::PinchGesture(Gesture::State state) -: Gesture(Gesture::Pinch, state), - scale(0.0f), - speed(0.0f) +PinchGesture::PinchGesture( Internal::PinchGesture* internal ) +: Gesture( internal ) { } -PinchGesture::PinchGesture( const PinchGesture& rhs ) -: Gesture( rhs ), - scale( rhs.scale ), - speed( rhs.speed ), - screenCenterPoint( rhs.screenCenterPoint ), - localCenterPoint( rhs.localCenterPoint ) +PinchGesture::PinchGesture() = default; + +PinchGesture::PinchGesture( const PinchGesture& rhs ) = default; + +PinchGesture::PinchGesture( PinchGesture&& rhs ) = default; + +PinchGesture& PinchGesture::operator=( const PinchGesture& rhs ) = default; + +PinchGesture& PinchGesture::operator=( PinchGesture&& rhs ) = default; + +PinchGesture::~PinchGesture() = default; + +float PinchGesture::GetScale() const +{ + return GetImplementation( *this ).GetScale(); +} + +float PinchGesture::GetSpeed() const { + return GetImplementation( *this ).GetSpeed(); } -PinchGesture& PinchGesture::operator=( const PinchGesture& rhs ) +const Vector2& PinchGesture::GetScreenCenterPoint() const { - if( this != &rhs ) - { - Gesture::operator=(rhs); - scale = rhs.scale; - speed = rhs.speed; - screenCenterPoint = rhs.screenCenterPoint; - localCenterPoint = rhs.localCenterPoint; - } - - return *this; + return GetImplementation( *this ).GetScreenCenterPoint(); } -PinchGesture::~PinchGesture() +const Vector2& PinchGesture::GetLocalCenterPoint() const { + return GetImplementation( *this ).GetLocalCenterPoint(); } } // namespace Dali diff --git a/dali/public-api/events/pinch-gesture.h b/dali/public-api/events/pinch-gesture.h index 9125b5e..71ec28a 100644 --- a/dali/public-api/events/pinch-gesture.h +++ b/dali/public-api/events/pinch-gesture.h @@ -2,7 +2,7 @@ #define DALI_PINCH_GESTURE_H /* - * Copyright (c) 2019 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. @@ -24,6 +24,12 @@ namespace Dali { + +namespace Internal DALI_INTERNAL +{ +class PinchGesture; +} + /** * @addtogroup dali_core_events * @{ @@ -39,68 +45,102 @@ namespace Dali * * A pinch gesture will continue to be sent to the actor under the center point of the pinch * until the pinch ends. - * @SINCE_1_0.0 + * @SINCE_1_9.28 */ -struct DALI_CORE_API PinchGesture: public Gesture +class DALI_CORE_API PinchGesture: public Gesture { - // Construction & Destruction +public: /** - * @brief Default Constructor. + * @brief Creates an uninitialized PinchGesture handle. * - * @SINCE_1_0.0 - * @param[in] state The state of the gesture + * Calling member functions with an uninitialized Actor handle is not allowed. + * @SINCE_1_9.28 */ - PinchGesture(Gesture::State state); + PinchGesture(); /** * @brief Copy constructor. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ PinchGesture( const PinchGesture& rhs ); /** + * @brief Move constructor. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the moved handle + */ + PinchGesture( PinchGesture&& rhs ); + + /** * @brief Assignment operator. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle * @return A reference to this */ PinchGesture& operator=( const PinchGesture& rhs ); /** - * @brief Virtual destructor. - * @SINCE_1_0.0 + * @brief Assignment operator. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the moved handle + * @return A reference to this */ - virtual ~PinchGesture(); + PinchGesture& operator=( PinchGesture&& rhs ); - // Data + /** + * @brief Non virtual destructor. + * @SINCE_1_9.28 + */ + ~PinchGesture(); /** * @brief The scale factor from the start of the pinch gesture till the latest pinch gesture. * - * If the user is moving their fingers away from each other, then - * this value increases. Conversely, if the user is moving their - * fingers towards each other, this value will decrease. + * If the user is moving their fingers away from each other, then this value increases. + * Conversely, if the user is moving their fingers towards each other, this value will + * decrease. + * @SINCE_1_9.28 + * @return The scale of the pinch (from the pinch start) */ - float scale; + float GetScale() const; /** * @brief The speed at which the user is moving their fingers. * * This is the pixel movement per second. + * @SINCE_1_9.28 + * @return The speed of the pinch (pixels per second) */ - float speed; + float GetSpeed() const; /** * @brief The center point of the two points that caused the pinch gesture in screen coordinates. + * @SINCE_1_9.28 + * @return The current center point of the pinch (in screen coordinates) */ - Vector2 screenCenterPoint; + const Vector2& GetScreenCenterPoint() const; /** * @brief The center point of the two points that caused the pinch gesture in local actor coordinates. + * @SINCE_1_9.28 + * @return The current center point of the pinch (in local actor coordinates) + */ + const Vector2& GetLocalCenterPoint() const; + +public: // Not intended for application developers + + /// @cond internal + /** + * @brief This constructor is used internally to Create an initialized PinchGesture handle. + * + * @param[in] PinchGesture A pointer to a newly allocated Dali resource + * @SINCE_1_9.28 */ - Vector2 localCenterPoint; + explicit DALI_INTERNAL PinchGesture( Internal::PinchGesture* pinchGesture ); + /// @endcond + }; /** diff --git a/dali/public-api/events/rotation-gesture-detector.h b/dali/public-api/events/rotation-gesture-detector.h index eab0de2..4647801 100644 --- a/dali/public-api/events/rotation-gesture-detector.h +++ b/dali/public-api/events/rotation-gesture-detector.h @@ -30,7 +30,7 @@ namespace Internal DALI_INTERNAL class RotationGestureDetector; } -struct RotationGesture; +class RotationGesture; /** * @brief This class looks for a rotation gesture involving two touches. diff --git a/dali/public-api/events/rotation-gesture.cpp b/dali/public-api/events/rotation-gesture.cpp index 03d6d81..a4a4637 100644 --- a/dali/public-api/events/rotation-gesture.cpp +++ b/dali/public-api/events/rotation-gesture.cpp @@ -20,38 +20,41 @@ // INTERNAL INCLUDES #include +#include namespace Dali { -RotationGesture::RotationGesture( Gesture::State state ) -: Gesture( Gesture::Rotation, state ) +RotationGesture::RotationGesture( Internal::RotationGesture* internal ) +: Gesture( internal ) { } -RotationGesture::RotationGesture( const RotationGesture& rhs ) -: Gesture( rhs ), - rotation( rhs.rotation ), - screenCenterPoint( rhs.screenCenterPoint ), - localCenterPoint( rhs.localCenterPoint ) +RotationGesture::RotationGesture() = default; + +RotationGesture::RotationGesture( const RotationGesture& rhs ) = default; + +RotationGesture::RotationGesture( RotationGesture&& rhs ) = default; + +RotationGesture& RotationGesture::operator=( const RotationGesture& rhs ) = default; + +RotationGesture& RotationGesture::operator=( RotationGesture&& rhs ) = default; + +RotationGesture::~RotationGesture() = default; + +const Radian& RotationGesture::GetRotation() const { + return GetImplementation( *this ).GetRotation(); } -RotationGesture& RotationGesture::operator=( const RotationGesture& rhs ) +const Vector2& RotationGesture::GetScreenCenterPoint() const { - if( this != &rhs ) - { - Gesture::operator=( rhs ); - rotation = rhs.rotation; - screenCenterPoint = rhs.screenCenterPoint; - localCenterPoint = rhs.localCenterPoint; - } - - return *this; + return GetImplementation( *this ).GetScreenCenterPoint(); } -RotationGesture::~RotationGesture() +const Vector2& RotationGesture::GetLocalCenterPoint() const { + return GetImplementation( *this ).GetLocalCenterPoint(); } } // namespace Dali diff --git a/dali/public-api/events/rotation-gesture.h b/dali/public-api/events/rotation-gesture.h index fa3894f..eb49f4e 100644 --- a/dali/public-api/events/rotation-gesture.h +++ b/dali/public-api/events/rotation-gesture.h @@ -26,6 +26,11 @@ namespace Dali { +namespace Internal DALI_INTERNAL +{ +class RotationGesture; +} + /** * @brief A RotationGesture is emitted when the user moves two fingers that are opposite each other * in a rotational/circular gesture. @@ -37,59 +42,88 @@ namespace Dali * * A rotation gesture will continue to be sent to the actor under the center point of the rotation * until the rotation ends. - * @SINCE_1_9.27 + * @SINCE_1_9.28 */ -struct DALI_CORE_API RotationGesture: public Gesture +class DALI_CORE_API RotationGesture: public Gesture { - // Construction & Destruction +public: /** - * @brief Default Constructor. - * @SINCE_1_9.27 - * @param[in] state The state of the gesture + * @brief Creates an uninitialized RotationGesture handle. + * + * Calling member functions with an uninitialized Actor handle is not allowed. + * @SINCE_1_9.28 */ - RotationGesture( Gesture::State state ); + RotationGesture(); /** * @brief Copy constructor. - * @SINCE_1_9.27 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ RotationGesture( const RotationGesture& rhs ); /** + * @brief Move constructor. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the moved handle + */ + RotationGesture( RotationGesture&& rhs ); + + /** * @brief Assignment operator. - * @SINCE_1_9.27 + * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle * @return A reference to this */ RotationGesture& operator=( const RotationGesture& rhs ); /** - * @brief Virtual destructor. - * @SINCE_1_9.27 + * @brief Move assignment operator. + * @SINCE_1_9.28 + * @param[in] rhs A reference to the moved handle + * @return A reference to this */ - virtual ~RotationGesture(); + RotationGesture& operator=( RotationGesture&& rhs ); - // Data + /** + * @brief Non virtual destructor. + * @SINCE_1_9.28 + */ + ~RotationGesture(); /** * @brief The overall rotation from the start of the rotation gesture till the latest rotation gesture. - * @SINCE_1_9.27 + * @SINCE_1_9.28 + * @return The rotation from the start of the rotation gesture till the latest rotation gesture. */ - Radian rotation; + const Radian& GetRotation() const; /** * @brief The center point of the two points that caused the rotation gesture in screen coordinates. - * @SINCE_1_9.27 + * @SINCE_1_9.28 + * @return The center point in screen coordinates */ - Vector2 screenCenterPoint; + const Vector2& GetScreenCenterPoint() const; /** * @brief The center point of the two points that caused the rotation gesture in local actor coordinates. - * @SINCE_1_9.27 + * @SINCE_1_9.28 + * @return The center point in local actor coordinates + */ + const Vector2& GetLocalCenterPoint() const; + +public: // Not intended for application developers + + /// @cond internal + /** + * @brief This constructor is used internally to Create an initialized RotationGesture handle. + * + * @param[in] rotationGesture A pointer to a newly allocated Dali resource + * @SINCE_1_9.28 */ - Vector2 localCenterPoint; + explicit DALI_INTERNAL RotationGesture( Internal::RotationGesture* rotationGesture ); + /// @endcond }; } // namespace Dali diff --git a/dali/public-api/events/tap-gesture-detector.h b/dali/public-api/events/tap-gesture-detector.h index 02406c2..2c17c4e 100644 --- a/dali/public-api/events/tap-gesture-detector.h +++ b/dali/public-api/events/tap-gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_TAP_GESTURE_DETECTOR_H /* - * Copyright (c) 2019 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. @@ -37,7 +37,7 @@ namespace Internal DALI_INTERNAL class TapGestureDetector; } -struct TapGesture; +class TapGesture; /** * @brief This class emits a signal when a tap gesture occurs that meets the requirements set by the diff --git a/dali/public-api/events/tap-gesture.cpp b/dali/public-api/events/tap-gesture.cpp index d20afc4..0dbefb6 100644 --- a/dali/public-api/events/tap-gesture.cpp +++ b/dali/public-api/events/tap-gesture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -18,41 +18,48 @@ // CLASS HEADER #include +// INTERNAL INCLUDES +#include +#include + namespace Dali { -TapGesture::TapGesture() -: Gesture(Gesture::Tap, Gesture::Clear), - numberOfTaps(1), - numberOfTouches(1) +TapGesture::TapGesture( Internal::TapGesture* internal ) +: Gesture( internal ) +{ +} + +TapGesture::TapGesture() = default; + +TapGesture::TapGesture( const TapGesture& rhs ) = default; + +TapGesture::TapGesture( TapGesture&& rhs ) = default; + +TapGesture& TapGesture::operator=( const TapGesture& rhs ) = default; + +TapGesture& TapGesture::operator=( TapGesture&& rhs ) = default; + +TapGesture::~TapGesture() = default; + +uint32_t TapGesture::GetNumberOfTaps() const { + return GetImplementation( *this ).GetNumberOfTaps(); } -TapGesture::TapGesture( const TapGesture& rhs ) -: Gesture( rhs ), - numberOfTaps( rhs.numberOfTaps ), - numberOfTouches( rhs.numberOfTouches ), - screenPoint( rhs.screenPoint ), - localPoint( rhs.localPoint ) +uint32_t TapGesture::GetNumberOfTouches() const { + return GetImplementation( *this ).GetNumberOfTouches(); } -TapGesture& TapGesture::operator=( const TapGesture& rhs ) +const Vector2& TapGesture::GetScreenPoint() const { - if( this != &rhs ) - { - Gesture::operator=(rhs); - numberOfTaps = rhs.numberOfTaps; - numberOfTouches = rhs.numberOfTouches; - screenPoint = rhs.screenPoint; - localPoint = rhs.localPoint; - } - - return *this; + return GetImplementation( *this ).GetScreenPoint(); } -TapGesture::~TapGesture() +const Vector2& TapGesture::GetLocalPoint() const { + return GetImplementation( *this ).GetLocalPoint(); } } // namespace Dali diff --git a/dali/public-api/events/tap-gesture.h b/dali/public-api/events/tap-gesture.h index 3584c26..6fa0a08 100644 --- a/dali/public-api/events/tap-gesture.h +++ b/dali/public-api/events/tap-gesture.h @@ -2,7 +2,7 @@ #define DALI_TAP_GESTURE_H /* - * Copyright (c) 2019 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. @@ -24,6 +24,12 @@ namespace Dali { + +namespace Internal DALI_INTERNAL +{ +class TapGesture; +} + /** * @addtogroup dali_core_events * @{ @@ -33,67 +39,100 @@ namespace Dali * @brief A TapGesture is emitted when the user taps the screen with the stated number of fingers a stated number of times. * * This is a discrete gesture so does not have any state information. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @see TapGestureDetector */ -struct DALI_CORE_API TapGesture : public Gesture +class DALI_CORE_API TapGesture : public Gesture { - // Construction & Destruction +public: /** - * @brief Default Constructor. - * @SINCE_1_0.0 + * @brief Creates an uninitialized TapGesture handle. + * + * Calling member functions with an uninitialized Actor handle is not allowed. + * @SINCE_1_9.28 */ TapGesture(); /** * @brief Copy constructor. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param rhs A reference to the copied handle */ TapGesture( const TapGesture& rhs ); /** + * @brief Move constructor. + * @SINCE_1_9.28 + * @param rhs The handle to move. + */ + TapGesture( TapGesture&& rhs ); + + /** * @brief Assignment operator. - * @SINCE_1_0.0 + * @SINCE_1_9.28 * @param rhs A reference to the copied handle * @return A reference to this */ TapGesture& operator=( const TapGesture& rhs ); /** - * @brief Virtual destructor. - * @SINCE_1_0.0 + * @brief Move assignment operator. + * @SINCE_1_9.28 + * @param rhs The handle to move. */ - virtual ~TapGesture(); + TapGesture& operator=( TapGesture&& rhs ); - // Data + /** + * @brief Non virtual destructor. + * @SINCE_1_9.28 + */ + ~TapGesture(); /** * @brief The number of taps in this tap gesture. + * @SINCE_1_9.28 + * @return The number of taps */ - uint32_t numberOfTaps; + uint32_t GetNumberOfTaps() const; /** * @brief The number of touch points in this tap gesture, i.e. the number of fingers the user had on the * screen to generate the tap gesture. + * @SINCE_1_9.28 + * @return The number of touchs */ - uint32_t numberOfTouches; + uint32_t GetNumberOfTouches() const; /** * @brief This is the point, in screen coordinates, where the tap occurred. * * If a multi-touch tap, then this is the centroid of all the touch points. + * @SINCE_1_9.28 + * @return The point where tap has occurred( in screen coordinates) */ - Vector2 screenPoint; + const Vector2& GetScreenPoint() const; /** * @brief This is the point, in local actor coordinates, where the tap occurred. * * If a multi-touch tap, then this is the centroid of all the touch points. + * @SINCE_1_9.28 * @return The point where tap has occurred (in local actor coordinates) */ - Vector2 localPoint; + const Vector2& GetLocalPoint() const; + +public: // Not intended for application developers + + /// @cond internal + /** + * @brief This constructor is used internally to Create an initialized TapGesture handle. + * + * @param[in] tapGesture A pointer to a newly allocated Dali resource + * @SINCE_1_9.28 + */ + explicit DALI_INTERNAL TapGesture( Internal::TapGesture* tapGesture ); + /// @endcond }; /**