Add ObjectView::CancelTouchEvent() 55/67655/1 accepted/tizen/common/20160428.144953 accepted/tizen/ivi/20160429.011431 accepted/tizen/mobile/20160429.011408 accepted/tizen/tv/20160429.011433 accepted/tizen/wearable/20160429.011421 submit/tizen/20160428.080835
authorHeeyong Song <heeyong.song@samsung.com>
Thu, 28 Apr 2016 01:41:03 +0000 (10:41 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Thu, 28 Apr 2016 01:41:03 +0000 (10:41 +0900)
Change-Id: I422eb84bbacf56cdb848a2bff252c51016c82aec

pepper-dali/internal/object-impl.cpp
pepper-dali/internal/object-view-impl.cpp
pepper-dali/internal/object-view-impl.h
pepper-dali/public-api/object-view/object-view.cpp
pepper-dali/public-api/object-view/object-view.h

index 1e51759..423daba 100644 (file)
@@ -131,10 +131,9 @@ bool Object::AttchBuffer( int* width, int* height )
   {
     mObjectView = Pepper::ObjectView::New();
 
-    mObjectView.TouchedSignal().Connect( this, &Object::OnTouched );
-
-    // Set surface
+    // Set surface and input modules
     Pepper::GetImplementation( mObjectView ).SetSurface( mSurface );
+    Pepper::GetImplementation( mObjectView ).SetInput( mPointer, mKeyboard, mTouch );
 
     // TODO: support multi touch, focus in/out, mouse in/out
 
@@ -221,51 +220,6 @@ Pepper::Object::ObjectSignalType& Object::ObjectViewDeletedSignal()
   return mObjectViewDeletedSignal;
 }
 
-bool Object::OnTouched( Actor actor, const TouchEvent& touchEvent )
-{
-  const TouchPoint& point = touchEvent.GetPoint(0);
-
-  Pepper::Internal::ShellClientPtr shellClient = reinterpret_cast< Pepper::Internal::ShellClient* >( pepper_object_get_user_data( reinterpret_cast< pepper_object_t* >( mSurface ), pepper_surface_get_role( mSurface ) ) );
-  if( !shellClient )
-  {
-    DALI_LOG_INFO( gPepperObjectLogging, Debug::General, "Object::OnTouched: shellClient is null. mSurface = %p\n", mSurface );
-    return false;
-  }
-
-  switch( point.state )
-  {
-    case TouchPoint::Down:
-    {
-      pepper_touch_add_point( mTouch, point.deviceId, point.local.x, point.local.y );
-      pepper_touch_send_down( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId, point.local.x, point.local.y );
-
-      DALI_LOG_INFO( gPepperObjectLogging, Debug::Verbose, "Object::OnTouched: Touch Down (%.2f, %.2f) device = %d surface = %p\n", point.local.x, point.local.y, point.deviceId, mSurface );
-      return true;
-    }
-    case TouchPoint::Up:
-    {
-      pepper_touch_send_up( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId );
-      pepper_touch_remove_point( mTouch, point.deviceId );
-
-      DALI_LOG_INFO( gPepperObjectLogging, Debug::Verbose, "Object::OnTouched: Touch Up (%.2f, %.2f) surface = %p\n", point.local.x, point.local.y, mSurface );
-      return true;
-    }
-    case TouchPoint::Motion:
-    {
-      pepper_touch_send_motion( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId, point.local.x, point.local.y );
-
-//      DALI_LOG_INFO( gPepperObjectLogging, Debug::Verbose, "Object::OnTouched: Touch Motion (%.2f, %.2f)\n", point.local.x, point.local.y );
-      return true;
-    }
-    default:
-    {
-      return false;
-    }
-  }
-
-  return false;
-}
-
 void Object::OnDestroySurface( pepper_event_listener_t* listener, pepper_object_t* pepperObject, uint32_t id, void* info, void* data )
 {
   Object* object = static_cast< Object* >( data );
index 40d9cbe..0dc2a17 100644 (file)
@@ -22,6 +22,7 @@
 #include <pepper-dali/internal/shell-client-impl.h>
 
 // EXTERNAL INCLUDES
+#include <dali/public-api/events/touch-event.h>
 #include <dali/integration-api/debug.h>
 
 namespace Dali
@@ -61,7 +62,11 @@ ObjectView::ObjectView()
 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ),
   mWidth( 0 ),
   mHeight( 0 ),
-  mSurface( NULL )
+  mTouchDown( false ),
+  mSurface( NULL ),
+  mPointer( NULL ),
+  mKeyboard( NULL ),
+  mTouch( NULL )
 {
 }
 
@@ -131,11 +136,96 @@ std::string ObjectView::GetAppId() const
   return appId;
 }
 
+bool ObjectView::CancelTouchEvent()
+{
+  if( !mTouchDown )
+  {
+    return false;
+  }
+
+  Pepper::Internal::ShellClientPtr shellClient = reinterpret_cast< Pepper::Internal::ShellClient* >( pepper_object_get_user_data( reinterpret_cast< pepper_object_t* >( mSurface ), pepper_surface_get_role( mSurface ) ) );
+  if( !shellClient )
+  {
+    DALI_LOG_INFO( gPepperObjectViewLogging, Debug::General, "ObjectView::CancelTouchEvent: shellClient is null. mSurface = %p\n", mSurface );
+    return false;
+  }
+
+  pepper_touch_send_cancel( mTouch, shellClient->GetView() );
+  pepper_touch_remove_point( mTouch, 0 );
+
+  mTouchDown = false;
+
+  return true;
+}
+
 void ObjectView::SetSurface( pepper_surface_t* surface )
 {
   mSurface = surface;
 }
 
