add Convert from TouchEvent to TouchData 44/198944/7
authorjunqing.ma <junqing.ma@samsung.com>
Thu, 31 Jan 2019 07:55:40 +0000 (15:55 +0800)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 27 Feb 2019 09:40:10 +0000 (09:40 +0000)
Change-Id: I2a75db549b506c502eb622702459f892f2880c82

automated-tests/src/dali/utc-Dali-TouchProcessing.cpp [changed mode: 0644->0755]
dali/devel-api/events/touch-data-devel.cpp [new file with mode: 0755]
dali/devel-api/events/touch-data-devel.h [new file with mode: 0755]
dali/devel-api/file.list [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 0221591..b5f0ec9
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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,6 +22,7 @@
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/render-task-list-integ.h>
 #include <dali-test-suite-utils.h>
+#include <dali/devel-api/events/touch-data-devel.h>
 
 using namespace Dali;
 
@@ -1560,3 +1561,41 @@ int UtcDaliTouchInterruptedDifferentConsumer(void)
 
   END_TEST;
 }
+
+int UtcDaliTouchDataConvert(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  actor.SetSize(100.0f, 100.0f);
+  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+  Stage::GetCurrent().Add(actor);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Connect to actor's touch signal
+  SignalData data;
+  TouchEventFunctor functor(data);
+  actor.TouchedSignal().Connect(&application, functor);
+
+  Vector2 screenCoordiantes(10.0f, 10.0f);
+  Vector2 localCoordinates;
+  actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordiantes.x, screenCoordiantes.y);
+
+  // Emit a down signal
+  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordiantes));
+  Dali::TouchData touchData = Dali::DevelTouchData::Convert(data.touchEvent);
+
+  DALI_TEST_EQUALS( 1u, touchData.GetPointCount(), TEST_LOCATION );
+  DALI_TEST_EQUALS( screenCoordiantes, touchData.GetScreenPosition(0), TEST_LOCATION );
+  DALI_TEST_EQUALS( localCoordinates, touchData.GetLocalPosition(0), 0.1f, TEST_LOCATION );
+  DALI_TEST_EQUALS( PointState::DOWN, touchData.GetState(0), TEST_LOCATION );
+  DALI_TEST_EQUALS( actor, touchData.GetHitActor(0), TEST_LOCATION );
+
+  data.Reset();
+
+  END_TEST;
+
+}
\ No newline at end of file
diff --git a/dali/devel-api/events/touch-data-devel.cpp b/dali/devel-api/events/touch-data-devel.cpp
new file mode 100755 (executable)
index 0000000..e9a953d
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019 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 <dali/public-api/events/touch-data.h>
+#include <dali/public-api/events/touch-event.h>
+#include <dali/devel-api/events/touch-data-devel.h>
+#include <dali/internal/event/events/touch-data-impl.h>
+
+namespace Dali
+{
+
+namespace DevelTouchData
+{
+
+TouchData Convert( const TouchEvent& touchEvent )
+{
+  Internal::TouchDataPtr touchDataImpl( new Internal::TouchData(touchEvent.time ) );
+
+  for( auto&& touchEventPoint : touchEvent.points )
+  {
+    touchDataImpl->AddPoint( Integration::Point( touchEventPoint ) );
+  }
+
+  return TouchData( touchDataImpl.Get() );
+}
+
+} // namespace DevelTouchData
+
+} // namespace Dali
diff --git a/dali/devel-api/events/touch-data-devel.h b/dali/devel-api/events/touch-data-devel.h
new file mode 100755 (executable)
index 0000000..c63dc2d
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef DALI_TOUCH_DATA_DEVEL_H
+#define DALI_TOUCH_DATA_DEVEL_H
+
+/*
+ * Copyright (c) 2019 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.
+ *
+ */
+
+namespace Dali
+{
+
+class TouchData;
+struct TouchEvent;
+
+namespace DevelTouchData
+{
+
+/**
+ * @brief Convert TouchEvent to TouchData.
+ *
+ * @return The TouchData convert from Dali::TouchEvent
+ *
+ * @note Use this API with caution.
+*/
+DALI_CORE_API TouchData Convert( const TouchEvent& touchEvent );
+
+} // namespace DevelTouchData
+
+} // namespace Dali
+
+
+
+#endif // DALI_TOUCH_DATA_DEVEL_H
old mode 100644 (file)
new mode 100755 (executable)
index 7a953c8..bd74e49
@@ -8,6 +8,7 @@ devel_api_src_files = \
   $(devel_api_src_dir)/common/hash.cpp \
   $(devel_api_src_dir)/common/stage-devel.cpp \
   $(devel_api_src_dir)/events/hit-test-algorithm.cpp \
+  $(devel_api_src_dir)/events/touch-data-devel.cpp \
   $(devel_api_src_dir)/images/distance-field.cpp \
   $(devel_api_src_dir)/images/texture-set-image.cpp \
   $(devel_api_src_dir)/images/nine-patch-image.cpp \
@@ -45,7 +46,8 @@ devel_api_core_common_header_files = \
   $(devel_api_src_dir)/common/stage-devel.h
 
 devel_api_core_events_header_files = \
-  $(devel_api_src_dir)/events/hit-test-algorithm.h
+  $(devel_api_src_dir)/events/hit-test-algorithm.h \
+  $(devel_api_src_dir)/events/touch-data-devel.h
 
 devel_api_core_images_header_files = \
   $(devel_api_src_dir)/images/distance-field.h \