Added mouse in/out for mouse event
authortaeyoon0.lee <taeyoon0.lee@samsung.com>
Tue, 20 Jun 2017 12:04:37 +0000 (21:04 +0900)
committertaeyoon0.lee <taeyoon0.lee@samsung.com>
Thu, 6 Jul 2017 14:24:58 +0000 (23:24 +0900)
Change-Id: Ia1e0cb8ba3894630043c2f0f51070bc11adcafa1

internal/widget_view/widget_view_impl.cpp
internal/widget_view/widget_view_impl.h

index 6a2e7f7..9dbb93e 100644 (file)
@@ -30,6 +30,7 @@
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali/integration-api/debug.h>
+#include <dali/devel-api/events/touch-event-devel.h>
 #include <string.h>
 #include <Ecore_Input.h>
 #include <widget_service.h>
@@ -233,7 +234,7 @@ bool WidgetView::PauseWidget()
   int ret = widget_instance_pause( mInstanceId.c_str() );
   if( ret < 0 )
   {
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::PauseWidget: Fail to pause widget(%s, %s) [%d]\n", mWidgetId.c_str(), mInstanceId.c_str(), ret );
+    DALI_LOG_ERROR( "WidgetView::PauseWidget: Fail to pause widget(%s, %s) [%d]\n", mWidgetId.c_str(), mInstanceId.c_str(), ret );
     return false;
   }
 
@@ -247,7 +248,7 @@ bool WidgetView::ResumeWidget()
   int ret = widget_instance_resume( mInstanceId.c_str() );
   if( ret < 0 )
   {
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::ResumeWidget: Fail to resume widget(%s, %s) [%d]\n", mWidgetId.c_str(), mInstanceId.c_str(), ret );
+    DALI_LOG_ERROR( "WidgetView::ResumeWidget: Fail to resume widget(%s, %s) [%d]\n", mWidgetId.c_str(), mInstanceId.c_str(), ret );
     return false;
   }
 
@@ -348,7 +349,7 @@ void WidgetView::SetLoadingTextVisible( bool visible )
 
     if( visible )
     {
-      mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, 
+      mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT,
                                 ( mLoadingTextString.empty() )? GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) : mLoadingTextString );
     }
     mLoadingText.SetVisible( visible );
@@ -945,73 +946,27 @@ void WidgetView::ConnectSignal( tizen_remote_surface* surface )
 
 bool WidgetView::OnTouch( Dali::Actor actor, const Dali::TouchData& event )
 {
-  tizen_remote_surface_event_type type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_NONE;
-
   if( event.GetPointCount() == 0 )
   {
     return false;
   }
 
-  switch( event.GetState( 0 ) )
-  {
-    case Dali::PointState::UP:
-    {
-      type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP;
-
-      if( mRetryState )
-      {
-        ActivateFaultedWidget();
-        return false;
-      }
-
-      break;
-    }
-    case Dali::PointState::DOWN:
-    {
-      type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_DOWN;
-      break;
-    }
-    case Dali::PointState::MOTION:
-    {
-      type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE;
-      break;
-    }
-    default:
-    {
-      return false;
-    }
-  }
-
   if( mRemoteSurface == NULL )
   {
     return false;
   }
 
-  int button = 1;
-
-  if( type == TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE )
+  DevelDevice::Class::Type deviceType = DevelTouchData::GetDeviceClass( event, 0 );
+  if( deviceType == DevelDevice::Class::MOUSE )
   {
-    button = 0 ;
+    return MouseEvent( event );
+  }
+  else if( deviceType == DevelDevice::Class::TOUCH )
+  {
+    return TouchEvent( event );
   }
 
-  Vector2 localPos = event.GetLocalPosition( 0 );
-
-  tizen_remote_surface_transfer_mouse_event( mRemoteSurface,
-                                             type,
-                                             0,
-                                             button,
-                                             (int)localPos.x,
-                                             (int)localPos.y,
-                                             wl_fixed_from_double( event.GetEllipseRadius( 0 ).x ),
-                                             wl_fixed_from_double( event.GetEllipseRadius( 0 ).y ),
-                                             wl_fixed_from_double( event.GetPressure( 0 ) ),
-                                             wl_fixed_from_double( event.GetAngle( 0 ).degree ),
-                                             TIZEN_INPUT_DEVICE_CLAS_TOUCHSCREEN,
-                                             TIZEN_INPUT_DEVICE_SUBCLAS_NONE,
-                                             "",
-                                             event.GetTime()
-                                           );
-  return true;
+  return false;
 }
 
 bool WidgetView::OnWheelEvent( Dali::Actor actor, const Dali::WheelEvent& event )
@@ -1192,7 +1147,6 @@ void WidgetView::SetRetryTextPropertyMap( Property::Map map )
 
     Property::Value* textColor = map.Find( TEXT_COLOR );
     Vector4 color;
-
     if( textColor && textColor->Get( color ) )
     {
       mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, color );
@@ -1224,6 +1178,167 @@ float WidgetView::TextPixelToPointSize( int pixelSize )
   return (pixelSize * 72.0f) / meanDpi;
 }
 
