/*
- * 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.
#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;
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
--- /dev/null
+/*
+ * 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
--- /dev/null
+#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
$(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 \
$(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 \