From 976c1ec00d799f57a1ef4e665b73314ab78fa56b Mon Sep 17 00:00:00 2001 From: "taeyoon0.lee" Date: Tue, 20 Jun 2017 21:04:37 +0900 Subject: [PATCH] Added mouse in/out for mouse event Change-Id: Ia1e0cb8ba3894630043c2f0f51070bc11adcafa1 --- internal/widget_view/widget_view_impl.cpp | 231 ++++++++++++++++++++++-------- internal/widget_view/widget_view_impl.h | 8 ++ 2 files changed, 181 insertions(+), 58 deletions(-) diff --git a/internal/widget_view/widget_view_impl.cpp b/internal/widget_view/widget_view_impl.cpp index 6a2e7f7..9dbb93e 100644 --- a/internal/widget_view/widget_view_impl.cpp +++ b/internal/widget_view/widget_view_impl.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -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 diff --git a/internal/widget_view/widget_view_impl.h b/internal/widget_view/widget_view_impl.h index 8783aa2..3d64bed 100644 --- a/internal/widget_view/widget_view_impl.h +++ b/internal/widget_view/widget_view_impl.h @@ -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 /** -- 2.7.4