+void WidgetView::MouseIn( const Dali::TouchData& event )
+{
+  Vector2 localPos = event.GetLocalPosition( 0 );
+
+  tizen_remote_surface_transfer_mouse_event( mRemoteSurface,
+                                             TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_IN,
+                                             0,
+                                             0,
+                                             (int)localPos.x,
+                                             (int)localPos.y,
+                                             0,
+                                             0,
+                                             0,
+                                             0,
+                                             TIZEN_INPUT_DEVICE_CLAS_MOUSE,
+                                             DevelTouchData::GetDeviceSubclass( event, 0 ),
+                                             "",
+                                             event.GetTime()
+                                           );
+}
+
+void WidgetView::MouseOut( const Dali::TouchData& event )
+{
+  tizen_remote_surface_transfer_mouse_event( mRemoteSurface,
+                                             TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_OUT,
+                                             0,
+                                             0,
+                                             0,
+                                             0,
+                                             0,
+                                             0,
+                                             0,
+                                             0,
+                                             TIZEN_INPUT_DEVICE_CLAS_MOUSE,
+                                             DevelTouchData::GetDeviceSubclass( event, 0 ),
+                                             "",
+                                             event.GetTime()
+                                           );
+}
+
+bool WidgetView::MouseEvent( const Dali::TouchData& event )
+{
+  tizen_remote_surface_event_type type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_NONE;
+  int button = 1;
+
+  switch( event.GetState( 0 ) )
+  {
+    case Dali::PointState::UP:
+    {
+      type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP;
+
+      if( mRetryState )
+      {
+        ActivateFaultedWidget();
+        return false;
+      }
+
+      break;
+    }
+    case Dali::PointState::DOWN:
+    {
+      type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_DOWN;
+      MouseIn( event );
+
+      break;
+    }
+    case Dali::PointState::MOTION:
+    {
+      type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE;
+      button = 0 ;
+      break;
+    }
+    default:
+    {
+      return false;
+    }
+  }
+
+  Vector2 localPos = event.GetLocalPosition( 0 );
+
+  tizen_remote_surface_transfer_mouse_event( mRemoteSurface,
+                                             type,
+                                             0,
+                                             button,
+                                             (int)localPos.x,
+                                             (int)localPos.y,
+                                             wl_fixed_from_double( event.GetEllipseRadius( 0 ).x ),
+                                             wl_fixed_from_double( event.GetEllipseRadius( 0 ).y ),
+                                             wl_fixed_from_double( event.GetPressure( 0 ) ),
+                                             wl_fixed_from_double( event.GetAngle( 0 ).degree ),
+                                             TIZEN_INPUT_DEVICE_CLAS_MOUSE,
+                                             DevelTouchData::GetDeviceSubclass( event, 0 ),
+                                             "",
+                                             event.GetTime()
+                                           );
+
+  if( event.GetState( 0 ) == Dali::PointState::UP)
+  {
+    MouseOut( event );
+  }
+
+  return true;
+}
+
+bool WidgetView::TouchEvent( const Dali::TouchData& event )
+{
+  tizen_remote_surface_event_type type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_NONE;
+  int button = 1;
+
+  switch( event.GetState( 0 ) )
+  {
+    case Dali::PointState::UP:
+    {
+      type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_TOUCH_UP;
+
+      if( mRetryState )
+      {
+        ActivateFaultedWidget();
+        return false;
+      }
+
+      break;
+    }
+    case Dali::PointState::DOWN:
+    {
+      type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_TOUCH_DOWN;
+
+      break;
+    }
+    case Dali::PointState::MOTION:
+    {
+      type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_TOUCH_MOVE;
+      button = 0;
+      break;
+    }
+    default:
+    {
+      return false;
+    }
+  }
+
+  Vector2 localPos = event.GetLocalPosition( 0 );
+
+  tizen_remote_surface_transfer_touch_event( mRemoteSurface,
+                                             type,
+                                             0,
+                                             button,
+                                             (int)localPos.x,
+                                             (int)localPos.y,
+                                             wl_fixed_from_double( event.GetEllipseRadius( 0 ).x ),
+                                             wl_fixed_from_double( event.GetEllipseRadius( 0 ).y ),
+                                             wl_fixed_from_double( event.GetPressure( 0 ) ),
+                                             wl_fixed_from_double( event.GetAngle( 0 ).degree ),
+                                             TIZEN_INPUT_DEVICE_CLAS_TOUCHSCREEN,
+                                             DevelTouchData::GetDeviceSubclass( event, 0 ),
+                                             "",
+                                             event.GetTime()
+                                           );
+  return true;
+}
+
 } // namespace Internal
 
 } // namespace WidgetView
index 8783aa2..3d64bed 100644 (file)
@@ -159,6 +159,14 @@ public: // Internal API
 
   void TerminateWidget();
 
+  void MouseIn( const Dali::TouchData& event );
+
+  void MouseOut( const Dali::TouchData& event );
+
+  bool MouseEvent( const Dali::TouchData& event );
+
+  bool TouchEvent( const Dali::TouchData& event );
+
 public: //Signals
 
   /**