+void ObjectView::SetInput( pepper_pointer_t* pointer, pepper_keyboard_t* keyboard, pepper_touch_t* touch )
+{
+  mPointer = pointer;
+  mKeyboard = keyboard;
+  mTouch = touch;
+}
+
+bool ObjectView::OnTouchEvent( const TouchEvent& touchEvent )
+{
+  if( 1 == touchEvent.GetPointCount() )
+  {
+    const TouchPoint& point = touchEvent.GetPoint(0);
+
+    Pepper::Internal::ShellClientPtr shellClient = reinterpret_cast< Pepper::Internal::ShellClient* >( pepper_object_get_user_data( reinterpret_cast< pepper_object_t* >( mSurface ), pepper_surface_get_role( mSurface ) ) );
+    if( !shellClient )
+    {
+      DALI_LOG_INFO( gPepperObjectViewLogging, Debug::General, "ObjectView::OnTouchEvent: shellClient is null. mSurface = %p\n", mSurface );
+      return false;
+    }
+
+    switch( point.state )
+    {
+      case TouchPoint::Down:
+      {
+        mTouchDown = true;
+
+        pepper_touch_add_point( mTouch, point.deviceId, point.local.x, point.local.y );
+        pepper_touch_send_down( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId, point.local.x, point.local.y );
+
+        DALI_LOG_INFO( gPepperObjectViewLogging, Debug::Verbose, "ObjectView::OnTouchEvent: Touch Down (%.2f, %.2f) device = %d surface = %p\n", point.local.x, point.local.y, point.deviceId, mSurface );
+        return true;
+      }
+      case TouchPoint::Up:
+      {
+        if( mTouchDown )
+        {
+          mTouchDown = false;
+
+          pepper_touch_send_up( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId );
+          pepper_touch_remove_point( mTouch, point.deviceId );
+
+          DALI_LOG_INFO( gPepperObjectViewLogging, Debug::Verbose, "ObjectView::OnTouchEvent: Touch Up (%.2f, %.2f) surface = %p\n", point.local.x, point.local.y, mSurface );
+          return true;
+        }
+        break;
+      }
+      case TouchPoint::Motion:
+      {
+        pepper_touch_send_motion( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId, point.local.x, point.local.y );
+
+//        DALI_LOG_INFO( gPepperObjectViewLogging, Debug::Verbose, "ObjectView::OnTouchEvent: Touch Motion (%.2f, %.2f)\n", point.local.x, point.local.y );
+        return true;
+      }
+      default:
+      {
+        return false;
+      }
+    }
+  }
+
+  return false;
+}
+
 void ObjectView::OnInitialize()
 {
   mImageView = Toolkit::ImageView::New();
index fe5c28e..a0c3cc6 100644 (file)
@@ -66,10 +66,20 @@ public:
   std::string GetAppId() const;
 
   /**
+   * @copydoc Dali::Pepper::ObjectView::CancelTouchEvent
+   */
+  bool CancelTouchEvent();
+
+  /**
    * Set pepper surface
    */
   void SetSurface( pepper_surface_t* surface );
 
+  /**
+   * Set pepper input modules
+   */
+  void SetInput( pepper_pointer_t* pointer, pepper_keyboard_t* keyboard, pepper_touch_t* touch );
+
 protected:
 
   /**
@@ -82,6 +92,13 @@ protected:
    */
   virtual ~ObjectView();
 
+protected: // From CustomActorImpl
+
+  /**
+   * @copydoc Dali::CustomActorImpl::OnTouchEvent( const TouchEvent& event )
+   */
+  virtual bool OnTouchEvent( const TouchEvent& event );
+
 private: // From Control
 
   /**
@@ -105,7 +122,12 @@ private:
   int mWidth;
   int mHeight;
 
+  bool mTouchDown;
+
   pepper_surface_t* mSurface;
+  pepper_pointer_t* mPointer;
+  pepper_keyboard_t* mKeyboard;
+  pepper_touch_t* mTouch;
 };
 
 } // namespace Internal
index 9485151..8c8b3fd 100644 (file)
@@ -79,6 +79,11 @@ std::string ObjectView::GetAppId() const
   return Dali::Pepper::GetImplementation( *this ).GetAppId();
 }
 
+bool ObjectView::CancelTouchEvent()
+{
+  return Dali::Pepper::GetImplementation( *this ).CancelTouchEvent();
+}
+
 ObjectView::ObjectView( Internal::ObjectView& implementation )
 : Control( implementation )
 {
index 2e8d83b..cbbe31e 100644 (file)
@@ -131,6 +131,14 @@ public:
    */
   std::string GetAppId() const;
 
+  /**
+   * @brief Cancels touch event procedure.
+   *
+   * @since_tizen 3.0
+   * @return true on success, false otherwise.
+   */
+  bool CancelTouchEvent();
+
 public: // Not intended for application developers
 
   /**