namespace
{
+const int DEFAULT_FONT_PIXEL_SIZE = 30; // Referred platform widget viewer evas
+
#define GET_LOCALE_TEXT(string) dgettext(PKGNAME, string)
#if defined(DEBUG_ENABLED)
DALI_SIGNAL_REGISTRATION( Dali::WidgetView, WidgetView, "widgetContentUpdated", SIGNAL_WIDGET_CONTENT_UPDATED )
DALI_SIGNAL_REGISTRATION( Dali::WidgetView, WidgetView, "widgetUpdatePeriodChanged", SIGNAL_WIDGET_UPDATE_PERIOD_CHANGED )
DALI_SIGNAL_REGISTRATION( Dali::WidgetView, WidgetView, "widgetFaulted", SIGNAL_WIDGET_FAULTED )
+DALI_SIGNAL_REGISTRATION( Dali::WidgetView, WidgetView, "widgetTerminated", SIGNAL_WIDGET_TERMINATED )
// Actions
DALI_ACTION_REGISTRATION( Dali::WidgetView, WidgetView, "pauseWidget", ACTION_WIDGETVIEW_PAUSE_WIDGET );
{
Dali::WidgetView::Internal::WidgetView* widgetView = static_cast< Dali::WidgetView::Internal::WidgetView* >( data );
- if( widgetView )
+ if( widgetView && !widgetView->IsWidgetFaulted() )
{
widgetView->CloseRemoteSurface();
widgetView->RemoveWidgetImage();
mUpdatePeriod( 0.0 ),
mPreviewVisible( true ),
mLoadingTextVisible( true ),
- mTapTextVisible( true ),
+ mRetryTextVisible( true ),
+ mRetryState( false ),
mPermanentDelete( false ),
mWatcherHandle( NULL ),
mRemoteSurface( NULL )
mUpdatePeriod( updatePeriod ),
mPreviewVisible( true ),
mLoadingTextVisible( true ),
- mTapTextVisible( true ),
+ mRetryTextVisible( true ),
+ mRetryState( false ),
mPermanentDelete( false ),
mWatcherHandle( NULL ),
mRemoteSurface( NULL )
WidgetView::~WidgetView()
{
- if( !mWidgetId.empty() && !mInstanceId.empty() )
- {
- widget_instance_terminate( mInstanceId.c_str() );
-
- if( mPermanentDelete )
- {
- widget_instance_destroy( mInstanceId.c_str() );
- }
- }
+ TerminateWidget();
}
bool WidgetView::PauseWidget()
void WidgetView::SetLoadingTextVisible( bool visible )
{
- if( mStateText && mLoadingTextVisible != visible )
+ if( mLoadingText && mLoadingTextVisible != visible )
{
mLoadingTextVisible = visible;
if( visible )
{
- mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
}
- mStateText.SetVisible( visible );
+ mLoadingText.SetVisible( visible );
}
}
if( mPid < 0 )
{
// Enable preview and loading text
- ShowTapWidgetState( false );
+ ShowRetryState( false );
ShowLoadingState( true );
// launch widget again
DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::ActivateFaultedWidget: widget_instance_launch is failed. [%s]\n", mWidgetId.c_str() );
ShowLoadingState( false );
- ShowTapWidgetState( true );
+ ShowRetryState( true );
// Emit signal
Dali::WidgetView::WidgetView handle( GetOwner() );
mWidgetCreationAbortedSignal.Emit( handle );
-
return;
}
+ screen_connector_toolkit_ops ops;
+ ops.updated_cb = OnBufferUpdated;
+ ops.removed_cb = OnSurfaceRemoved;
+ ops.added_cb = OnBufferAdded;
+ mWatcherHandle = screen_connector_toolkit_add(&ops, (char *)mInstanceId.c_str(), SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET, this);
+
DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::ActivateFaultedWidget: widget_instance_launch is called. [%s, mPid = %d]\n", mWidgetId.c_str(), mPid );
}
}
void WidgetView::RemoveWidgetImage()
{
- ShowTapWidgetState( true );
+ mWidgetImageView.SetVisible( false );
+ mWidgetImageView.Reset();
- // Emit signal
Dali::WidgetView::WidgetView handle( GetOwner() );
mWidgetDeletedSignal.Emit( handle );
- mWidgetImageView.SetVisible( false );
- mWidgetImageView.Reset();
-
DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::RemoveWidgetImage: Widget image is removed.\n" );
}
+void WidgetView::TerminateWidget()
+{
+ if( !mWidgetId.empty() && !mInstanceId.empty() )
+ {
+ widget_instance_terminate( mInstanceId.c_str() );
+
+ if( mPermanentDelete )
+ {
+ widget_instance_destroy( mInstanceId.c_str() );
+ }
+
+ Dali::WidgetView::WidgetView handle( GetOwner() );
+ mWidgetTerminatedSignal.Emit( handle );
+ mWidgetDeletedSignal.Emit( handle );
+
+ mWidgetId.clear();
+ mInstanceId.clear();
+
+ CloseRemoteSurface();
+ }
+
+ DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::TerminateWidget: Widget is terminated/destroyed and deleted signal is emitted.\n" );
+
+}
+
void WidgetView::SendWidgetEvent( int event )
{
Dali::WidgetView::WidgetView handle( GetOwner() );
}
case WIDGET_INSTANCE_EVENT_FAULT:
{
+ mPid = -1;
+ ShowRetryState( true );
mWidgetFaultedSignal.Emit( handle );
break;
}
}
case Dali::WidgetView::WidgetView::Property::PERMANENT_DELETE:
{
- bool del;
- if( value.Get( del ) )
+ bool permanent;
+ if( value.Get( permanent ) )
{
- impl.SetPermanentDelete( del );
+ impl.SetPermanentDelete( permanent );
}
break;
}
return mWidgetFaultedSignal;
}
+Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetView::WidgetTerminatedSignal()
+{
+ return mWidgetTerminatedSignal;
+}
+
void WidgetView::OnInitialize()
{
char* instanceId = NULL;
mStateTextActor.SetAnchorPoint( AnchorPoint::CENTER );
mStateTextActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- // State text
- mStateText = Toolkit::TextLabel::New( GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
- mStateText.SetParentOrigin( ParentOrigin::CENTER );
- mStateText.SetAnchorPoint( AnchorPoint::CENTER );
- mStateText.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
- mStateText.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
- mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Dali::Color::WHITE );
- mStateText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, "Bold" );
+ // Loading text
+ mLoadingText = Toolkit::TextLabel::New( GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
+ mLoadingText.SetParentOrigin( ParentOrigin::CENTER );
+ mLoadingText.SetAnchorPoint( AnchorPoint::CENTER );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Dali::Color::WHITE );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, "Bold" );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, TextPixelToPointSize( DEFAULT_FONT_PIXEL_SIZE ) );
mPreviewActor.Add( mStateTextActor );
- mStateTextActor.Add( mStateText );
+ mStateTextActor.Add( mLoadingText );
+
+ // Retry text
+ mRetryText = Toolkit::TextLabel::New( GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) );
+ mRetryText.SetParentOrigin( ParentOrigin::CENTER );
+ mRetryText.SetAnchorPoint( AnchorPoint::CENTER );
+ mRetryText.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ mRetryText.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+ mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Dali::Color::WHITE );
+ mRetryText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, "Bold" );
+ mRetryText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, TextPixelToPointSize( DEFAULT_FONT_PIXEL_SIZE ) );
+
+ mStateTextActor.Add( mRetryText );
+ mRetryText.SetVisible( false );
// launch widget
mPid = widget_instance_launch( instanceId, (char *)mContentInfo.c_str(), mWidth, mHeight );
if( mPid < 0)
{
- ShowTapWidgetState( true );
+ ShowLoadingState( false );
+ ShowRetryState( true );
DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_launch is failed. [%s]\n", mWidgetId.c_str() );
{
tizen_remote_surface_event_type type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_NONE;
- if( event.GetPointCount() == 0 || mRemoteSurface == NULL )
+ if( event.GetPointCount() == 0 )
{
return false;
}
case Dali::PointState::UP:
{
type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP;
+
+ if( mRetryState )
+ {
+ ActivateFaultedWidget();
+ return false;
+ }
+
break;
}
case Dali::PointState::DOWN:
}
}
+ if( mRemoteSurface == NULL )
+ {
+ return false;
+ }
+
int button = 1;
if( type == TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE )
void WidgetView::CloseRemoteSurface()
{
- screen_connector_toolkit_remove( mWatcherHandle );
+ if( mWatcherHandle != NULL )
+ {
+ screen_connector_toolkit_remove( mWatcherHandle );
+ mWatcherHandle = NULL;
+ }
mRemoteSurface = NULL;
+ mPid = -1;
}
void WidgetView::ShowLoadingState( bool show )
mPreviewImage.SetVisible( show );
}
- if( mStateText && mLoadingTextVisible )
+ if( mLoadingText && mLoadingTextVisible )
{
- mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
- mStateText.SetVisible( show );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
+ mLoadingText.SetVisible( show );
}
}
-void WidgetView::ShowTapWidgetState( bool show )
+void WidgetView::ShowRetryState( bool show )
{
if( mPreviewImage && mPreviewVisible )
{
mPreviewImage.SetVisible( false );
}
- if( mStateText && mTapTextVisible )
+ if( mRetryText && mRetryTextVisible )
{
- mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) );
- mStateText.SetVisible( show );
+ mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) );
+ mRetryText.SetVisible( show );
+ mRetryState = show;
}
}
void WidgetView::SetLoadingTextPropertyMap( Property::Map map )
{
- if( mStateText )
+ if( mLoadingText )
{
Property::Value* fontStyle = map.Find( FONT_STYLE );
std::string style;
if( fontStyle && fontStyle->Get( style ) )
{
- mStateText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, style );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, style );
}
Property::Value* textPointSize = map.Find( TEXT_POINT_SIZE );
if( textPointSize && textPointSize->Get( size ) )
{
- mStateText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, size );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, size );
}
Property::Value* textColor = map.Find( TEXT_COLOR );
if( textColor && textColor->Get( color ) )
{
- mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, color );
+ mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, color );
}
}
}
+float WidgetView::TextPixelToPointSize( int pixelSize )
+{
+ Dali::Vector2 dpi = Dali::Stage::GetCurrent().GetDpi();
+ float meanDpi = (dpi.height + dpi.width) / 2.0f;
+
+ return (pixelSize * 72.0f) / meanDpi;
+}
+
} // namespace Internal
} // namespace WidgetView